//original lua originated from SF94. Modified to avoid conflicts.

-- Shared functions

rawset(_G, "info", {})

-- System info

local Notes = {
MAPHP = {
	"The first public version of PV\n\ It was basic with barely anything in it.\n\ This and the future versions had\n\ unnecessary death pits and visual issues.\n\ This version and a few other early\n\ versions have a night version.",
	"This item is just a basic\n\ fan particle generator but,\n\ it was accidentally snuck in because\n\ AirFox was still using\n\ the 1.09.4 CFG for the Doom builder.\n\ It was only kept in as an inside joke.",
	"This version added Trees and water.\n\ Though not saying much it was\n\ a lot more polished than the older version.",
	"This is the second Park Base.\n\ This one only was for\n\ plot reasons for a long RP I did.\n\ Recently reworked into a place for 1v1s.\n\ You can go to an updated\n\ version of this map in the corner\n\ of the park.\n\ A standalone version is currently\n\ only available in the SRB2 Skybase.",
	"This is the first big update\n\ of PV. It had a bit more direction as\n\ it included pathways,\n\ the first edits of 2.0 Frost Columns,\n\ and a resturant. Though the resturant was \n\ removed due to it being\n\ moved to a project called\n\ Park Valley Carnival, which was later\n\ canceled.",
	"Music used for Park Valley\n\ v3.0-5.0",
	"Music that was used with\n\ PV-music.wad, which is no longer\n\ available.",
	"...Woof",
	"Default PV Music",
	"This is an unreleased\n\ Park Valley base. Even though it\n\ was never really shown\n\ it still was worked on to \n\ learn new things, like making fofs.",
	"Welcome to the life of the first tree...",
	"This version of PV is the\n\ Most recent rework of the layout\n\ that you see today! Except 25% bigger.\n\ Made with help from Markus\n\ The map has way more polish and adds\n\ a hotel and a rework of the\n\ house area in 2.0 Frost Columns.\n\ The only big problem this version had is\n\ the map was too big for software mode.",
	"Christmas Version of PV.\n\ A lost version recreated from scratch.\n\ This is the first version to replaces\n\ all the textures/flats and objects\n\ to a christmas theme.",
	"Hmm.. it seems that you finished\n\ the level.\n\ If the server has the ability to,\n\ Type suicide\n\ in console to escape this.",
	"The Smileys don't want company",
	" \n\ \n\ \n\ No noclipping. Go through the entrance!",
	" \n\ \n\ \n\ No noclipping. Go find the button first!.",
	"Everyone from left to right:\n\ Spectrum\n\ Wane\n\ Alice\n\ Lat'\n\ Not Fox N.P.C\n\ Telos (in air)\n\ PixL\n\ TemporaryAl\n\ LightSpeedAngel\n\ .Jazz.\n\ Toykyle\n\ AirFox",
	"Music used for\n\Park Valley Christmas",
	"The Park Valley Museum Project\n\ Learn about the history of\n\ Park Valley!",
	"Toggle the weather for yourself.",
	"Welcome to Park Valley!\n\ Version 7.0\n\ The Visual Update\n\ The look of the main park\n\ was visually updated to look\n\ better, at least to me.",
	"Frost Columns was added to PV in 2.3.7\n\ as a secret. \n\ It was later added as secondary\n\ main part of PV,\n\ having modified an area to become a house.\n\ This house became my character's\n\ Joey The Ice Fox (SnowFox)\n\ and Sakura The Sky Fox's (AirFox) home.",
	"The secret was located here\n\ on the south side of the map.\n\ having a small hole for players to step in\n\ to teleport to FC",
	"I'm a little angel!",
	"Due to problems with Change Music\n\ This room is closed",
	"‚Thank you for playing Park Valley!\n\ ‚Since development in 2010\n\ ‚I am happy how everything\n\ ‚turned out! Special thanks to\n\ ‚everyone that has had a hand in this\n\ ‚and the encouraging words everyone\n\ ‚has said about this map. It helps alot.\n\ „And I thank you, the player\n\ „For exploring Park Valley! I hope\n\ „you enjoyed this as much as I did making it!\n\ ‚-AirFox/SnowFox",
	"Skyboxes unlocked!\n\ Go to the museum to get there!",
	"You haven't unlocked the ability\n\ to be here right now...",
	"No noclipping! Find a way to get there!",
	"Music used for\n\ Park Valley Winter",
	"God mode too? Get out of here.",
	"Stop trying to cheese,\n\ Noclipping isnt allowed here.",
	"Wall to the crystal area lowered!\n\ Find it in Frost Columns!",
	"The teleport behind this sign brings you\n\ to the end of this area.\n\ I recommend to try the crystal area\n\ if you haven't done it yet.\n\ if you don't care, or have done it already, \n\you can go through.",
	"Resturant to be condemned.\n\ Thank you for your service! -unused",
	"A wall raised nearby...",
	"Park Valley Version 5.6-5.8\n\ The 2019 Christmas version\n\ These updates added more detail on the\n\ teleporter to FC\n\ and added a cabin to the middle spot.\n\ This also saw some updates to the\n\ crystal area.",
	"In version 5 onward, the map got 25% smaller\n\ making the map suitable in Software mode\n\ (This was before 2.1.22 fixed\n\ the visual issues with big rooms)",
	"Collected all Egos!\n\ The master ego can now be awakened!",
	"Look at the sky",
	"Note 1\n\ A weird area appeared out of nowhere\n\ I am tasked to research its origins\n\ I can't wait!",
	"Note 2\n\ The clues of where this area came from\n\ isnt clear, this area is pretty clean\n\ as in there isnt any 'litter'",
	"Note 6\n\ I found two foxes\n\ one that looks like a white arctic fox,\n\ the other looks like a light blue fennec?\n\ I don't think they saw me. I'll see\n\ if I can avoid contact with them.",
	"Note 7\n\ it seems that those foxes\n\ added water and trees to the place\n\ which is odd because just yesterday\n\ there was none. I'm certain I should of heard\n\ something when it was being added.\n\ Another sign of teleportation?",
	"Note 10\n\ An attack happened.\n\ I kept down low here in my little\n\ tunnel while it was happening.\n\ There were weird pipes when everything\n\ went quiet. I might get a piece of it\n\ when there is no one around.",
	"Note 13\n\ I got a piece of the pipe as \n\ cleanly as possible, so it doesnt look\n\ off. It is very questionable tech,\n\ I cant enter it but water can. I'll\n\ do some more research on this.",
	"Note 14\n\ Today is a weird day.\n\ I woke up and the walls are\n\ lower. I'm not in the same place anymore.",
	"Note 17\n\ I've been here for a year now.\n\ Things have changed quite a bit since\n\ I've been here. A resturant was made but\n\ no one was serving. Its fine though,\n\ I no longer need food to live.",
	"Note 19\n\ Those foxes were just...\n\ Reconstructing the entire area.\n\ Also there is a new building, \n\ I'll check that out\n\ when everyone is gone.",
	"Note 20\n\ That building seems to be a hotel\n\ I looked in but the interior doesn't look\n\ like the same shape as the exterior,\n\ and there are no windows. \n\It also feels like im being transported\n\ into a new area everytime \n\I go through the entrance.",
	"Note 23\n\ Apparently theres a teleportation device\n\ in the middle of the park\n\ Going in I immediately became cold\n\ I'm not acrobatic so I can't go back\n\ if I drop down.\n\ Looks like those two foxes live here.\n\ How did they make such advanced tech?",
	"Note 30\n\ What the hell are these things?\n\ Their heads say 'EGO' on them. \n\ They aren't alive though\n\ just little plushies...\n\ To be honest I would be \n\ threatened if they were alive.\n\ At least they will keep me company.\n\ Maybe I can take one when I manage to leave\n\ this place.",
	"You feel a floor move somewhere\n\ in the museum...",
	"Note 28\n\ They made a museum on top\n\ of my little spot. Thank god I closed\n\ the entrance off when they did it.\n\ This also means I can learn more\n\ of this place. \n\ Maybe these 10 years will pull off.\n\ I'm so tired of being here...",
	"If you are reading this.\n\ I managed to create a teleporter out of here\n\ I am no longer stuck here in this hell.\n\ I don't want to know how this place exists\n\ and wanted to leave, so thats what I did.\n\ I just want to go home...\n\ Even if this teleporter doesnt bring me\n\ home. I'm glad I managed to leave this place.\n\ Im also leaving my notes here\n\ for anyone to read. I don't care anymore.",
	"Note 35\n\ Yes! The test teleporter works!\n\ I guess those foxes were\n\ some help after all.\n\ I stole their equipment to make this.\n\ Seems the shard helps the teleporter stay\n\ active even after a use.\n\ Good thing I only need to use it once\n\ to leave this place. Just got to be careful,\n\ the area around that shard stings.",
	"Seems like a room was here.\n\ But its gone now.",
	"Looks like a pile of paper\n\ The text written\n\ here is research on some\n\ of the technology used for\n\ Park Valley...",
	"Note 4\n\ I dont understand what these white\n\ particals are, I tasted one and\n\ it didnt taste like anything.\n\ I feel weird, hopefully I don't get sick.",
	"Note 26\n\ Its been 6 years since\n\ I got here, this place\n\ hasnt seen any renovations for a while.\n\ I'm starting to worry if I am still alive.\n\ Nothing interesting is happening\n\ to report. I wished I never\n\ got stuck in this hell.",
	"Event Board\n\ Temporary Version events will show up here \n\ if there are any\n\ \n\ \n\ \n\ \n\ \n\ Current Events: \n\ None",
	"Found the hidden ego, enjoy your points.",
	"I am the all knowing EGO\n\ Waking up the Master Ego will\n\ kill everyone here! Don't trust the\n\ EGOS! Collect every one and come back here\n\ I'll open a special room and\n\ deactivate the button for the\n\ Master EGO.\n\ I'll give more info after you do.",
	"1/30 Egos",
	"2/30 Egos",
	"3/30 Egos",
	"4/30 Egos",
	"5/30 Egos",
	"6/30 Egos",
	"7/30 Egos",
	"8/30 Egos",
	"9/30 Egos",
	"10/30 Egos",
	"11/30 Egos",
	"12/30 Egos",
	"13/30 Egos",
	"14/30 Egos",
	"15/30 Egos",
	"16/30 Egos",
	"17/30 Egos",
	"18/30 Egos",
	"19/30 Egos",
	"20/30 Egos",
	"21/30 Egos",
	"22/30 Egos",
	"23/30 Egos",
	"24/30 Egos",
	"25/30 Egos",
	"26/30 Egos",
	"27/30 Egos",
	"28/30 Egos",
	"29/30 Egos",
	"The EGOS you give the Master Ego will\n\ give him more power\n\ I've opened the room and\n\ disabled the ability to awaken the\n\ Master Ego\n\ Find my Special room in the crystal area\n\ and burn those EGOS you have collected\n\ to stop the Master Ego from getting\n\ stronger!",
	"Character Teleported\n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ ",
	"Thank you a lot, \n\ the true reward is in\n\ Frost Columns granted by it's\n\ power source located in the house.",
	"The island started development\n\ back in late 2018. Its the map\n\ I kept running out of ideas for\n\ and lost interest\n\ until early 2020 where I\n\ continued Park Valley more and  \n\ continued development again.",
	"This map became part of Park Valley\n\ as a sequal to Park Valley\n\ and as a backstory for the \n\ Ego Toads.",
	"Here are some old screenshots\n\ of The Island. The base of the map\n\ was always completed before starting\n\ on the interior of the\n\ Diner and the Sky Temple.",
	"The Frost Columns shown in PV is\n\ a modified version of SRB2 2.0\n\ FC. I might make more adjustments\n\ where it looks closer to 2.1/2.2\n\ But don't expect me to\n\ upgrade at all.",
	"The version has been lost,\n\ but the first completed version\n\ of the FC house was covered in\n\ ZIM textures. This was changed\n\ when Markus was in charge of the rework.",
	"The button for the Master Ego\n\ has been deactivated.",
	"The EGOs have been eliminated\n\ The Master Ego is weakened and\n\ continues his slumber...",
	"You have been powered up\n\ by the Power Crystal.",
	"Version 5.9\n\ This version did some visual\n\ changes to some areas of the map\n\ including removing those\n\ old random sectors in the middle\n\ of the park.\n\ This also included a rework to the\n\ Ice part of the crystal area\n\ and a difficulty adjustment to the\n\ lava area.",
	"Park Valley the Past\n\ A pk3 that has many of the\n\ older versions of Park Valley\n\ Currently, its only available \n\on the SRB2 Skybase.\n\ There might be an easier way to\n\ play this in the future.",
	"Park Valley",
	"Frost Columns",
	"Crystal Area",
	"Park Base",
	"Music used for\n\ Park Valley Halloween",
	"Music room, check out the music\n\ used for other version of\n\ Park Valley!\n\ Credits to each song is in the\n\ Sound Test menu, maybe check\n\ them out!",
	"Found part: 'Monitor'",
	"Found part: 'Generator'",
	"You are not allowed up there!",
	":)",
	"Found part: 'Powerful Ice Shard'",
	"monkey flip is cooler than you lmao xd",
	"egg",
	"Hey!\n\ I got here as soon as I got the reading.\n\ Once you enter the teleporter\n\ Park Valley will move to a new\n\ universe and fix itself from imploding.\n\ While its slowly recovering, \n\ I'll figure out\n\ how to get back to the island.\n\ you can revisit this place\n\ until it recovers.",
	"Cave Of Mystery Skybox unlocked\n\ If the skybox room is open\n\ you can enter there.",
	"The Blue Button of Mystery!\n\ Pressing it gives a random effect!\n\ Rather its a small change to the map,\n\ or to you! press it many times to\n\ figure them all out!\n\ There are 37 effects.\n\ The water is for cleansing yourself\n\ of any side effects.\n\ (AirFox does not take responsibility\n\ for any Desynchs this may cause.)\n\ (Hint: Not all effects happen here.)",
	"Harp seals are cool!",
	"You have been stunned by Rick Astley",
	"1/3\n\ This room is from the Finale event.\n\ this room appeared when the event was\n\ completed when it was available.\n\ Now its here in the museum.",
	"2/3\n\ Park Valley came in as a test map\n\ for me to learn the ropes for making\n\ a map. But as time went on\n\ I decided to make it a hangout map\n\ instead. Adding slight lore elements\n\ and more areas to explore.",
	"3/3\n\ I enjoyed maps like SF94, Hyper House,\n\ Tyrcity, and other hangout maps due to\n\ the amount of exploring each one had, and\n\ wanted to do the same. \n\ While it did take a long time to\n\ get the map to how I wanted it, \n\ I am glad I still\n\ continued to work on it.\n\ Thanks for playing Park Valley\n\ and hope you enjoy any future updates.",
	"The next pedistal are the names\n\ of the people who helped me\n\ out with Park Valley in general,\n\ Friends, or just those who were just there\n\ with me (Rather intentionally or\n\ unintentionally) helped make me\n\ continue Park Valley to what it is today.\n\ Some names listed are how I remember them.\n\ as I havent seen them for years.",
	"Demnyx, Colby Fox Kat, Mazefire, Sky,\n\ SteelT, Wind, Wolfy,\n\ .Jazz., Lat', TemporaryAL,\n\ Spectrum, Alice,\n\ Gemini Zodiac, NotablyPrettyCrazy\n\ Landiros, Skye, Toykyle, PixL, Glaber,\n\ SSS77, EternallyAries, Dage4, SirMania\n\ SonicFreak94, Markus",
	"I may have forgotten a few people,\n\ and while I dont think of this\n\ as a Hall of Fame or anything,\n\ I am glad to be apart of this\n\ community for 10 years,\n\ even though it has some rough\n\ edges. I cannot wait to \n\ continue more projects\n\ and learn more about everything to\n\ help me grow.",
	"While not everyone\n\ on this list physically\n\ helped with the map, some helped by\n\ being a buddy and didn't\n\ mind my pressence.",
	"To unlock this skybox\n\ you must complete the Finale event!",
	"Note to self:\n\ Keep more of an eye on \n\ Park Valley's status next time.\n\ It might affect more than just itself.",
	"If you want to go to The Island,\n\ get everyone on this teleporter\n\ once everyone is on it the teleport shall\n\ commence.\n\ Just dont touch the shards, they hurt.",
	"What? It didn't work?!\n\ I probably messed something up\n\ on my end. Everyone come back\n\ and we'll try again.",
	"Music used for the Finale Event",
	"Music used for Cave of Mystery,\n\ A map in Park Valley the Past",
	"‡Vega, or how its commonly named,\n\ ‡Park Valley is a sentient,\n\ universe hopping, chunk of land\n\ that came from an unknown source. \n\ it takes shape as\n\ a grassy area filled with\n\ strange plants and bushes. Though its\n\ true form is a vast, \n\ blue vortex that absorbs anything\n\ it touches. Though it doesn't like\n\ absorbing living creatures.",
	"Vega can always change how it looks,\n\ but it seems to like how it looks.\n\ Though it will change \n\ a little bit if it feels\n\ like doing so. \n\ Even at times changing based on\n\ how we build on it.",
	"While on Vega, it doesnt seem to mind\n\ our pressence, and seems to accept\n\ on what we build on it.\n\ or at least sometimes it does.\n\ it only gets angry at some things\n\ we put on it, abosrbing it into its vortex.\n\ I may have seen that resturant a few times\n\ while in the vortex, \n\ so I know its still around.",
	"Something that I found out is that\n\ whenever someone steps foot on\n\ Vega, they gain some sort of\n\ immortality, as the need to eat\n\ is gone and so is aging. \n\ But it seems that you still need to drink.\n\ Gotta stay hydrated on Vega!",
	"The water in Vega is \n\ completely drinkable and\n\ seems unlimited, you will never see that \n\ river stop flowing unless Vega wants it to.",
	"Vega speaks by changing the land\n\ around it, if it gets angry\n\ it starts destroying itself,\n\ showing its true form.\n\ basically, the more happy it is,\n\ the less you see of its vortex form.",
	"I've lost my steak but at\n\ least I am alive. I forget that\n\ Vega will try to destroy any\n\ food that exists on it.\n\ With the exception for any not on\n\ Park Valley itself.",
	"Don't try eating the berries\n\ in Park Valley, they are not food.\n\ In fact its only scenery\n\ to make some bushes look different.",
	"The Skybox room\n\ To unlock this room\n\ You must find the key in the\n\ Crystal Area.",
	"Rest in Peace Snowball\n\ A good kitty that was my\n\ little baby.\n\ I tried my best taking care\n\ of you but it wasnt enough.\n\ You will be remembered forever...\n\ \n\ \n\ Miss you already."


},

MAPIS = {
	"Hey! Don't pick me up!\n\ I'm not a plushy!..\n\ Oh sorry, Someone came over\n\ a few months ago and took 30\n\ of us in a box and shipped us\n\ to an unknown place. I don't want to know\n\ what happened to them.",
	"This weird looking cloud\n\ isn't really a cloud, but a \n\ transporter to the Sky Temple.\n\ inside lies the secrets of the Master Ego.",
	"This lighthouse's light\n\ is a bit strange, as it\n\ flickers rather than\n\ rotates. I don't think whoever\n\ put this together understands\n\ how lighthouses work.",
	"Theres a theory that there\n\ is unlimited supplies of food\n\ for this Diner, but it has yet to be\n\ proven. Though it seems they\n\ don't have to restock.",
	"I don't know why there is juice here,\n\ but it looks bigger\n\ on the inside.",
	"We EGOs don't like being called babies!\n\ We aren't young you know.\n\ What we are wearing are\n\ pants. Weirdo.",
	"We don't really have a home\n\ we sleep where we don't\n\ bother anyone. Those two houses\n\ are for two foxes\n\ who vacation here yearly.",
	"A weird explosion happened in\n\ the lighthouse. But it doesn't seem\n\ to have effected anything.\n\ It might of happened underground.",
	"These flowers are pretty!\n\ though there were\n\ more before I got here...",
	"I don't understand the popularity\n\ of these segways. I guess\n\ I would need one to find out.",
	"Welcome to the entrance\n\ of the Sky Temple.\n\ To learn a bit of the\n\ history of the\n\ Master Ego,\n\ just head inside.\n\ though you must learn how to\n\ read the text.",
	"That tower fell down\n\ cause three idiots were\n\ fighting over the speaker\n\ and one of them pushed\n\ the self destruct button.\n\ At least I don't have to hear them\n\ anymore.",
	"I wonder if I could go\n\ to those mountains.\n\ Jumping off just ends\n\ up going back to\n\ the island.",
	"The word 'EGO' was put on us\n\ from the creator themself.\n\ There is a chance where\n\ there could be one that doesn't\n\ have 'EGO' on their head.",
	"I was able to\n\ find out how to transport through\n\ universes... Now to find\n\ out how to go back to help\n\ people go back\n\ and from Park Valley.",
	"I found this book on how to\n\ read the text on the walls\n\ but you can have it.\n\ I can't read english text.",
	"You've got the ability to\n\ read the ancient EGO texts",
	"The master ego\n\ created us to\n\ have us multiply\n\ just for him to\n\ consume us for\n\ power",
	"Our power grows\n\ by consuming the\n\ environment\n\ around us\n\ \n\ We cannot\n\ control it",
	"Our lifespan\n\ is unknown as\n\ the master ego\n\ consumes us\n\ before we die\n\ of old age",
	"The master ego\n\ wants to become\n\ the all powerful\n\ leader of the\n\ world",
	"The master ego\n\ came from the\n\ elder ego whom\n\ was killed by\n\ the master ego\n\ due to different\n\ plans on the egos",
	"The only way to\n\ defeat the\n\ master ego\n\ is to get rid of\n\ us egos\n\ if we go extinct\n\ so does he",
	"The Smileys still don't want company",
	"Something about you teleporting here\n\ out of nowhere annoys me.",
	"Where did you come from?\n\ Don't scare me like that..",
	"How did you get in here?\n\ you must have the ability\n\ to go anywhere with that power huh?",
	"If you want to go to Park Valley,\n\ get everyone on this teleporter\n\ once everyone is on it the teleport shall\n\ commence.\n\ Just dont touch the shards, they hurt.",
	"What? It didn't work?!\n\ I probably messed something up\n\ on my end. Everyone come back\n\ and we'll try again.",
	"Character Teleported\n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ ",
	"This ball feels slow? If you want to help\n\ get a better one out\n\ contact the owner of the place.\n\ I'm sure he will be happy to\n\ credit ya if you help him out.\n\ The owner tried their best\n\ trying to make a good ball.\n\ Though he looked like he didnt\n\ feel happy with it.",
	"I found a book that has\n\ little tidbits of a place\n\ called 'Park Valley'.\n\ What a mysterious place indeed.",
	"This library has a bit of\n\ history of this island.\n\ Too bad they are all in English.\n\ We may speak it, but most\n\ of us can't read it.",
	"People say the Master Ego made us\n\ but in reality it was Elder Ego.\n\ The Elder Ego wanted us to bring\n\ power to others.\n\ But the Master Ego instead\n\ wanted the power to himself.\n\ So he eats us when he gets\n\ hungry for power.\n\ Its quite sad honestly.",
	"Coming soon"

	
}
}


