Checkactivatormotion: Difference between revisions
Jump to navigation
Jump to search
New page: '''checkactivatormotion <lotag>''' Checks to see if the activator with the lotag specified is in motion or not - if it is, than RETURN is set to 1. Category:EDuke32 specific commands |
corrected var name |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
'''checkactivatormotion <lotag>''' | '''checkactivatormotion''' <lotag> | ||
Checks to see if the activator with the lotag specified is in motion or not - if it is, than [[RETURN]] is set to 1. | |||
==Detecting MasterSwitch motion== | |||
'''checkactivatormotion''' only detects activator motions, but it won't return 1 if it's a delayed masterswitch that goes off. | |||
Fortunately, there is a way to check for this. When a MasterSwitch starts moving, the sprite is deleted, meaning that we can catch it in EVENT_KILLIT and act appropriately. | |||
One way to handle this: | |||
<pre> | |||
var MASTERSWITCH_SUBSCRIPTION 0 2 | |||
var MASTERSWITCH_RETURN 0 2 | |||
var temp 0 2 | |||
var temp2 0 2 | |||
appendevent EVENT_KILLIT | |||
ifactor MASTERSWITCH | |||
{ | |||
for temp sprofstat 1 | |||
{ | |||
getav[temp].MASTERSWITCH_SUBSCRIPTION temp2 | |||
ife temp2 sprite[].lotag | |||
setav[temp].MASTERSWITCH_RETURN 1 | |||
} | |||
} | |||
endevent | |||
useractor notenemy MASTERSWITCHHANDLER // this actor has to do something if it detects the masterswitch is moving | |||
set MASTERSWITCH_SUBSCRIPTION <lotag to check> | |||
ife MASTERSWITCH_RETURN 1 | |||
{ | |||
// do stuff | |||
set MASTERSWITCH_RETURN 0 // remember to reset this or whatever code will keep triggering | |||
} | |||
enda | |||
</pre> | |||
[[Category:EDuke32 specific commands]] | [[Category:EDuke32 specific commands]] |
Latest revision as of 17:23, 29 December 2022
checkactivatormotion <lotag>
Checks to see if the activator with the lotag specified is in motion or not - if it is, than RETURN is set to 1.
Detecting MasterSwitch motion
checkactivatormotion only detects activator motions, but it won't return 1 if it's a delayed masterswitch that goes off. Fortunately, there is a way to check for this. When a MasterSwitch starts moving, the sprite is deleted, meaning that we can catch it in EVENT_KILLIT and act appropriately.
One way to handle this:
var MASTERSWITCH_SUBSCRIPTION 0 2 var MASTERSWITCH_RETURN 0 2 var temp 0 2 var temp2 0 2 appendevent EVENT_KILLIT ifactor MASTERSWITCH { for temp sprofstat 1 { getav[temp].MASTERSWITCH_SUBSCRIPTION temp2 ife temp2 sprite[].lotag setav[temp].MASTERSWITCH_RETURN 1 } } endevent useractor notenemy MASTERSWITCHHANDLER // this actor has to do something if it detects the masterswitch is moving set MASTERSWITCH_SUBSCRIPTION <lotag to check> ife MASTERSWITCH_RETURN 1 { // do stuff set MASTERSWITCH_RETURN 0 // remember to reset this or whatever code will keep triggering } enda