[Lua] MapChange does not fire for titlemap

amperbee

thunderdome denizen
MapChange does not fire whenever the titlemap is to be loaded when the client is returned to the main menu. Is this intended?

Example script:
Code:
addHook("MapLoad", function()
	print("MapLoad "..leveltime.." "..gamemap)
end)
addHook("MapChange", function()
	print("MapChange "..leveltime.." "..gamemap)
end)

Results from log file:
notepad_2020-10-24_20-13-15.png
 
I'd say it's intentional. MapChange basically fires whenever a map command is received. There are only a few exceptions where the game will not issue a map command to load a level. Playing back a demo, respawning in Single Player, and the titlemap. In the former two a normal gamestate will follow (MapChange also fires), but the titlemap is a special case because it has a titlescreen state and not a level state. So I think it makes sense for MapChange not to fire for it.
 
Last edited:
Getting into suggestion territory, maybe this is worth some kind of MapExit hook that fires any time a map is left, regardless of the destination? I know I've used MapChange frequently to clean up variables that shouldn't carry over from map to map, and now knowing that that hook doesn't trigger in certain situations (particularly playing demos) kind of undermines that.
 
Sorry I worded that poorly. The titlemap is the only instance MapChange doesn't fire.
 

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top