Globs of Honey: The CAOS of Honeypot Refills

A CAOS Lesson with HoneyThe aesthetics of the updated honey jar play a role, but the real reason for this project is to make improvements on the coding side. Luckily the Creatures 1 honey does not include many of the issues that the other base food items contained. I’ve learned a great deal about CAOS and how it works with food items, yet honey is unique in one very big way: It’s refillable! Empty honey jars usually litter Albia, and they require someone to carry them off to the beehives. This is usually our job as players, although Creatures can get lucky near the beehives! Let’s see how this works with the honey’s drop script and the C1 CAOS Guide.

Annotating the Honey’s Drop Script (2 6 2 5)

This corresponds with the class number for the honey (2 6 2), and is for the drop script (script number 5).

CAOS Code Explanation
scrp 2 6 2 5 Some programs begin with this line, while others name the file by it. This simply creates a new script for 2 6 2 (honey) for script number 5 (drop). It defines what happens when a honey jar is dropped.
snde drop Listen, listen! This states that the drop.wav will play, which is the standard sound for a dropped object. These jars weigh something!
setv var0 0 Recall that the setv command defines the value of a variable. In this case, var0 (variable 0) is set to 0. It may not make sense on its own, but read on!
enum 2 8 1 This is the beginning of a set of linked codes. enum must be paired with next. What does it do? It looks for a specific type of object. In this case, 2 8 1 corresponds with the beehive. When the game locates one, it will set the targ command to point to it. For the sake of this example, we’ll say that the game located a beehive at this point. What next?
doif touc targ ownr gt 0 Well, that looks like a mess of garbled words! Let’s take it one step at a time. The doif (“do if”) command means that any following script lines will be carried out only if the conditions are met. We’re in luck with the rest of the code! touc targ ownr gt 0 is just a very, very long way of checking to see if two objects are touching. So this would mean that a honey jar and the currently selected beehive are in contact with one another.
setv var0 1 Another case of setting a variable equal to something. In this case, var0 will have a value of 1 only if the honeypot and beehive are touching. If not, this command is ignored and var0 will remain the same.
endi Remember what this command does? It’s very important, for it marks the end of a doif statement. Even a single line of code, like the one above, needs the endi statement so the game knows where to end the conditional statement.
next Recall from above that the enum command must end with the next command, so it follows a similar logic as the line above. However, this does have an important difference: The game will continue searching for all objects that meet the criteria and will follow through the commands above. This ensures that any beehive can refill a honeypot. Without it, the game would only find the first instance of the object, which wouldn’t exactly make sense! Only one beehive has honey in it? Impossible! Never forget that next ends an enum statement.
doif var0 eq 1 The doif statement returns. This time, the script is checking to see if var0 (variable 0) is equal to (eq) 1. Going off of the previous codes, this condition is met only if a honeypot is touching a beehive.
andv attr 239 Even I run into walls, and this is one CAOS-ridden wall! The andv command seems to indicate that both of the following values are used in an “and” statement. So attr indicates an object’s attributes, which define what it can do, such as being invisible to Creatures. attr comes from adding together defined values for different behaviors. 239 corresponds with everything except being invisible. In other words… I have no idea what this means!
setv obv0 0 Similar to above, this setv command sets the value of a variable. obv0 (object variable 0) will be set to a value of 0. Not shown here are the other scripts for the honey jar, which use obv0 to define the pose to be used. The honeypot remains full so long as obv0 is less than ten, and this goes up by one each time the honey is eaten. Once it hits that number, off it topples and goes empty! This basically resets the counter and fully refills the honey jar.
endi End that doif statement with endi!
doif obv0 lt 10 This is another doif statement, but be mindful of where it resides. It resides on its own, similar to the above statement. This is always an important consideration since doif statements can be nested for more advanced functionality. In this instance, it is checking to see if obv0 (object variable 0) is less than (lt) 10. In simple terms? It’s checking to see if the honeypot is not empty: It doesn’t need to be full, but it needs to have at least one meal.
pose 0 In non-technical terms, this line means that a non-empty honey jar will stand in the upright position when it is dropped. It sets the pose to 0, which corresponds to this image in the sprite file. Not too complicated, thank goodness!
else An else statement can be seen as a catchall when a corresponding doif statement is not true. Notice that the previous doif statement is still active, since it hasn’t reached its end yet. In this instance, the following instructions will be followed if the honey jar has an obv0 value of 10 or more. Note that this is just in this case: else can mean something different depending on the script and other doif statements. In other words, a catchall statement.
pose 2 Think you can hazard a guess as to what this means? It sets the honeypot’s pose to a value of 2. If it doesn’t have any honey remaining, what does it look like? An empty honey jar laying on its side!
endi And so ends the doif and else statements with this endi command. Very simple, but very important! Never forget this little command.
endm We made it! An endm statement marks the end of the script. The end!

Why the C1 Beehives Work with the HoneyAll that just to define how the honeypots are refilled? Indeed! CAOS can seem extremely complicated and long, but hopefully these practice lessons are helpful. By taking each line of a script one at a time, understanding the technical side isn’t too terrible! I’m still learning, and likely will be forever. That’s one of my favorite features of Creatures… There are so many things to learn about and study! In even simpler terms, this drop script simply says that if an empty honeypot is touching a beehive, it will be refilled. Often the best way to learn CAOS is to take a look at the existing scripts for the included objects. At least we know they work decently well enough! The updates to this script and the honey are coming soon. Stay tuned!

2 Comments
« Previous Post | Next Post »