Thursday 11 February 2016

Changing ATTR with DOIF

Altering ATTR with a DOIF command can be a very powerful way of governing that object's abilities when it is in the world.  The trouble is that there are so many different ways they can be combined that it is difficult to see what's going on!   The medlar uses changes in ATTR to make sure that creatures can't pick an unripe fruit, and that ripe fruit fall off the patch and allow new ones to grow. 

All the time, the BHVR is 48 - edible and pickupable, so it is only the ATTR that will change and govern how creatures interact with it - you can't mess with it if you can't see it.  It also has various physics properties at installation, which will be obeyed when the ATTR says they will.

When it is installed, the ATTR for the medlar is 80. It is invisible, and will collide with room boundaries.

80:

Invisible: Creatures don't see you - applies to ESEE and STAR on creatures, as well as internal creature code.
Suffer Collisions: Will collide with room boundaries, according to its PERM.


When the medlar achieves its ripened state by stepping through its poses, the ATTR is changed to 67.  It is visible, carryable, can be picked up by the mouse, and will collide with room boundaries. 

            doif attr eq 80
               attr 67
            endi


67:

Carryable: Can be picked up by things other than creatures, vehicles and the pointer.
Mouseable: Can be picked up by the mouse.
Suffer Collisions: Will collide with room boundaries, according to its PERM.


If it is picked (either by hand or creature), its ATTR changes to include suffering physics - being able to drop.  It will also automatically change to this, and drop, if it has been hanging around, ripe on the tree for a long time.
 
195:

Carryable: Can be picked up by things other than creatures, vehicles and the pointer.
Mouseable: Can be picked up by the mouse.
Suffer Collisions: Will collide with room boundaries, according to its PERM.
Suffer Physics: Agent falls with proper physics, including gravity, air resistance and friction. Otherwise, it simply moves with velocity.
 


   doif attr eq 67
      attr 195
   endi

 

The full coding of the medlar can be seen at Garden Box Central.

2 comments:

  1. Thank you for this information! I had a similar experience with fixing some of the C1 food updates, although C1 CAOS is quite different from that of C3/DS. It's an important thing to carefully plan out how an object will work and how it will affect Creatures. DOIF statements are wonderful pieces of the script that can do a whole lot!

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete