Page 1 of 1

Mention that script.raise_event raises it instantly

Posted: Thu Dec 05, 2024 7:29 pm
by PennyJim
I personally think it's fairly obvious that it would raise it instantly, but it doesn't hurt to be explicit about it.

So my little snippet of code doing this works fine

Code: Select all

local flag = false

function some_func()
	flag = true
	script.raise_event("my-event", {})
	flag = false
end

function other_func()
	if not flag then error("This can only be called during my-event") end
	-- stuff
end

Re: Mention that script.raise_event raises it instantly

Posted: Thu Dec 05, 2024 11:54 pm
by PennyJim
And while we're talking about it. It doesn't mention that there's a prototype for CustomEvent that adds another avenue making a valid event to throw.