Nearly all commands currently throw Script Errors when using serials/vars it can't find, due to it being...
Offscreen
Hidden / Invisible
Unset / Doesn't Exist
Script Errors cause everything to abruptly stop, which is not an intended outcome.
Players expect particular tasks may fail & return false, but their script continues running.
Instead, all commands involving serials/vars should...
Display "Not Found" warning (can be @ suppressed/quiet mode)
Continue running the script
Return a value of -1 in expressions:
-- Allows if ...expression... to still evaluate -1 to false
-- Allows if ...expression... = -1 to differentiate between false outcomes:
-- Returns 0 ... serial was available to test, and determined to be false
-- Returns -1 ... serial was NOT available to test (offscreen/unseen/unset), therefore nothing could be determined so it is false
Couple Examples Below (not an exhaustive list, too many to list...)
if dead 'myPET'
// is dead ?
// is offscreen / not exist ?
// impossible to know which...
endif
if dead 'myPET' = -1
// is offscreen / not exist
elseif dead 'myPET'
// is onscreen and dead
else
// is alive
endif
if findlayer 'myPET' backpack
// has backpack (is a pack llama/horse/mule)
else
// has no backpack ?
// is offscreen / not exist ?
// impossible to know which...
endif
if findlayer 'myPET' backpack as 'myPETBag'
// has backpack (is a pack llama/horse/mule)
elseif findlayer 'myPET' backpack = -1
// is offscreen / not exist
else
// is onscreen, but has no backpack
endif
Nearly all commands currently throw Script Errors when using serials/vars it can't find, due to it being...
Script Errors cause everything to abruptly stop, which is not an intended outcome. Players expect particular tasks may fail & return false, but their script continues running.
Instead, all commands involving serials/vars should...
@
suppressed/quiet mode)-1
in expressions: -- Allowsif ...expression...
to still evaluate-1
tofalse
-- Allowsif ...expression... = -1
to differentiate between false outcomes: --Returns 0
... serial was available to test, and determined to befalse
--Returns -1
... serial was NOT available to test (offscreen/unseen/unset), therefore nothing could be determined so it isfalse
Couple Examples Below (not an exhaustive list, too many to list...)