Gameware Creature Labs Press Shop Forums


Making a Vendor for C3

In this tutorial you can learn the basics of making a vendor - an agent that produces other agents.

A vendor can take many forms, and can produce anything that you like! Using the knowledge from the previous two tutorials it is now straightforward to produce a vendor for making toys or food. Have a look at the code below, and download the COS file here.
Code Explanation
**make the vendor
inst
new: simp 2 23 10 "fishbowl" 2 0 5000 Create new simple object
attr 199 Give it attributes that allow it to be picked up and activated by the hand. Responds to gravity and boundaries.
perm 60 A permeability that will allow it to sit on wooden platforms (rather than fall through them)
elas 0 Elasticity of 0%
fric 100 Friction of 100%
accg 3 Acceleration due to gravity of 3
mvto 5000 3400 Move to the corridor area of the ship
cmrt 0 Move the camera to look at the object
*****vendor activate
scrp 2 23 10 1 This is the activate 1 script for the vendor created above
*make the bowl animate
anim [0 1 0 1 0 1 0 1 0 1 0] Animate the bowl
*get the coordinates for the bowl This part gets some world coordinates from the bowl - the food can then be created at this position later in the script
setv va00 posl Get the left position of the bowl
addv va00 30 Add 30 to the left position (makes the coordinate further to the right on the screen)
setv va01 post Get the top position of the bowl
addv va01 10 Add 10 to the top position (makes the coordinate further down screen)
*produce something here!
inst make the rest of the script run instantly
*cheesy-food
new: simp 2 11 1000 "infinite_cheese_machine" 2 44 4900 Create new simple object. This cheese food is the same one created in a previous tutorial
attr 195
bhvr 48
elas 30
fric 50
accg 3
mvto va00 va01 Move it to the position calculated.
*give it some velocity
velo rand -10 10 rand -15 -20 Give it some velocity - this will make it come flying out of the top of the vendor. In this case we're using random values for both the X and Y velocities.
*give it a tick
tick 8 Give it a small tick (this is purely used to change the image plane of the cheese - it starts off at a plane behind the vendor and then after a small time moves to a plane in front of the vendor)
endm End of activate 1 script
*****cheese timer
scrp 2 11 1000 9 The timer for the cheese created by the vendor
plne 5001 Change image plane
tick 0 Stop the timer
endm End of timer script
*****eat script
scrp 2 11 1000 12 Eat script for the cheese - identical to eat script from previous tutorial
lock
sndc "chwp"
stim writ from 79 1
pose 1
wait 20
kill ownr
endm

Injecting this item into the world will show you a fish bowl type object sitting on the floor. Clicking on it will produce a lump of cheese from the top of the device.This can be altered to produce anything you desire ... toys, devices, eggs, anything! There are many examples of vendor type machines in C3, including:
  • Norn, Grendel and Ettin Egg Layers
  • Cheese Machine
  • Seed Banks
  • Creator and Replicator
  • ... and many more!
The same principle can be used to create temporary items - such as a spray of mist from the Anti-Infection spray or the Atmosphere machine in the Norn Terrarium - the thing that is produced does not have to be an agent that will exist in the world for long.

The important things to remember when creating a vendor:
  • You need to get coordinates for the created object to appear. Normally this is based on the position of the vendor object - with modifications to position it and/or take into account of its size.
  • You should check that the created object can actually be positioned where you are trying to put it. For example, if you are in an enclosed space when you activate the vendor you may find that the coordinates for the created agent now lie outside of the room system - and produce an error.



Topic Keywords: agent caos creatures3 tutorials

Copyright | Privacy Policy | Contact us | RSS