CAOS Questions: Doif Statement Conditions
The wonderful thing about CAOS is that it is pretty well documented in the Official Creatures CAOS Guide. The trouble? It’s only “pretty well” documented! I finished up the last fix in my updates for the Creatures 1 carrot… And then decided to try and throw in one more tiny surprise! I thought I had it all figured out, only it didn’t work out too well. Since I received such wonderful feedback when I posted a few CAOS problems, I decided to reach out to the Creatures community again! Any help untangling this issue would be most appreciated, as always. I’m still learning lots of new things!
CAOS Doif Statement Conditions
This is a complete list of conditions that doif statements will accept. What I’m trying to figure out is what each one means and how to implement it when choosing the pose to use from a sprite file. This table contains my own interpretations, and will be updated. I will also post a more definitive guide in a new post to clearly show the correct definitions! For the examples, assume that the sprite file contains 8 poses labeled 0, 1, 2, 3, 4, 5, 6, and 7.
| Condition | Meaning | Example |
|---|---|---|
| EQ | Equals |
doif pose eq 5 Do if the pose equals 5 True for pose 5 |
| NE | Not Equal to |
doif pose ne 5 Do if the pose does not equal 5 True for poses 0, 1, 2, 3, 4, 6, and 7 |
| GT | Greater Than |
doif pose gt 5 Do if the pose is greater than 5 True for poses 6 and 7 |
| LT | Less Than |
doif pose lt 5 Do if the pose is less than 5 True for poses 0, 1, 2, 3, and 4 |
| GE | Greater Than or Equal to |
doif pose ge 5 Do if the pose is greater than or equal to 5 True for poses 5, 6, and 7 |
| LE | Less Than or Equal to |
doif pose le 5 Do if the pose is less than or equal to 5 True for poses 0, 1, 2, 3, 4, and 5 |
| BT | ??? | Unknown |
| BF | ??? | Unknown |
I though that BT and BF might indicate something along the lines of between, but I’m not sure if there’s a way to define variables in that way. I have doif statements that involve less than and greater than, yet there is one pose I’m trying to use that is used completely differently. Poses 0-4 represent the growth stages, pose 5 represents the full grown carrot, and poses 6-7 represent the dropped carrots (pointing in either direction). What I would love to do is to define a doif statement defining the pose numbers that it must be between. If there is a way to accomplish that task, I would be very interested to learn about it! The CAOS code “doif pose bt 6 7” seemed like a good attempt to define the minimum and maximum poses, but that created a lovely macro error. Hopefully someone has an idea!




In Creatures 2, BT and BF are:
BT — Bit-wise AND function
BF — Bit-wise NAND function
Source
I hope this helps you get started.
Thanks for that information, Malkin! Would you happen to know of an example of how those would work in CAOS? I haven’t found very detailed information about what they would actually do, or what conditions would make them true. At least I now know what they stand for, though! That’s definitely a step in the right direction!
There might be an example in the C2 Scriptorium (available for download at Slink’s Treasures, courtesy of TreeSprite’s Creatures Grove).
I’ll have to check that out when I have some time. Thanks for the link and information!
Bitwise ands are not really used in conditions. Their typical use is to extract individual or groups of bits from a value.
The only use case I can think of in the creatures context would be checking if a specific property (value) is present in the “attr” value for an object.
Such as in “the attr for this object is 65, is the object carriable? Is the object activatible ?…”
Etc…
You recently covered how to calculate an attr for an object given a list of its properties, a bitwise does the opposite.
I can’t cover that here and now, but I may write a dedicated post about how and why that works, along with real use cases if needed.
It seems like BT and BF might not really have much use in Creatures 1, or at least from what I’m understanding so far. How lovely it would have been if BT really did mean between! Thank you for that additional information, LoneShee: That certainly makes the bitwise functions a little easier to understand!
The good news is that I figured out how to get my doif statements to work with the standard functions! The carrots seem to be functioning exactly as I wanted, along with that special added sprite. Granted, that doesn’t add all that much on, but I like creating some extras. Plus, it’s given me a lot more practice with putting together sprite files and understanding CAOS!