BHAV:Pick Up / Put Down
Here we show a SimAntics BHAV code snippet that will direct the current Sim to pick up the object clicked on (which is defined note to be placeable on the floor or decorative slots) and then put it down again on the same surface.
This code snippet illustrates several primitives. Use these links to see full details about how to use these primitives in order to recreate the BHAV code below.
We also illustrate the use of global function
- Route - Route to Reach (0x0188)
The BHAV code
Firstly we start by remembering the current object in case we need it later since this code is going to use the Stack Object for other things. We also save away the ID of the object that our current object is sitting on.
0x0000: Expression (Local 0x0000 := Stack Object ID), True Target: 0x0001, False Target: Error 0x0001: Expression (Local 0x0005 := Stack Object's container id), True Target: 0x0002, False Target: Error
Now we direct the Sim to go to the object and pick it up.
0x0002: Route - Route to Reach(), True Target: 0x0003, False Target: False 0x0003: Reach/Put (Pick up: Stack Object ID, Slot: 0x00), True Target: 0x0004, False Target: False
Now we put it down again, using our remembered containing object ID, we run the 'surface' function provided by that containing object (e.g. a counter). If we are unable to do this (perhaps something has been placed on that surface since we picked it up) we will drop it on the floor.
0x0004: Expression (Stack Object ID := Local 0x0005), True Target: 0x0005, False Target: Error 0x0005: Run Functional Tree (flat surface), True Target: 0x0007, False Target: 0x0006 0x0006: Reach/Put (Drop onto: Floor, Slot: 0x00), True Target: 0x0007, False Target: 0x0007 0x0007: Your code