Woes of CAOS Coding in Creatures 1
Written onThe good news about the C1 carrot update is that the project is nearing completion! The more important elements of the scripts have been lightly tested, and will be put through more robust testing. First, though, I seem to have run across a couple of puzzling errors. I figured I would put these up for discussion, since there are many talented CAOS users in the Creatures community! A lot of this has been a learning experience for me, so I’m sure that I simply may be trying to do certain things that Creatures 1 can’t handle. This screenshot actually shows one of the updates, although it might not be too obvious. I’ll leave that a not-so-exciting surprise for the time being! Make sure to brush up on your CAOS skills, and perhaps you’ll even have a possible solution!
CAOS Problem #1
Ah, a lovely macro script error! What I’m trying to do is to make each carrot point either left or right each time it is dropped. I added in a new image in the sprite file, edited the other scripts to update the total number of images in the sprite file, and wrote a bit of CAOS. I have tried practically everything in the book that I can think of to make this pose load correctly… To no avail.
Here is the annotated script. Don’t worry if it looks completely foreign to you! I will be going into this in more depth as we explore CAOS more in the future. This version is mostly to figure out what I’m doing wrong!
CAOS Code | Explanation |
---|---|
scrp 2 6 3 5 | This is the script for what to do when a carrot is dropped. |
snde drop | When a carrot is dropped, it plays the drop.wav sound file. |
rndv var0 6 7 | A random value between 6 and 7 (inclusive) is chosen and assigned to var0, a variable. I’ve tried all different iterations here, with other variables and object variables. The goal here is to choose either pose 6 or 7 in the sprite file, which corresponds to a dropped carrot pointing left or right. |
setv pose var0 | I believe this is the root of all my issues! This line is supposed to set the pose of the current carrot to whatever random variable was chosen above (6 or 7). It never works. I’ve tried this with and without the setv command, and with the other variables mentioned above. Perhaps this is beyond the scope of Creatures 1, though. Can the pose command only take a set number, and not a variable? |
endi | This marks the end of a doif statement… Although there isn’t one in this script. Possibly the cause of my problem, now that I see it? |
endm | The end of the script. |
CAOS Problem #2
This may or may not be related to CAOS, but the carrots refuse to show up correctly in my world when I edit the sprite file. It is pars.spr, correct? I get distorted images every way I try it. Yet if I create a new sprite file with a different name, I have no issues. The bitmaps are all the same… Baffling! The screenshot at the top shows the carrots and how they appear correctly. Every pose works, aside from the two dropped poses, since I haven’t been able to get that CAOS working just yet. Is it possible to edit existing sprite files? I had no problems with all of my updated egg sprites. Perhaps I simply have to try this out a few more times, as it could be something obvious I’m just missing! Feel free to share any thoughts!
Help is greatly appreciated, and anyone who might be able to offer up a solution or two will receive a mention in the credits section when this carrot update is complete! There might even be some beta testing opportunities coming up…
Hi Jessica, I might have a few hints regarding this script:
– Your usage of rndv to assign var0 is perfectly correct.
– The pose command however is not used that way. “pose” is a command by itself and not a variable, it should therefore be run alone, with a parameter, rather than assigned a value.
– “setv” is only used to fill variables (as in “SET Value”).
– Just use “pose var0” for the expected effects.
– The “endi” part should not be there if there are no corresponding “doif” blocs. It doesn’t seem to produce visible side effects to leave it in there, but I wouldn’t risk it.
– Also, it’s ok to use variables instead of immediate values in most places expecting a number. That’s what they are for. It’s only when you will try to use them to replace string values (such as in the “say$ [hello]” command) that you might be in trouble.
This should correct most of your problems.
One issue that might also arise, is if you try to set pose 7 for a carrot of the classic type that doesn’t have the pose.
I don’t know how the game supports having one of its original sprite files extended by one pose when objects of that kind already exist in the world.
This might also be the cause of your rendering issues.
I’d delete all ingame carrots (by using “enum 2 6 3,kill targ,next”) before injecting a modified one to perform the tests, just to be sure no old carrot is ever put into pose 7.
Otherwise you might get a random crash at each carrot drop depending on the random pose adopted.
Hope this helps!
Thanks for all of that information, LoneShee! That explains some of the concepts with variables that I was a little murky on. Oddly enough, using “pose var0” still produces a script error, although I’m going to go back and re-check my coding. I made a few silly typos early on, so I’m wondering if there might be something like that in there!
The update includes an install script that first removes all existing carrots, so at least you’ve confirmed that I’m doing that correctly! I’ll have to check out the sprite issue in more detail. Although I don’t think it’s the end of the world if players need to add a new sprite file, I would love to use the existing one if possible.
All of that definitely helps: Thank you again! I’ll look into what the pose line is doing… Most likely it’s just me being absentminded and doing something obviously wrong. I’m somewhat on the right track, though, and all of this will definitely help keep me there!
I realize I left out one important bit of information:
After deleting all carrots with “enum 2 6 3,kill targ,next”, they are reinstalled with:
“inst,new: simp pars 7 0 3500 0,setv clas 33948416,setv attr 64,bhvr 0 1,rndv var0 3400 3800,mcrt var0 902,tick 1”
Installing them in any pose but the “0” one seems to cause some trouble due to the various growth scripts interaction. I haven’t had time to explore spawning of full grown carrots that would still incorporate in the growth cycle (contrary to the island dispenser carrots that disappear once eaten).
That should spare you some head scratching :)
Once again, thank you! My install script looks very similar to what you’ve written, which again confirms that I’m doing something right. I’m actually pretty happy that I can look at that code and understand all of it. Yay! I appreciate the added information about the growth scripts and pose 0: I hadn’t known about that, but it all makes sense. Definitely something important for me to keep in mind. Thank you again: You’ve been wonderfully helpful!
You’re welcome.
The carrots are definitely not the simplest item you could have chosen as an introduction to CAOS due to the number of scripts involved their interaction and their unforeseen side effects.
But you seem to be doing pretty good!
CAOS scripting is very picky about its syntax. Especially in C1 where the slightest error usually results in an immediate game crash. C2 seems to handle bogus scripts slightly better on that aspect, but it remains a very strict syntax.
The most common and vicious source of errors I encounter is usually spaces.
One too much between two commands, or even an empty space at the end of the script is enough to ruin everything! And it’s pretty hard to spot in the first place.
From time to time, there are also some weird behaviors, and sometimes stuff that logically should work just doesn’t. Just adding a single valid command in a script might be enough to pass from working to crashing even though the modification is legit in itself. Debugging those is the real pain.
Good luck with the learning!
IT WORKS! I have no idea exactly what I changed that I didn’t try before, but I am so excited right now! I thought I tried every combination before, yet it seems like I must have left out the one working combination. Thank you again for all of the explanations! I learned a lot along the way, and I’m sure a lot of this will come in handy as I continue to learn CAOS.
I’m going to work on some extensive testing with these carrots to make sure they’re working correctly in every way. I’m sure I’ll open up a beta testing phase, though, as this is my first foray into CAOS and I’d rather get some feedback from others before saying that they’re working absolutely as expected. But this is definitely good news: For the hundredth time (though I mean it each time) thank you for all of your help!
I seem to recall that the island carrot dispenser doesn’t actually make a carrot at all – the act of pushing the vendor makes an animation show, but the food chemicals are given by the action of pushing the dispenser itself. Can anyone please confirm or debunk this?
You are totally right!
I hadn’t seen the vendor used in a long time and didn’t recall this detail.
But that explains why I wasn’t able to find anything resembling a carrot creation script in there.
The island carrot vendor has the 2 8 3 classifier.
Its action1 script is :
anim [0123456789],
snde vend,
over,
stim writ from 10 255 0 0 35 100 34 10 57 100 0 0,
snde chwp,
pose 0,
setv actv 0,
endm
As you said, it just plays an animation, an eating sound, and directly injects the Norn with the corresponding chemicals.
We can also notice that it injects a significantly lower dose of NFP decrease than the regular carrots.
(10 instead of 70).
Maybe that makes it a candidate for being turned into a regular vending machine for a future project?
Thanks for pointing that out.
Inspired by this, I’ve recently released an update to the distillery that makes it act more like the island’s carrot vendor.
My little ones seem to have gotten the hang of pushing it to have a little feed, with some teaching.
That’s awesome, Malkin! I’ll definitely have a look. There are lots of opportunities to make improvements in Creatures 1 after all these years, and it’s great to see you taking this on. Plus it’s sometimes nice to have these projects where you’re not creating something from scratch… I know I wouldn’t have started on CAOS if it wasn’t for these updates. Thanks for sharing: I’m sure that’s going to be very handy for players!