Checkactivatormotion: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
One (talk | contribs)
No edit summary
Sangman (talk | contribs)
corrected var name
 
(3 intermediate revisions by the same user not shown)
Line 2: Line 2:


Checks to see if the activator with the lotag specified is in motion or not - if it is, than [[RETURN]] is set to 1.
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