New food cobs usually contain both installation and regular scripts, the following scripts are from my own Muddy Swamp Carrot cob.
The installation script | Description and translation | |
inst | run the script
instantly |
|
enum 2 6 20 | an enum
command targets any
object with the family genus and species given. In this case the family
is 2 (simple
objects), the genus is 6
(food objects) and
the species if 20 (specific
to Muddy Swamp Carrots) |
|
kill targ | this command kills
the target
object (removes it from the game) |
|
next | next tells
us that the commands above (only one in this case) will be repeated
until all objects with the enum "2 6 20" are dealt with, it
forms a kind of loop |
|
reps 20 | reps 20 tells
us that the next few commands will be repeated 20 times |
|
new: simp mudi 7 0 500 0 | a new:
simple object using
sprites from the file mudi 7 images will be used, starting from number 0 the plane of the object will be 500 clone 0 |
|
setv clas 33952768 | sets the variable class to 33952768, the class used by Muddy Swamp Carrots. | |
setv attr 80 | sets
the variable
attributes
to 80 |
|
bhvr 0 1 | behavior
is set to 0 1,
meaning that the user cannot activate it (in this case eat it), but
creatures can. |
|
rndv var0 5394 5870 | rndv creates
a random variable var0 is the variable where the resultant random number will be placed 5394 and 5870 mark the range in which random numbers will be chosen |
|
rndv var1 897 903 | rndv creates
a random variable var1 is the variable where the resultant random number will be placed 897 and 903 mark the range in which random numbers will be chosen |
|
mvto var0 var1 | mvto moves
the created object to the X coordinate of var0
and Y coordinate of var1 (this will move the
objects to the ground of the jungle) |
|
tick 300 | tick 300 sets
the timer of the object going at 300 ticks, that is 30 seconds. This
will trigger script 9 every thirty seconds, which makes the carrot grow. |
|
repe | repe marks
the end of the commands to be repeated, and so forms a loop |
|
endm | end the module |
The installation script first removes any muddy carrots already in the world (useful to make sure you only install one batch). It then installs twenty carrots in random positions in the jungle area.