local originalNotes = {}

function info.setwrd(map, n, text)
	map = "MAP"..$1

	if not originalNotes[map] originalNotes[map] = {} end
	originalNotes[map][n] = Notes[map][n]

	Notes[map][n] = text
end

function info.restorewrd()
	for map, _ in pairs(originalNotes)
		for n, _ in pairs(originalNotes[map])
			Notes[map][n] = originalNotes[map][n]
		end
	end

	originalNotes = {}
end


function info.wrd(p, text, style)
	if style ~= 100 and p.wrd and p.wrdStyle == 100 return end

	-- Regular Sign
	if style == 0
		if not p.wrd
			p.wrdLine = 0
			p.wrdAlpha = 10
		elseif p.wrdStyle == 1
			return
		end
		p.wrdTime = 1

	-- Special event
	elseif style == 1
		p.wrdLine = 0
		p.wrdAlpha = 10
		p.wrdTime = 4 * TICRATE

	-- Clientside Event
	elseif style == 2
		if not p.wrd
			p.wrdLine = 32
			p.wrdAlpha = 10
		elseif p.wrdStyle == 1
			return
		end
		p.wrdTime = 2 * TICRATE
	
	-- Ego Collect Event
	elseif style == 3
		p.wrdLine = 0
		p.wrdAlpha = 10
		p.wrdTime = 1 * TICRATE
	end

	p.wrd = text
	p.wrdStyle = style
