My understanding was that a script that is started (from an object's local script) without a target specified would be run as a global script, and not a targeted script on the object
if no caller is specified with the caller->globaScript syntax, the calling object is passed by default to the global script. This is powerful but risky if you execute commands in the global script when the caller has been deleted
e.g.
try attaching this local script to Fargoth
Code: Select all
begin fargothScript
short state
short doOnce
;if ( doOnce )
;return
;endif
if ( CellChanged )
startscript fargothGTScript
endif
if ( doOnce )
return
endif
short health
short level
short hello
if ( GetLevel > 10 )
set health to GetHealth
set level to GetLevel
set hello to GetHello
set doonce to 1
Messagebox "Fargoth's changed health=%g, level=%g, Hello=%g" health level hello
endif
end
starting the global targeted script
Code: Select all
begin fargothGTScript
short health
short level
short hello
set health to GetHealth
set level to GetLevel
set hello to GetHello
Messagebox "Fargoth's original health=%g, level=%g, Hello=%g" health level hello
SetHealth 500
SetLevel 100
SetHello 25
stopscript fargothGTScript
end
and test from a fresh new game
[EDIT]to clarify, attaching the script to the player is a workaround, good only for global scripts meant to stop very soon, because player is always available but is recreated on reload, so global script becomes detached on reload
[EDIT]commented out unnecessary repeated lines in fargothScript