creatures caves welcome, guest
downloads   gallery   dev   community   creatchi   forum   mycaves
bookmarks | search | post new topic
Development Forum
old
Beast Death and Animation Speed   
the1whoscreams

the1whoscreams
United States  


  11/3/2016

I'm trying to make a death script for a beast I'm working on. When its energy reaches zero, it's supposed to go through an animation, then kill the agent. The CAOS editor doesn't seem to want to interpret it as anything other than a giant pile of syntax errors. How would I go about actually getting the thing to die properly? Also, how do I edit the speed of an animation?
 
GimmeCat

GimmeCat



  11/3/2016

We won't know what the errors are complaining about until we see the code.
 
Ghosthande
Prodigal Sock

Ghosthande


 visit Ghosthande's website: Breeders Beware
  11/3/2016

It helps to see the code as well as the errors you're getting, but to answer your last question, you can change animation speed using FRAT. (FRAT 1 = regular speed, FRAT 2 = half speed, etc.) This controls the speed of all an agent's animations, though, not just one.

If you haven't already, I'd strongly recommend going to Window -> Error Output to bring up the "error output window", which will tell you in more detail what syntax errors it's found.



 
Malkin

Malkin

Manager


 visit Malkin's website: Malkin's page at CWiki
  11/3/2016

Quite often I've found that when I get a whole pile of CAOS errors for what seems like no good reason, I've simply forgotten to close one thing that needs closing (SCRP and ENDM, DOIF and ENDI, ENUM and NEXT, REPS and REPE, etc.). Once I find that one thing and close it and hit the 'reformat' button, the errors go away. :)

My TCR Norns
 
Papriko
Peppery One

Papriko



  11/3/2016

The code and/or error message would be very helpful indeed. Also, when you get a pile of errors in a rapid succession, a good starting point is scrolling all the way up to the first line that causes problems. The subsequent error messages are most likely just a result of the first thing confusing the machine.

Lets play plants! Photosynthesis... Photosynthesis... Photosynthesis...
 
the1whoscreams

the1whoscreams



  11/3/2016

I managed to get the death script to not make the editor bug out, but now the check is making the thing flip out.
scrp 2 16 14893 9
doif ov00 le 0
subr die
else
subr walk
endi
endm

That script is supposed to make the Icerunner die if its energy is less than or equal to 0. If it's greater than 0, it walks. But from that script onward, every else, endi, endm, scrp, and scrx gets highlighted in red and listed as a syntax error. The error output keeps saying "retn" was expected and thinks the other scripts are nested inside other things, when the only thing before the buggy script is the install script, and I know that's closed properly.

 
Papriko
Peppery One

Papriko



  11/3/2016

Subroutines have to go before the endm. It is a kinda weird and somewhat inconvenient system and it forces you to redefine subroutines multiple times if you need them in more than one script, but that's how it is. Believe me, I got a plenty of error messages tossed my way before figuring that one out.

Lets play plants! Photosynthesis... Photosynthesis... Photosynthesis...
 
Malkin

Malkin

Manager


 visit Malkin's website: Malkin's page at CWiki
  11/3/2016

Subroutines are a discrete piece of code, often used repeatedly in a single script. You need to first say 'go to this subroutine' by using GSUB then go back to the main story of the critter - then write in the segments using SUBR and RETN after you have finished that part later, like this:

scrp 2 16 14893 9
doif ov00 le 0
gsub die
else
gsub walk
subv ov00 1
endi

subr die
lock
kill ownr
retn

subr walk
*walking code goes here
retn

endm



You might like to check out Creating a Metaroom Part 5: Agents for more details.

I've put in a subtraction for OV00 because it looks like that's your object variable controlling the lifespan of your critter.


My TCR Norns
 
the1whoscreams

the1whoscreams



  11/3/2016

I moved the subroutines to the part right after the install script, and then literally all of both of them got highlighted in red. The errors said "Token is not inside a script, got '[insert first word of the line here]'."
 
RisenAngel
Sanely Insane

RisenAngel

Manager


 visit RisenAngel's website: The Realm
  11/3/2016

