State changes discrepancy in lsl-luau vs mono
tracked
TrishAce Resident
Something about the way lsl-luau handles state changes differs from Mono.
It appears like the state is changed immediately instead of after the whole event is handled.
Take this test script:
integer screwthisimout()
{
if (TRUE) state other;
return 13;
}
default
{
state_entry()
{
integer r = screwthisimout();
llOwnerSay("after state change, r=" + (string)r);
}
}
state other
{
state_entry()
{
llOwnerSay("entered state other");
}
}
In mono, you see both llOwnerSay printed, State_Entry fully finished, the output is:
after state change, r=0
entered state other
in lsl-luau, state_entry doesn't get to finish and only outputs:
entered state other
Tested on the latest 2026-07-24 luau channel
Log In
M
Mercury Linden
updated the status to
tracked
SuzannaLinn Resident
Another variation:
integer screwthisimout()
{
if (TRUE) state other;
return 13;
}
default
{
state_entry()
{
integer r = screwthisimout();
llOwnerSay("after state change, r=" + (string)r);
state another;
}
}
state other
{
state_entry()
{
llOwnerSay("entered state other");
}
}
state another
{
state_entry()
{
llOwnerSay("entered state another");
}
}
In Mono:
after state change, r=0
entered state another
In LSL-Luau
entered state other
It seems that it's a "bugfeature". I would rather remove the bugfeature than make LSL-Luau do this.
User-defined (global) functions cannot change a script's state. The compiler will throw the error 'ERROR: Global functions can't change state'. However, a workaround can be used by putting the state change in the body of a simple 'if' statement; one which is without an 'else' clause (Ex: if (condition) state Two; rather than if (condition) state Two; else state default;). Rand Linden has previously stated that this workaround is no longer valid, so care should be taken in using it, and preparations made for the sudden removal of this bugfeature.
TrishAce Resident
SuzannaLinn Resident
the problem with removing a bugfeature like this is that if LL still plans to phase out mono and move scripts over to lsl-luau, this particular bug will possibly have some non-negligeable side effects in some scripts. (Whether or not it was warned about before, it will inevitably break stuff)