Garden Box Development Guides, posted here in one convenient file since the forums are Very, Very Broken (Thank you, Mea, for bringing this to my attention). Please email questions/concerns/errors to amaikokonut at songua dot com! Thanks!

Writing/Converting Garden Box Agents:

This is a simple guide to making your agents Garden Box compatible.

First, you just write the agent like any other agent. Eat scripts, growth scripts, flying scripts, whatever.

Then, in the injection script, mvsf your agent to game "ch_x" game "ch_y" to get it to inject where the crosshair is pointing. The agent should not inject unless the crosshair is in a valid position, so you shouldn’t need to worry about backup coords. Really, only extensive testing will tell, but my hope is that no one will have to write tmvt backups.

Really, that is all you need to do in the cosfile itself. The rest of the GB-compatible information is stored in the PRAY file.

You will need to prepare a display sprite no larger than 40x40 (unless you want to be known as “the lazy guy who’s huge sprites mess up my garden box.”). It is recommended that you have a specific sprite prepared for display. You will specify this in your prayfile.

Write your PRAY file as you would any other PRAY file, but keep these differences in mind:

- Use group DSGB “[Agent Name]” not AGNT, not DSAG. The chunk type must be DSGB for the Garden Box to detect it.

- Keep in mind that no two agents can have the same name or they will clash; that collectively includes all standard C3, DS, and GB agents, so it might be a good idea to denote your GB-specific agents with a prefix or suffix to avoid clashes.

- Dependencies, scripts, inline files, etc; are all written in as normal.

- Agent Description is written as normal, but keep in mind there is less space to display it on the Garden Box. Include details in a help file and just keep the description brief.

- "Agent Animation File", "Agent Animation Gallery", and "Agent Sprite First Image" are all still required, though animation itself is not supported (thus, "Agent Animation String" does not need to be included) These will point to your 40x40 display sprite.

- “Web URL”, “Web Icon” and so on are not supported. They won’t blow up anything, no, but they won’t do you any good.

The following new items can be included in your prayfile

“GB_Category” [integer 1-8]

Categories are as follows:
1: Patch Plant
2: Traditional Plant
3: Animal
4: Aquatic Plant
5: Aquatic Animal
6: Decoration
7: Tools
8: Misc/Other

- Take special caution to not accidentally label something as a patch plant or decoration that isn’t one (or vice versa), because agents in these categories are injected differently and are likely to crash the injector if they’re mislabled.
- If you don’t include a category, your agent won’t be able to be filtered. (it will still show up if no filter is applied).

"GB_Category Name" “[name]”

This is not required or even recommended. If your category is defined as a number higher than 8, this will attach a name to that number. Useful for creating your own categories, and annoying people by clashing your categories with theirs and slowing down the filtering process as the game tries to filter all those categories. Use sparingly, if ever.

Agent Author” “[Your Name]”

- Will display next to the agent name. I always wished the regular agent injector had something like this-- it would make tracking authors down a lot easier.
- If you don’t include an Author name, the author will show up as “Unknown.”

Otherwise, write as you would a normal prayfile.

Now personally, I'm as lazy as they come, so I actually use CAOS2PRAY with Jagent/Monk (Requires the latest version 2.0.4, updated 8-14-12) and have a block like this at the top of my cosfile:

*# Pray-File "gb_pp_apples.agent"
*# DSGB-Name "Apples (C3)"
*# Depend apple.c16
*# Attach gb_applepatch.c16

*# desc = "Juicy, crunchy C3 apples, now available anywhere."
*# Agent Animation File = "gb_applepatch.c16"
*# Agent Animation Gallery = "gb_applepatch"
*# Agent Sprite First Image = 0
*# GB_Category = 1
*# Agent Author = "Amaikokonut"

Then select "PRAY Chunk" on Monk and drag the cosfile onto it. It should then compile the agent properly, assuming all the components are in the same folder. In my view, this is the easiest way to do things.

Feel free to ask any questions, let me know if there's any confusion, or just let me know if following these instructions works!

Guide To Writing Patch Plants

Herein lies the very-detailed annotated cosfile for the chillies patch plant! You should be able to use this as a template for your own patch plants, or just get a general idea of what it entails:

**How to make a Patch Plant
**Using the Chili Pepper Plant as an example

**The first thing you need to do is make an invisible flag agent
**This agent is classified as 1 205 X, and stores information about your patch plant.
**This means a lot of NAME variables.

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

*The first thing you're going to do is define the number of your spawn script
*This is the script that the patch core will trigger when it's time to spawn a fruit/bud/whatever.
*I'm going to use script 1000 for this... we'll get more into it later.

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" "chilli"
setv name "sprite_pose" 11

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

setv name "prod_fmly" 2
setv name "prod_gnus" 8
setv name "prod_spcs" 22935

*now personally, I like to define my blossoms as "fruit" all the way through the growing process,
*and just keep them invisible to creatures until they are fully grown. You might chose to do it
*differently and define them as flowers that later are killed and replaced with fruits. However
*you choose to do it is up to you-- but the only agents that are going to be considered part
*of your patch are those with those classifiers as defined above. Thus, once your flower is killed
*and replaced with a fruit, the patch won't recognize it anymore-- so you'll have have to do some
*more creative coding if you want to do it that way.

*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

**That's it for your install script!

*Now for your spawn script-- this is 1000 as we defined it in the install script.

