Welcome to the Creatures Wiki! Log in and join the community.

Editing CAOS

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 8: Line 8:
 
CAOS is a register-based language, with a set of opcodes with fixed argument lists. Local variables are not supported. The basic unit of CAOS code is the command which can be injected and executed by the engine. However, CAOS is mostly used in [[script]]s, blocks of code identified by four integers - three identifying the [[class number|object for which the script applies]] (0 may be used as a wildcard), and one identifying the [[event]] the script triggers on. Those form the backbone of the actual game, declaring the different forms of interactions between the different [[COB]]s or [[agent]]s (a term for the programming objects introduced with [[Creatures 3]] - every [[gadget]] or even [[creature]] in the [[world]] is an [[agent]]) by defining [[action]]s to be taken when certain events happen (from time triggered ones to [[physics|collisions with other objects]] or even clicks).
 
CAOS is a register-based language, with a set of opcodes with fixed argument lists. Local variables are not supported. The basic unit of CAOS code is the command which can be injected and executed by the engine. However, CAOS is mostly used in [[script]]s, blocks of code identified by four integers - three identifying the [[class number|object for which the script applies]] (0 may be used as a wildcard), and one identifying the [[event]] the script triggers on. Those form the backbone of the actual game, declaring the different forms of interactions between the different [[COB]]s or [[agent]]s (a term for the programming objects introduced with [[Creatures 3]] - every [[gadget]] or even [[creature]] in the [[world]] is an [[agent]]) by defining [[action]]s to be taken when certain events happen (from time triggered ones to [[physics|collisions with other objects]] or even clicks).
  
Each script may contain [[subroutine]]s; however as these cannot be shared and do not have local variables, they are little more than a convenience.
+
Each script may contain subroutines; however as these cannot be shared and do not have local variables, they are little more than a convenience.
 
 
Objects in Creatures are written using an [[wikipedia:object-oriented programming|object-oriented programming]] approach.
 
  
 
CAOS scripts have 100 registers of the form [[VAxx|VA''xx'']] to use to hold temporary variables. In addition, an object may be selected into the special register [[TARG]], and then 100 [[attributes]] of the object may be accessed with registers of the form [[OVxx|OV''xx'']]. In most cases an object must be selected into TARG before it is acted upon. Using the command [[AVAR]] to access the OV''xx'' variables of an agent without having to fiddle with TARG, one can implement simple arrays.
 
CAOS scripts have 100 registers of the form [[VAxx|VA''xx'']] to use to hold temporary variables. In addition, an object may be selected into the special register [[TARG]], and then 100 [[attributes]] of the object may be accessed with registers of the form [[OVxx|OV''xx'']]. In most cases an object must be selected into TARG before it is acted upon. Using the command [[AVAR]] to access the OV''xx'' variables of an agent without having to fiddle with TARG, one can implement simple arrays.

All contributions to Creatures Wiki are considered to be released under the CC-BY-SA and GFDL (see Creatures Wiki:Copyrights for details).

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)