/* 
Console
version 1.0
by Kaldrum
Console command stuff and map/global hpu toggle
"Globalhpu on/off" in console to turn toggle global halfpipe utilities
"Lua.hpu = active" on level header to enable for a level.
handled in wallrun, but for organization: "Lua.multiwallrun = active" to enable multiple walljumps
*/

if HPU
	print("\x85 Didn't load repeat instance.")
	return
end

rawset(_G, "HPU", {})

CV_RegisterVar{
	name = "GlobalHPU", 
	defaultvalue = 1, 
	flags = CV_NETVAR,
	PossibleValue = CV_OnOff
}

HPU.maphpu = false

HPU.Global = CV_FindVar("GlobalHPU")

addHook("MapChange", function(map)
	if mapheaderinfo[map].hpu == "active"
		HPU.active = true
		HPU.maphpu = true
	else
		HPU.active = false
		HPU.maphpu = false
	end
end)

addHook("ThinkFrame", function()
	if HPU.Global.value and not HPU.active
		print("Global Halfpipe Utilities is enabled.")
		HPU.active = true
	elseif not HPU.Global.value and HPU.active and not HPU.maphpu
		print("Global Halfpipe Utilities is disabled.")
		HPU.active = false
	end
end)