Welcome to the Creatures Wiki! Log in and join the community.
Difference between revisions of "Basic plant script"
Jump to navigation
Jump to search
GreenReaper (talk | contribs) m |
|||
Line 221: | Line 221: | ||
*'kill ownr' kills the ownr of the script - here , it's the seed | *'kill ownr' kills the ownr of the script - here , it's the seed | ||
*'endm' closes each script | *'endm' closes each script | ||
− | |||
− | |||
[[Category:Tutorials]] | [[Category:Tutorials]] |
Revision as of 13:14, 20 February 2005
Introduction
Here is a very simple, base plant script which you can use for virtually any plant. It uses a few basic variables.
- create the plant!
new: simp 2 4 50000 "basicplant" 3 0 rand 200 6000
But what does this mean?
- new: simp - creates a new simple Agent
- 2 is the family
- 4 is the genus; 4 = plant
- 50000 is the unique classifier
- "basicplant" is the name of the image file which is situated in the images folder. So, this agent uses the image 'basicplant.c16'.
- 3 is the number of images in the image file
- 0 is the start image
- rand 200 6000 sets the plane of the agent randomly from 200 to 6000.
Ok, the next few parts set the objects properties.
bhvr 48
attr 199
perm 40
emit 7 1
accg 3
elas 25
fric 90
aero 2
- bhvr is the actions Creatures can perform on the object. A series of numbers signify different actions. IE, 1 means norns can activate the object. Then you add the numbers together, and in this case it equals 48.
- attr is the attributes of the object. It works in the same way bhvr does, but in this case, the numbers signify gravity, whether the hand can activate it, and other things. In this case, it equals 199.
- perm is the permanency of the object. It goes from 0 to 100, 0 meaning that it can go through anything, such as walls etc, and 100 meaning it can't go through anything.In this case, it can go through some types of floor and wall, but mostly can't.
- emit is the smell an object emits. Creatures navigate using smells, so its important that objects emit them. In this case, its emitting plant smell.
- accg is the acceleration of an object as it falls down. Fairly obvious, really.
- elas is the elasticity of an object, as in, how much it bounces. This object bounces a bit, but not much. 0 is no bounce, 100 means it never stops bouncing.
- fric is the friction of an object, strangely enough. 0 means it doesn't move along the ground at all when thrown, 100 means it will continue sliding forever.
- aero is the aerodynamics of an object. (Better explanation needed here)
The next part is setting the variable we will use.
setv ov10 rand 200 1000
In this object, ov10 is the lifespan of the plant. We're setting it randomly from 200 to 100. We'll see how to use this variable later.
Almost done the install script! There is one more little chunk of code here.
mvsf game "CreatorX" game "CreatorY"
velo rand 10 25 rand 0 -10
This will move the object to the Creator, whether it be the DS Agent Injector or the C3 Creator.
- mvsf is, in english, move to a place nearby thats safe. In this case, we want it to move to somewhere safe near the Creator.
- velo is the velocity the object appears with. This variable may look a little complicated, but in actuality is quite simple. (Better explanation needed here)
endm
You've just finished the install script! Congratulations! Now, moving onto the next script..
The Timer Script
scrp 2 4 50000 9
- This line tells to the engine that the lines which are following are a script.
- scrp = script
- We have to write the classifier of the agent the script refers to
- 9 is the number of the script : here, 9 means 'timer script'
gsub grow gsub live gsub seed gsub die
- gsub means : "jump to the subroutine' - so here the script will jump to the soubroutine grow, then live, then seed, then die.
- A subroutine is defined by two tags
- 'subr' "name of the subroutine" will begin the subroutine
- 'retn' will end it
- Now we're going to make the plant grow
subr grow setv va00 pose reps 2 wait rand 40 80 addv va00 1 pose va00 repe retn
- As said before, 'subr grow' opens the subroutine - here the name is 'grow', but you can use any name you want
- The image file has 3 images, and the base image is 0
- 'pose' defines the image used by the plant at the moment
- 'setv va00 pose' means we're setting the pose number in a variable, and this is because we can't add any values directly to the pose
- 'reps 2' means that the lines which are following will be repeated twice
- If you want something to be repeated, take it inside 'reps X' and 'repe', where 'X' is an integer
- 'wait rand 40 80' means the script will wait randomly from 40 to 80 ticks
- 'addv va00 1' : here we add 1 to the variable va00 - if you want to add something to a value, use 'addv' - if you want to substract something, you can use 'addv' too, you you'll have to add a negative number
- We've just add 1 to va00 - We've done this because we want to change the pose from 0 to 1
- Now we can set the pose to va00 : 'pose va00' means : set the pose to the number contained in va00
- 'repe' : this is the closing tag of the 'reps' command
- The pose changing is repeated twice, because we want to move from pose 0 to pose 2
- 'retn' closes the subroutine
subr live loop doif ov10 ne 100 setv va01 ov10 subv va01 1 setv ov10 va01 endi wait 1 untl ov10 = 100 retn
- 'subr live' opens the subroutine 'live'
- 'loop' is the first part of the command which will make a part of script loop
- 'doif someting' means 'do only if the something is true' - a doif must be closed by 'endi'
- Here we say : do only if ov10 isn't equal to 100
- 'setv va01 ov10' means we set the value of ov10 in va01 - 'setv' can be used like this too
- 'subv va01 1' will substract 1 from va01
- 'endi' closes the 'doif' tag
- 'untl something' is the closing tag of the 'loop' command - the script will loop until the condition 'something' won't be true
- Here the script will loop until ov10 will not be equal to 100
- 'retn' closes the subroutine
- Now we've waited some time, and the pant has 'lived' enough to make seeds
subr seed setv va10 posx setv va11 posy reps rand 2 5 new: simp 2 3 50000 "blank" 1 0 1000 attr 195 bhvr 0 elas 0.5 aero 2 accg 0.2 mvsf va10 va11 velo rand -10 10 rand -10 0 tick 1 repe wait rand 40 90 retn
- 'subr seed' opens the subroutine
- 'posx' and 'posy' are two game variables which are giving the position in x and in y of the agent on the map
- Here we set these values into variables
- Then we set how many times the plant will seed
- We write the 'creation of an agent script'
- 'mvsf x y' means the agent will move to the nearest safe position it can found around the coordinates we've given
- 'velo' sets the velocity, this way, the seed will not fall to the feet of the plant
- 'tick 1' tells that the script will wait 1 tick before calling the timer script
- 'wait rand 40 90' makes the plant wait
- 'retn' closes the subroutine
- Take care of two things : here, the norns will be unable to do anything with the seed, and the seed will be invisible - blank is an invisible image, which you can use at any time if you want something to be done , and if you want it to be invisible
- The plant has grown, lived and seeded : it can now die
subr die loop setv va00 pose subv va00 1 pose va00 untl pose = 0 setv va20 256 loop subv va20 50 alph va20 1 untl va20 ne 6 kill ownr retn
- 'subr die' opens the die subroutine
- 'loop' opens the loop command
- We will make the plant grow into the bad way : from adult to baby plant
- So we do as before, using 'pose' - here the script will loop until the pose will not be 0
- 'setv va20 256' : to make a dead animation, we will make the plant fade out - the plant will be visible,then a bit less, then invisible
- The command 'alph' will set the transparency of an agent - 'alph integer yes/no' is the syntax of the command.
- The integer is choosen from 0 to 256, where 256 means full visible, and 0 full invisible
- 'yes/no' : 1 = yes, 0 = no
- So the script will loop until the plant will be not far from invisible
- 'kill ownr' means that the owner of the script will be killed - here, the owner is the plant
- 'retn' closes the subroutine
endm
- 'endm' closes every script
- We will now make the timer of the seed
scrp 2 3 50000 9 wait rand 10 40 setv va00 posx setv va01 posy new: simp 2 4 50000 "basicplant" 3 0 rand 200 6000 bhvr 48 attr 199 perm 40 emit 7 1 accg 3 elas 25 fric 90 aero 2 setv ov10 rand 200 1000 mvsf va00 va01 tick 1 kill ownr endm
- 'scrp 2 3 50000 9' opens the timer script of the seed
- 'wait' : we want the seed to wait a bit before make a plant
- We set the position into variables
- And we make a plant
- The plant will move to the coordinates, and will wait 1 tick before going to his own timer script
- 'kill ownr' kills the ownr of the script - here , it's the seed
- 'endm' closes each script