scrp 1 205 22935 1000

*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). It has also stored the plane set by the patch options in the NAME
*"patch_plane" variable.

*So first, create your little fruit to be:

new: simp 2 8 22935 "chilli" 14 1 name "patch_plane"

*again, I like to keep my blossoms invisible to creatures so they don't
*try to eat them while they're still flowers. You also obviously don't want them to suffer
*physics just yet.

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

*And that is just about it.

*From here you pretty much script it like you would any other blossoming plant-- give it a timer
*script to grow, ripen, become visible and so on. Of course, don't forget eat scripts,
*collision scripts, etc.

*Keep in mind: when your plant is picked (or falls off the patch if you decide to code it like that)
*aside from making it suffer physics, you'll also have to decide if you want to clear the
*patch_id variable. If you clear it, it will no longer count toward the total number of
*fruits growing on the patch, and a new one will spawn to take its place. If you don't clear
*it, the script will keep counting it and until that fruit is eaten or otherwise disappears,
*a new fruit won't spawn. If you haven't scripted your fruits to eventually decay, you may
*wish to keep the patch_id variable intact so you don't have a patch that keeps spawning
*endless numbers of fruits that pile up and slow down the game.

*Another thing you might consider doing is setting the tick to something static after the fruit
*falls off the patch, so that the growth rate set by the user does not affect the decay rate of
*the fruit. Personally, I choose not to do this, but it is an option to consider.

*This is my timer script:

scrp 2 8 22935 9

*if it's not fully grown, grow it to the next stage

doif pose lt 10
setv va00 pose
addv va00 1
pose va00

*if it is fully grown, add to its timer (ov00), and make sure creatures can see/grab it.

doif ov00 lt 10
addv ov00 1
doif attr = 80
attr 67

*also make it start smelling like a fruit

emit 6 0.01

*if it's fully grown and has been sitting on the plant for 10 turns,
*it should fall off the patch

doif attr = 67
attr 195
pose 11

*I'm going to chose to clear the patch_id variable so a new one can spawn where it fell.

setv name "patch_id" 0

*and if it's fully grown and already on the ground, it should add to its decay timer (ov01)

elif attr = 195
doif ov01 lt 10
addv ov01 1

*but if its been laying on the floor for 10 turns, go ahead and call it rotten.
*I'm going to be lazy and just kill targ, but if you have proper sprites prepared,
*turning it into detritus can benefit your ecosystem if you've got bugs and critters that eat it.

kill targ

*here's the collision script-- in this case if it's hitting the floor for the first time
*it changes the sprite.

scrp 2 8 22935 6
snde "smit"
doif ov02 = 0
pose rand 12 13
setv ov02 1

*This is the pickup script

scrp 2 8 22935 4

*if it's attr is still 67, you (or a creature) are picking it directly off the plant
*and need to set it so it doesn't act attached to the patch anymore

doif attr = 67
attr 195
pose 11

*Again, I'm going to chose to clear the patch_id variable so a new one can spawn.

setv name "patch_id" 0

*Finally, the eat script. Nom.

scrp 2 8 22935 12
snde "leat"
stim writ from 78 1

*going to add hotness and vitamin C to mimic the hardman chilis.

doif from ne null
targ from
chem 153 .15
chem 99 .35

*Again, I'm just killing it here, but no reason you can create a fruit with multiple bites, or
*something that turns into detritus after it's eaten.

kill ownr

enum 1 205 22935
kill targ
enum 2 8 22935
kill targ

Feel free to post any questions you have in this thread! I will do my best to keep it updated with clarifications to make the development process as easy as possible.

Guide To Writing Decorations

Decoration agents are painfully simple to write-- in fact, it probably takes more time to write the PRAYfile than the code, unless you want to include some really snazzy special actions.

This is your basic code for a decoration agent:

new: simp 1 99 [spcs] "[sprite]" 1 0 500
mvto game "ch_x" game "ch_y"

scrp 1 99 [spcs] 1001
*special action 1

scrp 1 99 [spcs] 1002
*special action 2

scrp 1 99 [spcs] 1003
*special action 3

scrp 1 99 [spcs] 1004
*special action 4

enum 1 99 [spcs]
   kill targ

Unless you plan on actually including special actions in your scripts, you don't have to include those scrp lines either, meaning the only code you need is:

new: simp 1 99 [spcs] "[sprite]" 1 0 500
mvto game "ch_x" game "ch_y"

enum 1 99 [spcs]
   kill targ

How's that for simple?

Important things to note:
- The family/genus must always be 1/99 -- that's how the deco panel tells it's a decoration.
- it has to be a simple, not a compound agent, else it won't show up with the box-selection properly (Turns out LINE doesn't play nice with compound agents) >:
- You cannot change the ATTR (well, you can try, but the deco panel will reset it). Deco agents will always be invisible to creatures, no matter what.
- If you want to get really creative and include other scripts in your deco agents, keep in mind that the following are already used with the garden box deco panel:
     - 1 (Activate 1/Select)
     - 4 (Pickup)
     - 10 (Creation/Self-select)
     - 75 (Mouse movement)
     - 1001-1004 (Special Actions-- you can use these obviously, for their intended purpose)
     - 2000 (Plane Change)
If you use any of these scripts in your deco agent, they're unlikely to work properly.

Have fun! The decoration possibilities are endless.