Author Topic: Script Order of Execution  (Read 316 times)

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Script Order of Execution
« on: November 10, 2012, 05:23:54 pm »


               This is a problem that has plagued me recently so I looked into it today.

When a creature enters an area and lands on a trigger the order of exection is:
  • Trigger Enter.
  • Area Enter.
When a creature exits an area and a trigger at the same moment the order of execution is:
  • Trigger Exit.
  • Area Exit.
Someday I may look at areas of effect too.

Also as far as I can tell, placeables do not cause area or trigger enter events. I was hoping that a trigger would "know" when a placeable is inside it, but alas... I don't think so. I'll confirm this in the future because I need to know if a player pushes a barrel on top of a trap door to keep the ghouls in the basement from climbing up.

EDIT - I was wondering if anyone else knows more about this. I had assumed the order was more intuitive, and am surprised that Objects which contain others appear to receive an enter event last.
               
               

               


                     Modifié par henesua, 10 novembre 2012 - 05:26 .
                     
                  


            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Script Order of Execution
« Reply #1 on: November 10, 2012, 06:22:16 pm »


               GetFirstInPersistentObject  and GetNextInPersistentObject will do what you need with regards
to the trigger and barrel.

As to the order, areas and triggers are really different things though. I'm not too surprised they
are treated a little differently. You first result is a little counter intuitive. But to really say something
about objects containing others I think you may want to test multiple triggers in the same exact place and see what order you get.

Cheers,
Meaglyn
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Script Order of Execution
« Reply #2 on: November 11, 2012, 03:24:30 am »


               Thanks for the tip on GetFirstInPersistentObject.. I'll check that out. I've been wanting to do a puzzle with placeables or even a rug sitting on top of a trapdoor that would prevent someone from coming up from below, and this does the trick.

I am using a text parser which allows PCs to move placeables around so this could get interesting. Anyway enough babble. Thanks!