It's as the error says: the subroutines have to be inside a script (that is, between the two lines that say "scrp X X X X" and "endm";).

In this case, you'd want them within the timer script (scrp X X X 9), as that script is presumably what you're using to make the beast "live." If you put them in another script, the timer script won't be able to access them.


~ The Realm ~
Risen Angel's Creatures Blog


 
the1whoscreams

the1whoscreams



  11/3/2016

* The Icerunner dies.
subr die
doif ov00 le 0
anim [8 9 10 11 12 13 14]
kill ownr
retn
endi
endm

Now, this one is flipping out on me. Retn and endm are the ones in red. The error box has this to say.
Line 64: 'elif', 'else' or 'endi' expected, got 'retn'
Line 66: 'retn' expected, got 'endm'
When I swap endi and retn, it stops flipping out about them, but it still doesn't like the endm.

 
RisenAngel
Sanely Insane

RisenAngel

Manager


 visit RisenAngel's website: The Realm
  11/3/2016

"endi" basically means "end this doif block." As far as the posted code there is concerned, it's finding a random "end subroutine" command when what it wants is an "endi."

Once you've done that, you're out of the "doif" block, but still in the "subr" block. To end the "subr" block, you put a "retn."

In other words, switching the "endi" and the "retn" was the right thing to do.

As for the "endm," the only place you should be using "endm" is at the end of a script (the parts of the code that begin with scrp X X X X). If it's giving you an error, either you're trying to end a script block early, or you never started the script block.

What does your entire code look like at this point? That'd probably help explain some things.

Furthermore, have you looked at a CAOs Tutorial? If not, I don't blame you; a lot of the good ones are hard to find and often have a lot of busted images/links nowadays. However, it'd probably help explain this whole code block thing better than I could. While I don't know of any that cover subroutines off the top of my head, CAOs Chaos at least covers doif statements.

Also, you may wish to put "over" after your "anim." That will tell the code to play the entire animation before going forwards with the code. If you leave that out the beast will start animating but then vanish without finishing the animation.


~ The Realm ~
Risen Angel's Creatures Blog


 
the1whoscreams

the1whoscreams



  11/3/2016

I just figured out my big problem! I forgot to put in a retn after the first subroutine. It's mostly fine now, but when it dies, this happens.

Runtime error in agent 2 16 14893 script 2 16 14893 9 unique id 3482749
Anim change failed - on part 0 which has base 0
... die doif ov00 le 0 {@}anim [8 9 10 11 12 13 14] over ...

 
RisenAngel
Sanely Insane

RisenAngel

Manager


 visit RisenAngel's website: The Realm
  11/3/2016

Usually, that error's a result of miscounting the number of frames a sprite file has (or how many frames the agent in question is actually using out of the images in a sprite file). The agent's trying to access a frame that isn't there or it just can't access.

Without seeing the sprite file exactly I can't tell you exactly what to do to fix it, but keep in mind that counting for images starts at 0, not at 1 (e.g. the last image in a sprite file with 10 images is 9).


~ The Realm ~
Risen Angel's Creatures Blog


 
the1whoscreams

the1whoscreams



  11/4/2016

I got it fixed. The sprite count thingy in the install script was messed up. I got that fixed, but now the Icerunner is walking backwards, and very slowly at that. I can fix the backwards thing, but it's moving at a snail's pace. I stole the walk script from the Snotrock COS and tweaked it.
 
GimmeCat

GimmeCat



  11/4/2016

How many pixels per tick is the walk subroutine moving the agent? It may need to be increased.
 


downloads
cobs
adoptions
creaturelink
metarooms
breeds
 
gallery
art
wallpaper
screenshots
graphics
promos
sprites
dev
hack shack
script reservations
dev resources
active projects
dev forum
 
community
links
advice
chat
polls
resources
creatchi
 
forum
bookmarks
general
news
help
development
strangeo
survivor
mycaves
log in
register
lost pw
1 online
stinger9
creatures caves is your #1 resource for the creatures artificial life game series: creatures, creatures 2, creatures 3, docking station, and the upcoming creatures family.

contact    help    privacy policy    terms & conditions    rules    donate    wiki