Skip to content

Hide lua invalidity errors under (cv_debug & DBG_LUA)

Latapostrophe requested to merge valid-error-under-debug into next

This makes LUA_ErrInvalid only actually error under devmode 2048.

The reason this was done is because the game already makes all the necessary P_MobjWasRemoved checks and whatnot, and returns nil if anything is missing. This of course doesn't remove .valid from Lua as it's still useful for its purpose and not just adding more checks whenever you want to access a mobj. Some may argue that this error helps scripters know when something they want to access went poof, but as someone who scripts for this game a lot, all this error ever did was frustrate and force me to add more checks everywhere before accessing anything.

For exemple, say I'm trying to set player.mo.z = FRACUNIT, this will error if player or .mo doesn't exist. With this, it will simply not do anything.

Now, let's say I'm trying to check for player.mo.flags & MF_NOGRAVITY, this would also error if player or .mo didn't exist. With this, it will simply return nil, as it also would have with the error. It just won't print.

The error itself can still be seen with devmode 2048 but I'm not even sure if THAT's desirable at all.

Merge request reports