Jump to content

Detecting when player enters a location? (And other questions.)


Asterra

Recommended Posts

Wouldn't, I don't know the technical term, staging a variable be more efficient than a timer? Sorry I don't know how to properly post scripts from my phone, but for example:

 

Short myVariable

 

Begin onActivate player

 

Set MyVariable to 1

 

End

 

Begin GameMode

 

If MyVariable == 1

 

If player.getitemcount thingA > 0

ContainerRef.additem thingB 1

Set myVariable to 2

 

Elseif player.getitemcount thingC > 0

ContainerRef.additem thingD 1

Set MyVariable to 2

 

Else

 

ContainerRef.additem thingE 1

Set MyVariable to 2

 

Endif

 

Elseif myVariable == 2

 

ContainerRef.Activate player ;though I assume it could be just "activate" since the script is presumably on the container anyway.

Set MyVariable to 0

 

End if

 

End

Edited by uhmattbravo
Link to comment
Share on other sites

Thanks for the explanation guys. And I know that is just an example script.

But couldn't you just skip the game mode block having all that execute within an OnActivate block ?

 

I guess the reversal of that would be more what the OP might find useful ?

 

A game mode block running to detect triggering events so to speak. That then sets variables.

Which an OnActivate block would then place items in the container based on the variables.

Link to comment
Share on other sites

Sometimes if too many actions are triggered at once in one if, especially if they're all on one ref, things can either happen in the wrong order, or otherwise not work as intended.

 

Separating them either with a timer or stages helps make sure it all happens in the order you want it to. In this case, it'll make sure the item gets added before the PC actually opens the container.

 

The gamemode block just allows the timer or stages to be checked more than once (which they need to be) whereas the onActivate block only runs once per activation. That'd advance the timer or stage, but you'd need to click it a second time to actually open the container.

 

 

I have noticed though that in my example, it'll keep adding the items every time you activate the container. I should have had that last command set myvariable to 3 instead of 0.

Edited by uhmattbravo
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...