creatures caves welcome, guest
downloads   gallery   dev   community   creatchi   forum   mycaves
bookmarks | search | post new topic
Strangeo Forum
old
A Fruity Ramble   
Malkin

Malkin
Australia  
Manager


 visit Malkin's website: Malkin's page at CWiki
  4/19/2013  2

Just thought I should write down some thoughts on 'what a growing patch of plants needs' - hope this helps someone. As always, comments on coherency, completeness and accuracy are welcomed. :)

A growing patch of plants, like the apples, needs at least 2 agents - the mother and the fruit.

The 'mother' agent is invisible (1 1 X) and uses her timer script (1 1 X 9) to periodically check how many apples are in the world, and if she should create a new one. If the agent is a patch plant, the mother agent has to talk with the main GB to get certain parameters, (where to put them, what plane to put them in, etc.) and the timer script is called a 'spawn_script' and is script 1000.

*Flag agent, stores information about my patch plant


new: simp 1 205 10853 "blnk" 0 0 9000


*The first thing you're going to do is define the number of your spawn script - script 1000.
*This is the script that the patch core will trigger when it's time to spawn a fruit/bud/whatever.


setv name "spawn_script" 1000


*Now you have to define the file name and image number of the sprite that will represent your plant
*when it is fully grown. This will be used both in placing a fruit/bud and serving as the little
*indicator that shows on the hand when you're placing the patch.

sets name "sprite_file" "medlar"
setv name "sprite_pose" 13


*finally, you need to define the classifiers for your produce

setv name "prod_fmly" 2
setv name "prod_gnus" 9
setv name "prod_spcs" 10853


*Now that you have everything defined, you need to contact the patch core agent (1 1 22929) and let
*it know that you're here-- the patch scripts will take it from there and generate the
*placement windows, let the user choose options, and so on.

seta va00 targ
enum 1 1 22929
mesg wrt+ targ 1000 va00 0 0
next

**That's it for your install script!


Now for the spawn script:

*Now for your spawn script-- this is 1000 as we defined it in the install script.
scrp 1 205 10853 1000
inst
*If this script is running, it's because the patch core decided it was time for your
*patch to spawn a new bud. It has also sent the coordinates it has decided were proper in
*_p1_ (x) and _p2_ (y)

*So first, create your little fruit to be:
*As of May 2012, patch_plane lets the users choose which plane the fruit will appear on.
new: simp 2 9 10853 "medlar" 14 0 name "patch_plane"
attr 80
bhvr 48
accg 2
perm 64
fric 100
elas 30
aero 2
*And move it to the coords sent by the patch agent:
mvto _p1_ _p2_
*Now, a few new name variables have been defined in your patch flag agent since you last
*left it-- these are settings that have been defined in the options window as well as a
*unique patch ID number that has been generated. You'll need to copy these over to your
*your budding fruit!
*The patch ID is important-- if you don't copy it over, the patch plant won't realize that
*the fruit is there, and it will spawn another one, and continue spawning FOREVER.
setv name "patch_id" mame "patch_id"
*then there's the ticks as set in the options panel:
tick rand mame "tickfrom" mame "tickto"
*personally I like to define a default tick too, in case something goes wrong and the tick ends
*up as 0.
doif tick eq 0
tick 200
endi
endm


And that's the 'mother' agent done with.

The fruit itself has a few scripts.

Script 9, the timer script for the fruit, lets the apple flower bloom by stepping through each picture for the blossom, and changes the attributes of the fruit when it's fully ripe (so that creatures can't see, smell or pick unripe fruit, and so that ripe fruit falls). It also controls the fruit's lifespan - generally this is accomplished by adding to a 'life time' variable, counting up (or down) until the fruit rots.


*And the timer....copypasted but greatly edited!
scrp 2 9 10853 9

doif ov00 eq 0
doif carr eq null
doif pose lt 13
setv va00 pose
addv va00 1
pose va00
else
*changed from 64 to 80
doif attr eq 80
*this is the turning point at which it becomes edible~
attr 67
endi
addv ov99 1
endi

doif ov99 ge 20
setv ov99 0
doif attr eq 67
attr 195
endi
setv ov00 1
endi
endi
endi
*if ov00 is 1, it's been picked or fallen, and thus stops growing and starts rotting.
doif ov00 eq 1
*We're going to set its patch id to 0 now.. this detaches it from the patch itself
*So that it doesn't count toward the number that can grow on the bush
setv name "patch_id" 0
addv ov99 1
doif ov99 ge 50
doif carr eq null and room targ <> -1
altr room targ 4 0.01
altr room targ 3 0.01
kill ownr
endi
endi
endi
endm


The next major script is the eat script (12). This script is the core of your fruit agent, but it's very simple - make a noise, and give the creatures nutrients by stimming them. You can also add in pose changes to this, or, by storing the location of the fruit before it's eaten, you can make a new detritus agent exactly where the fruit once was. This is how the C3 apple creates an apple core. You can also add in extra chemicals to this script, for extra goodness.

*eat script!
scrp 2 9 10853 12

setv va00 posl
setv va01 post

stim writ from 78 1

stim writ from 82 1


wait 10
snde "eat1"
kill ownr
endm


Because you often want to design fruit to be picked by Hand or norn, you need a pickup script (4) to fire because the timer script hasn't finished making the fruit fully detachable yet. So you need to check if the attributes say it's unripe, change it to being ripe, and maybe change the pose. This script sets the permeability for the garden box apples, too - if you want half the items to go on the higher levels and half to go to the lower levels, set "perm rand 40 60" - most semi-permeable platforms are set to perm 50. If it's a garden box agent, you need to tell the main garden box that the fruit has left the patch, so the apple mother can decide if she needs to make more apples.

*This is the fruit pickup script, copypasted from Clabs
scrp 2 9 10853 4
lock
*if it hasn't been picked up before, a few things are going to change...
*like it starts actually acting like fruit~
doif ov00 eq 0
setv ov00 1
endi
doif attr eq 67
attr 195
endi
perm 60
endm


You can also have a collision script (6), which can make a noise, and change the pose of the fruit. It can also change the attributes of the fruit, if needed.

*pickup
scrp 2 9 10853 6
doif carr eq null
plne 4000
endi
endm


Going back to the eat script for a minute, you can create a new detritus agent, like an apple core. The new detritus agent needs a lifespan, often defined by a timer script, and an eat script. You can use CATO and CATA to fool everyone into thinking you've made a new detritus agent while not using any more precious class numbers, but that is beyond scope.

You also need to remove your agents and scripts:

rscr
enum 1 205 10853
kill targ
next
enum 2 9 10853
kill targ
next


My TCR Norns
 


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
0 online
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