end


function info.infowrd(p, wrd)
	if not p.wrd or p.wrdStyle ~= 100 p.wrdAlpha = 10 end
	p.wrdLine = 32
	p.wrdTime = 4 * TICRATE
	p.wrd = wrd
	p.wrdStyle = 100
end


addHook("LinedefExecute", function(line, mo)
	local text, style = Notes[G_BuildMapName(gamemap)][line.frontside.textureoffset / FRACUNIT], line.frontside.rowoffset / FRACUNIT

	if style == 1 or not mo.player or not mo.player.valid
		for p in players.iterate
			info.wrd(p, text, style)
		end
	else
		info.wrd(mo.player, text, style)
	end
end, "PVMINFO")



addHook("ThinkFrame", do
	for p in players.iterate
		if not p.wrd continue end

		if p.wrdTime == 0
			if p.wrdAlpha == 9 p.wrd = nil continue end
			if (leveltime & 3) == 3 p.wrdAlpha = $1 + 1 end
		else
			if p.wrdAlpha ~= 0 p.wrdAlpha = $1 - 1 end
			p.wrdTime = $1 - 1
		end
		if (leveltime & 1) == 1 and p.wrdLine < 32 p.wrdLine = $1 + 1 end
	end
end)


addHook("MapLoad", do
	for p in players.iterate
		p.wrd = nil
	end
end)


local function wrd_bottom(v, text, alpha, n)
	local x, y = 160, 160

	for line in text:gmatch("[^\n]+")
		y = $1 - 12
	end
	for line in text:gmatch("[^\n]+")
		if n == 0 return end
		n = $1 - 1
		v.drawString(x, y, line, V_ALLOWLOWERCASE | (alpha << V_ALPHASHIFT), "center")
		y = $1 + 12
	end
end

local function wrd_center(v, text, alpha, n)
	local x, y = 160, 100

	for line in text:gmatch("[^\n]+")
		y = $1 - 6
	end
	for line in text:gmatch("[^\n]+")
		if n == 0 return end
		n = $1 - 1
		v.drawString(x, y, line, V_ALLOWLOWERCASE | (alpha << V_ALPHASHIFT), "center")
		y = $1 + 12
	end
end

hud.add(function(v, p)
	if not p.wrd return end

	if p.wrdStyle != 100
		wrd_bottom(v, p.wrd, p.wrdAlpha, p.wrdLine)
	else
		wrd_center(v, p.wrd, p.wrdAlpha, p.wrdLine)
	end
end, "game")