Lua MobjDeath hook vs Intermission Screen

Flame

WR 102
The Lua Hook MobjDeath can trigger on the intermission screen.
And you can get the message:
Code:
This can only be used in a level!

Here's some example code to try for yourself:
Code:
addHook("MobjDeath", function(mo)
	if mo and mo.valid
	and mo.player and mo.player.valid
		print("Something Funny")
	end
end, MT_PLAYER)
For added context, it errors at the "if mo and mo.valid" line.
 
Last edited:
Where did you get this to happen then? I've been testing with a copy of the code included loaded, but I can't get this to occur in any of SRB2's own levels (at least up to CEZ3, anyway).
 
Would like to confirm that this bug still occurs as of 2.2.6 - somehow, MobjDeath hooks can trigger during an intermission screen. I have no idea as to the cause, so I'm sorry to bump this thread.
 
I found the cause - it happens when a player switches to spectator during an intermission.
 
As Krabs mentioned, it happens primarily during a Multiplayer intermission screen. This is me switching to spectator during an intermission screen with the above code loaded. Thanks to Lua stack tracebacks, I can kinda provide more context.
Code:
$exitlevel
The round has ended.
Flame died.
WARNING: ../LUA/\resources\intermission.lua:2: This can only be used in a level!
stack traceback:
    [C]: ?
    ../LUA/\resources\intermission.lua:2: in function <../LUA/\resources\intermission.lua:1>
Flame became a spectator.
Speeding off to level...
 

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

Back
Top