version 1.1
Please find the lessons about scripting if you want a basic primer in how to script objects.
Scripting objects is what everyone, even new players, can do as scripting only allows a sub-set of these command or as find: [thorn] coined them: cowmands.
If you have proved yourself worth then you will be granted access to code objects and use this full set of cowmands.
TOC
Introduction to COWScript
About blocks or subs
About COWScript commands or cowmands
About creating commands for users
The anatomy of an object
COWscript commands (old presentation)
Definitions
More detailed definitions
* The full list of commands *
Extra Info storage
Notes on the written content of an object
About reacting objects
Introduction to COWScript
CowScript consists of one or more blocks (sometimes called subs)
of named code containing one or more commands (sometimes called cowmands).
When you code an object code the elephant you are putting code into that object so that it can react to events around it.
Every object (even you) can be coded and every command a user can type (like look, say, create and get are simply specially named objects that behave in a global way.
Some sample COWScript:
if reacting to drop then sniffit;
##sniffit:
print "[$actor] sniffs [$target]";
getgender $actor;
if $target's name like "%cheese%" then eatit else ignoreit;
##eatit:
print "[$actor] licks $hisher lips"
call "eat $target";
##ignoreit:
print "[$actor] turns $hisher nose up at [$target]"
About blocks or subs: up
A block starts with a double hash '##' and ends at the start of the next double hash or the end of the code.
The name of the block of code immediately follows the double hash and ends with the first colon ':'. In the above example there are 3 code blocks called 'sniffit', 'eatit' and 'ignoreit'.
You can name your blocks almost anything you like, just avoid spaces and punctuation and 'key words' used for triggering reactions. If an object contains a block name that matches a 'key word' used in a message, the object will perform that block of code (see About reacting objects below).
Blocks of code are named so you can make logical jumps from one block to another.
When you use the if cowmand to logically choose one block or another, any code following the if (up the the next block) will be executed after the called block.
In this way blocks are like functions or subroutines that are called during the flow of the code.
With this in mind, you can use the include cowmand to include a standard set code blocks you can use without having to re-type them. read the info about include.
About cowScript commands: up
Each command within a block of code starts with a 'command word' or 'cowmand' and ends with the first semi-colon ';'.
The above example has several commands if, print, getgender and call.
You can use the redundant niceness of 'please', 'thanks' and 'thankyou' in your commands if your in the mood. They have no impact on your commands execution but they might make you feel better when reading the code.
please set $actor's loc to $dest;
set $tactor's loc to $target's loc thanks;
This is my little hommage to the google: [Intercal Programming Language]
The parameters of each command are separated initially by a space however additional parameters may be separated by spaces, commas or keywords as defined for each command.
In the first example:
if $target's name like "%cheese%" then eatit else ignoreit;
if_{operand}_{operator}_{operand}_then_{sucess}_else_{fail};
If has 7 params seperated by spaces.
White spaces and new lines around commands are ignored and can be used to make the code block more legible. Here is a sample of code without newlines:
##setloc:var $dest to $actor's loc;if $target's loc eq $dest then sayhere else saythere;
About creating commands for users up
Global commands users type when using cow (like look, get, say, create and drop) are objects called the name of the command eg 'a command called get' holds the code for the 'get' command.
If a command object is not in one of the books in the library it will still work as a valid command however you wont be able to read about it via the commands command.
When finding a command to execute, cow first looks inside the player, then in the players current location, then finally anywhere in cow. This way an 'action called get' in the current location will be used to perform the get command instead of the global get command.
So if you want to override specific commands in some places, just make named objects in a location and hide them. (pose it as hidden then put it on itself and it disappears from view)
So, named objects in the current location will be executed as a command.
eg. in a room with a pig named mike,
a player types 'mike come here',
if the pig is coded like a command it will be performed.
The anatomy of an object up
read: [1250]
COWscript commands: up
(Is going to be completely replaced by the new full list of commands. See further. Kept here for the time this new part is not finished).
if {condition} then {true_sub_name} else {false_sub_name};
get {$target | $target,to,$text | $text,'to',$target | $target,$ret,$second | $pretext,$target} in {$object};
msg {$loc},{$actor},{$target},{$second},"{trigger_cmd_name}","{msg_text}";
say "{trigger_cmd_name}","{msg_text}";
set {thing} to {thing};
var {$variable} to {thing};
new {full_object_description_text}; // sets $target and $new_loc and $old_target
find {$thing},{$thing|random filter}; // sets $found_id and $found_loc
foreach in {$loc} do {sub_name} {filter}; // fore each object in this location do the named sub.
look {$loc},{method}; // populates the locaiton and sys_msg strings
with current location based on method.
goto {sub_name}; // continue execution from this named sub
case {thing} do {sub_name}; // do the sub based on the thing passed
mode {mode_name};
call "{user_cmd_string}"; // must be in quotes
copy {thing}; // makes a duplicate copy of an object
touch {object}; // updates the objects upd_time so it wont be
deleted.. all GET objects are touched so this
is probably redundant.
code {thing} cut|copy|paste {code} // manipulate the code of an object
add {value} to {$variable}
take {value} from {$variables}
swap {$variable} so {thing} is {thing} // swaps one string with another in the named variable swap $newname so "black" is "white" - swap #newclass so $target's class is $new_colour; # list is returned to $current_loc
colour {thing} //
dedupe {thing} // removes duplicate instances of the specified object
list {criteria} // lists all objects (no in void) based on criteria - default is all new objects.
nudge {thing},up|down|left|right|north|east|south|west // change an objects x,y,z
clear {thing},xyz|all // clear objects x,y,z and or pose,host and hosthow -
load {thing}|colour // loand the content from an object or the colour list
save {thing}
loop {blocktorun|cut text|copy text|paste text}
Definitions: up
{thing} = {obj_field | $var | "string"}
{condition} = {thing} {like | eq | ne | > | < | != } {thing}
{obj_field} = {{resolves_to_obj_id}'s }field} eg: $actor's host's link's host's qty
{msg_text} = "[$actor] did $action with params of $cmd_text" If you enclose a variable in [] then it will be translated into then name of the object represented by the value of the variable
{trigger_cmd_name} = a simple word used to find objects which react to the action performed eg get and eat should both used the trigger_word 'get'
{user_cmd_string} = a command as if typed by a user eg 'call create a cat;' will cause the current actor to create a cat
{code} = iether part of a codename to match OR a block of code to paste
$var = a temp variable created for use only while this object is performing its commands. (there are some pre-defined variables $actor, $loc, $cmd_text, $init_obj, $init_cmd etc.. I will describe later).
find method = 'random' = pick a random object in this location..
look method = 'list|full|inv|examine|trade'
If var ends with [1] then only return the first word of string: $text = 'to the fish' $text[1] returns 'to'
If the code of an command is 'code like {object}' the that named command will be used eg 'same as paint'
new sets vars: $target,$new_loc
find sets vars: $found_id,$found_loc;
foreach sets vars: $for_id,$for_link,$for_class,$for_name,$for_code,$for_info,$for_extra,$for_host
look sets vars: $current_loc or $sys_msg with description of the obj $loc, method is 'inv','list','examine' or blank for default location description
copy sets vars: $new_id,$new_loc
If you want to change the default click command do this:
var $click_cmd to 'watch';
var $desc_intro to 'Click on an object to watch:';
look $loc,list
case $actor's weight do something,another,secondsub; // starts at 0
More detailed definitions up
{thing}
A thing in a command can be one of several things, it always resolves itself into a value but it can be derived from several sources.
A thing can be:
a constant number eg 123
a constant string of text "old and crumbly"
the ID number (obj_id) from the named object eg $actor,$loc,$target etc..
a field value from a named object eg $actor's host -or- $target's link etc..
This concept needs a little more explanation:
In an effort to make the syntax very english-like I have opted for the delimiter of "'s " to separate the objects unique ID and its field name.
read The anatomy of an object to see what fields an object has.
Logically you can continue chaining values until you reach your desired value eg $actor's host's loc's link's loc's class
(does not appear to be working beyond 2 levels - code still in progress)
If you refer to a field that is not part of the standard anatomy, it becomes a new object within the object.. and is called a pocket variable. This way there is no limit to how much info can be stored with an object. It also means you can go inside your object and directly edit some of these values by editing the objects inside it.
The full list of commands up
add
call
case
clear
code
copy
dedup
divide
find
foreach
fixplural
get
getname
goto
if
load
loop
mode
motion
msg
multiply
new
nudge
percentbar
refresh
runsub
save
say
set
swap
take
var
ADD up to full list
Adds a number to a variable. Since the VAR command can only set one value, you have to use ADD and TAKE to modify a number variable
Syntax:
add {number} to {$variable}
Example:
var $amount to 10;
add 2 to $amout;
say 'msg',"the number twelve looks like this - $amount";
CALL up to full list
lets the current actor simply perform commands as if they had typed them.
Syntax:
call "command string with embedded variables"{, delay in seconds or a full reversed datetime}
Example:
call "think whats is [$init_obj] doing now!?!"
call "get $found_id";
call "go north",10;
call "shout hello",20081001101010;
When specifying a time delay the command wont be processed until that number of seconds have passed.
To use the datetime, it must be 14 characters long YYYYMMDDHHNNSS. as soon as that second has passed the command will be performed.
Once you have 'call'ed a command it sits on the command stack awaiting processing.. nothing can stop it once its in the command stack.
By making a command that silently sends out a trigger word, you can call that to trigger something into action some time in the future.
CASE up to full list
Runs the nth block of code based on the value used in the case statement.
If the value is larger than the number of blocks named then nothing is done.
Syntax:
case {number} do {list_of_block_names};
Example:
case $actor's counter do say1,say2,say3,say4;
##say1:say 'msg',"[$actor] counter is one";
##say2:say 'msg',"[$actor] counter is two";
##say3:say 'msg',"[$actor] counter is three";
##say4:say 'msg',"[$actor] counter is four";
CLEAR up to full list
Use this to clear the pose, host and x,y,z positions of an object.
if you specify 'all' then everything gets cleared.
if you specify 'xyz' then just the x,y and z values are cleared.
Syntax:
clear {object},all|xyz
Example:
clear $target,all;
clear $actor,xyz;
CODE up to full list
Manipulate the code of an object. You can cut, copy and paste sections of code.
Syntax:
code {thing} cut|copy|paste|as|switch on/off {code_name|"string"|$variable};
Returns:
$orig_code is set to the code of the named object prior to the action.
$copy_code is a subset of all code blocks matching the name specified (result of cut and copy).
$new_code is the entire code pasted back into the object (result of cut and paste).
Example:
if you want to get all of the code blocks matching 'xnewobj' from the target object do this:
code $target's code copy 'xnewobj';
This will find ##newobj: and ##newobj1: and ##newobjcontinue: etc.. and put it in $copy_code for later use.
To paste this code into the second object:
code $second's code paste $new_code;
To remove all instances of code refering to 'move' from the actor:
code $actor's code cut "move";
To append all of the code from the target into the second do this:
code $target's code copy "junk";
code $second's code paste $new_code;
To completely duplicate the code from the target to the second use the SET command:
code $second as $target;
Note: paste just adds the code to the bottom of the object's current code and duplications of code blocks may result in unpredictability.
To turn an objects tick or tickloc on or off use code like this:
code $target switch on;
code $actor's host switch off;
This turns all instances of tick into txick and visa-versa.
COPY up to full list
Copies the named object.
Sets the variable $new_id to the new objects ID.
Syntax:
copy {object}
Example:
copy $target;
DEDUP up to full list
Reduces duplicate objects into one with appropriate quantity.
use it after you have used new if you dont want lots of individual objects created.
It finds the location of the object you name and dedupes in that location, accumulating all quantities and leaving just one object that matches both class and name.
Syntax:
dedupe {thing}
Example:
new a cat;
dedupe $new_id;
GET up to full list
Work out which object's ID or string of text the player is refering to and sets the associated variables. If the player typed 'open the red door', then the OPEN command will try and find 'the red door'.
Syntax:
get {things} [in {locs}]
get {things} can be:
get $target just try and resolve the target object and nothing else
get $target,to,$text Resolve the target object and all text following the word 'to' eg. rename the cat to Frank
get $target,$rel,$text same as above but uses all relationship words 'to' 'in' 'beside' etc...
get $target,$rel,$text,non-greedy same as above but matches FIRST rel words not last
get $pretext,$target
get $target,$rel,$second
The {locs} is either one object the target and the second must be found in,
or two objects separated by a comma where the target then the second must be found in if they are to be different. ***difficult to understand***
This concept allows us to specify that you can only give something in your carry to an object in the same location as you eg.
get $target,$rel,$second in $actor,$loc;
This says: find a target in the current actor and a second in the current location.
There are a set range of things you can get:
get {$target | $target,to,$text | $text,'to',$target | $target,$rel,$second | $target,$rel,$text,non-greedy | $pretext,$target} in {$object1,$object2};
$lastword is automatically set as the last word in the string (specifcally for painting things: paint the cat orange)
The non-greedy word (4th param) alters how much text is grabbed when divising up the users command.
It is used in the force command as we want to match on the first relation word 'to' not the last 'to' in this example:
'force the cat to do jumps on wolis then goes to sleep'
However we dont want to use it in when whispering, we want to match on the last rel word 'to' in this examle:
'whisper you should go to the open field to wolis'
GETNAME up to full list
Returns a nice printable string variable called $this_name of the objects name.
You may optionally specify one of these methods: tiny, brief or extended.
for an object = 'an apple which is tasty' you get:
tiny = an apple
brief = the apple
extended = an apple which is tasty in the fruit bowl
If the object were a player it would not use 'a' or 'then' and simply return the objects name for both tiny and brief.
Syntax:
getname $object{,tiny|brief|extended};
Example:
getname $target;
say 'msg',"[$actor] lookes at $this_name";
GOTO up to full list
Jumps to the named block of code, like runsub
Syntax:
goto whattodo;
Example:
goto sayitnow;
goto sayitagain;
goto sayitnow;
##sayitnow: say 'msg',"[$actor] says 'welcome';
##sayitagain: say 'msg',"[$actor] says 'all I have to say is';
FIND up to full list
Finds an object in the selected location, either explicitly by name or randomly.
Syntax:
find $loc,cat; this finds a cat in the current location
find $loc,random {options}; this finds a random object in the current location taking into account options, see below..
find $loc,dusty path; finds an object called 'dusty path' in the current location..
Options for find random:
doorway
not doorway
player
not player
not me
locked
not locked
edited
not edited
You can combine these in any combination eg:
find $loc,random not doorway not me not player;
find $loc,random player not me;
find $loc,random not me not locked edited;
find $loc,random doorway;
FIXPLURAL up to full list
Fixes the plural version of an objects name (this in actually its 'class').
Syntax:
fixpural {$object}
After changing the 'class' of an object - say changing a cat to a dog, you will need to fix up the pluralised verision of the new name.
Since the 'class' is the singular form of the objects name the 'pclass' contains the puralised form and would contain 'dogs' or 'cats' etc..
Simplt chaning the class dows not automatically change the class so running fixplural will do this, based on the current contents of class.
set $target's class = 'knife';
fixplural $target;
The target object will now display as 'knives' if there are more than one (qty > 1) and 'knife' if one.
Note: cow contains the basic rules of pluralisation.
FOREACH up to full list
Loops through objects or lines of a file, performing the named block for each item.
Syntax:
foreach in {$thing|list} do {block} {options};
Options for the foreach are the same as the find:
doorway
not doorway
player
not player
not me
locked
not locked
foreach sets vars: $for_id, $for_link, $for_class, $for_name
after loading a list, foreach in list sets var: $list_line
If you specify a location (your $thing resolves to an single id number) then the block is performed for every object in that location.
foreach in $loc do checkcolour not doorway not player;
foreach in $actor's do interogate;
If you specify 'list' then the content of the last loaded list is used and the variable $list_line contains each item found in the list:
load $actor's mood;
foreach in list do showmood;
##showmood: say 'mood',"[$ator] $list_line";
If you specify an actual list then each item in the list will be used:
var $lst to ''reg,green,yellow with white dots,black'';
foreach in $lst do showcolour;
IF up to full list
If the contition is true the continue from the first named sub else continue from the last named sub.
Syntax:
if {thing} {like | eq | ne | > | < | != } {thing} then {true_sub_name} else {false_sub_name};
Example:
if $actor's host > 0 then onsomething else freestanding;
In this example we check to see if the $actor's host value is > 0. If it is then continue with the code block named 'onsomething' otherwise continue with a sub called 'freestanding'.
See the description of a 'thing' for more information.
LOAD up to full list
loads the contents of named thing into the global list @list for processing with loop or foreach.
The first entry in the list is set into $listitem and a random item from the list is $randomitem.
If you load colours you get the full list of colour names
Use save to save back to a {thing} and loop or foreach to work with the lines of the list.
If you have already loaded a list then the keyword 'incr' or 'increment' can be used to retrive the next top line from the list. This is useful for stepping down through a list.
Syntax:
load {thing|incr{ement}|colours}
Example:
load $actor's pocket;
loop printcontent;
or
rem - say the first two lines from the actors memory;
load $actor's memory;
say 'msg',"[$actor] says '$listitem'";
load increment;
say 'msg',"[$actor] says '$listitem'";
Note that in the above examples neither the 'pocket' or the 'memory' are fields within the object table. If thry had been (like 'info', 'extra', class etc..) then the value from the name field would be loaded. Since they are not field names then objects with matching names are looked for within the $actor and the 'info' (what you write in an object) is used.
I call these kinds of internal holders of information 'pockets' or 'pocket variables' as this was the first use I had for them.
Use new lines to seperate items in the list so if you need a list of word or phrases for an object to say, just create an object called something like 'mylist' edit it like this:
Welcome to this fine place
My look at that
What is thr world coming to?
Welcome back my old friend
then give this pocket object to your actor object so you can:
load $actor's mylist;
say 'msg',"[$actor] says '$randomitem'";
SAVE up to full list
Saves the contents of the current global @list to a {thing}
Use load to load a list from a {thing} and loop to work with the lines of the list.
Syntax:
save {thing}
Example:
load $actor's pocket;
loop add "A new line for the list";
save $actor's pocket;
LOOP up to full list
Loop through the contents of the current global list @list and work with the lines its contains.
You can add new lines to the list, remove lines and process blocks of code foe each line found using the loop command.
When using cut and copy the global variable $list_clipboard is set the the matching line.
When processing a block of code, the global variable $listitem is the current line.
The cut and copy will do a partial match:
cut will remove all lines that match the string.
copy will only set $list_clipboard the last match found.
Syntax:
loop {blockname}
loop {cut|copy|paste "string"}
Example:
rem - example of printing out contents of an objects pocket variable;
load $actor's pocket;
loop showline;
##showline:say,'msg',"[$actor]'s pocket contains $listitem";
rem - example of adding a new lines to a specific objects info field;
load $found_id's info;
loop paste "[$actor] has added a new line to this";
save $found_id's info;
rem - example removing a line from a list which contain the word 'bad' ;
load $found_id's memories;
loop cut "bad";
save $found_id's memories;
rem - example finding the last line that matches the word 'good';
load $found_id's memories;
loop copy "good";
say 'msg',"[$found_id] has '$line_clipboard' in its meories';
MODE up to full list
Executes an in-built mode function (m_{function name}
Syntax:
Example:
MSG up to full list
Sends a message out to a thoses who are listening.
Thes is the base command on which the say command is built on and simplifies.
MSG allows infinate control over where the mesage is heard and who gets to hear it (say does not).
If the location is 0 then everyone gets to hear the message like a shout or somthing done loudly
If the actor is 0 then anything trying to react to it wont know who initiated this message
If the target and second are 0 then everyone in the location hears it, otherwise its like a whisper just for the target and second
The trigger_word is the key word which triggers other objects into action
The visible message is displayed to those who can see it. By including variables you can embed strings oftext in your message. By including object IDs in square brackets you can embed object names.
The init_obj is the initiating object who caused this message to be generated (optional)
The initiating command string is the whole string which was used to trigger this message (optional)
To have your message have its embedded variables converted correctly you must use double quotes around the message string.
To get the name of an object into the messge you need to wrap it variable name in square brackets most commonly you want to refer to [$actor] and [$target].
Syntax:
msg {location}, {actor}, {target}, {second}, {trigger_word}, "{visible message}", {init_obj}, {initiating command string}
Example:
rem - create a varaiable to hold a random sound, then make that sound visible to all those in the current location ($loc)
var $sound to (bing bong,ting-a-ling,wooop wooop,eee oor,nee nar);
msg $loc,$actor,0,0,'sound',"[$actor] goes $sound";
rem - send a secret message to the actor - noone else can see
msg 0,0,$actor,0,'secret',"(only you [$actor] can see this message )";
rem - assuming we have already defined $destination we can tell everyone in that location that the $target has arrived.
msg $destination,$target,0,0,'arrives',"[$target] stumbles in from [$loc]";
The trigger words in these three examples are 'sound', 'secret' and 'arrives'. Any object that reacts to any of these trigger words will rn as soon as they see these messages. Coding an obejct to react to these is done by defining a block with the triger name in it eg ##sound:runsub dosomething;
NEW up to full list
Create a new object. If one with the same name already exists it is simply combined into the one object. Its worth is also merged, so if you have 1 fig worth 5 pennies and you create a new fig worth 1 penny, you end up with 2 figs worth 6 pennies in total. Unfortunately getting one fig will split the value evenly into 3 pennies each.
Syntax:
new {object name}
Example:
rem - create a golden elephant;
new golden elephant;
rem - create a pig using a variable name as the objects name;
var $nobj to "pig";
new $nobj;
rem - use a combination of variables to name your new object;
var $otype to (wooden,metal,broken,strong,flimsy);
var $oname to "door";
new "$otype $oname";
NUDGE up to full list
Moves an object on the map view by a small increment
The direction is a string of up, down, left, right, north, east, south, west
Syntax:
nudge {target},{direction}
Example:
nudge $target,up;
nudge $actor,south;
RUNSUB up to full list
same as goto, runs a block of code, then continues running code below it
Syntax:
Example:
SAY up to full list
A short-hand way of getting a message out into the current location.
You have no control over who sees the message.
If the location is 0 then everyone hears it like a shout or a something done loudly.
the key word 'msg' is a commonone for general messages an no object should be coded to react to a msg. This isnt to say no object will but since 'msg' has been used extensivly for all manner of messages, you could not loically handle a reaction to it, unlike a conceptual trigger word like 'get' or a 'drop' etc..
You can view a list of all coded objects which generate trigger key-words with this: mode triggers() note it only works in no-frames view so pop open a new window by clicking on the time and then execute that command.
Syntax:
say 'trigger word',"message string"
Example:
rem - simple show others in this location that the actor is looking up;
say 'msg',"[$actor] looks up and contemplates the clouds";
rem - show a message in this location saying that the actor picked something up.. objects which react to a get may respond if need be;
say 'get',"[$actor] bends down and picks up [$target]";
rem - to replcate a SAY or THINK command you simply include all of the appropriate punctiation;
say 'say',"[$actor] says 'What on earth was that!?!'";
say 'think',"[$acor] . o 0 (I wonder if I should investigate)";
SET up to full list
Sets a value into an object.
This is different from VAR in that it maniputales the named object not just a temporary variable.
You get to make use of the ownership'apostrophy S space' concept when setting values of an object.
Note, changing any value of an object is immediate and silent, you need to use SAy or MSG to let others know the change has taken place.
In some instances you may want to force users to look around again.
usually you are simply setting values like location, colour, description etc.. however there is a concept of 'pocket variables' which makes an object hold an unlimited amount of information regardless of the fields in the anatomy of an object.
Syntax:
sat {object's field} to {new value}
Example:
rem - changing an objects info (what is seen when you read it) to a set string of text;
var $something to "who would have thought";
set $target's info to $something;
rem - moving an object to a new location, sending messages to both old an new locations informing accordingly;
var $dest to $olink's loc;
msg $loc,$actor,0,0,'leaves',"[$actor] is spirited away via [$olink]";
set $actor's loc to $dest;
msg $desc,$actor,0,0,'arrives',"[$actor] tumbles down from the sky";
pocket variables
If you name a field of an object which is not in the anatomy of an object then the contents of the object are checked for objects with that name and their info (what you see when you read and write in them) is used as the value.
eg:
If you have a mouse, and you want to store the kind of nut it has in its pocket you can do it like this:
set $actor's holder to "walnut";
Since there is no 'holder' field in the anatomy of an object a new object called 'holder' is created (or the existing one if one already exists) within the mouse (the $actor in this example) and its info is set to 'walnut';
You can query the $actor's holder just like you might check an $actor's loc or an $actor's colour, even though you are refering to a distinct object in cow, which itself may contain its own set of pocket variables!
They are called pocket variables as they are esentially what the object is holding at that time (in their pocket).
The battle process uses this concept as it creates a pocket variable call 'counter' within each object which holds their current starting penny value so a percentage bar-graph for each object can be shown (comparing original to current values).
SWAP up to full list
replaces a string with another string in a variable
Syntax:
swap {variable} so {old string} is {new string}
Example:
rem - change the instances 'blip' with 'blop' in the variable;
var $sound to "the thing went blip then blip again";
swap $sound to "blip" is "blop";
TAKE up to full list
Reduces the value of a number variable by a specified amount
Syntax:
take {number} from {$variable}
Example:
rem - reduce the quantity of an object by 1, including setting the vale back into the object;
var $amt to $target's qty;
take 1 from $amt;
set $target's qty to $amt;
DIVIDE up to full list
Divide the number variable by the number specified
Syntax:
divide {$variable} by {number}
Example:
var $bignum to 999;
dvide $bignum by 10;
MULTIPLY up to full list
Multiply the number variable by the number specified
Syntax:
multiply {$variable} by {number}
Example:
var $smallnum to 99;
multiply $smallnum by 10;
PERCENTBAR up to full list
sets two variables formated for displaying in messages which are:
$percentbar = the graphical percentage = [####------]
$pct = the numerical percentage = 40%
Syntax:
prcentbar {$variable} of {$variable}
Example:
pecentbar $result of $total;
say 'msg',"$result is $pct of $total - which looks like this $percentbar";
MOTION up to full list
A very specific cowscript command which retrieved an objects specifed mode of motion. read the command called motion
This makes a variable called $motion you can you in messages, with iether 'away' or 'in' at the end.
Syntax:
motion {$object},{arrives|leaves}
Example:
rem if the actor's motion for leaves is 'flies' the message is that the actor 'flies away';
motion $actor,leaves;
say 'leaves',"[$actor] $motion";
REFRESH up to full list
Makes sure all objects hosted by the specified object have the same location as the hosted object (otherwise they get left behind)
Syntax:
refresh {object}
Example:
set $target's loc to $newloc;
refresh $target;
UNHOST up to full list
Pushes every object which is hosted by the named object off so it can safely be move to a new location without effecting the ,previsouly, hosted objects.
Syntax:
unhost {thing}
Example:
unhost $target;
set $target's loc to $newloc;
VAR up to full list
read: [7338]
Extra Info storage up
About looping up
Do this when looping through a list:
foreach in list do something;
##something:
if $list_line eq $init_obj's name then foundfriend else end;
The magical string variable $list_line is your current line while looping through the list.
read: [7337]
About reacting objects up
An event is any message shown to everyone in a location eg when someone arrives, or says something.
Each individual event or message carries an invisible keyword which is what coded objects listen for and react to.
eg:
A mouse is coded to react to the 'drop' keyword that accompanies the message indicating that someone dropped something.
When someone drops something in the same location as this coded mouse, it triggers the mouse into action and it executes it block of code it has that relates to drop.
##drop: runsub whattodo;
##whattodo:
say 'msg',"[$actor] sniffs [$target]";
There are timed events that trigger reactions which will be discussed later.