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

Difference between revisions of "SUBV"

From Creatures Wiki
Jump to navigation Jump to search
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<b>SUBV</b> is a [[CAOS]] command used to subtract [[variable]]s.
+
'''SUBV''' is a [[CAOS]] command used to subtract from a [[variable]].
  
 
==Usage==
 
==Usage==
Syntax: <i>SUBV X(int or float variable) Y(int or float)</i>
+
Syntax: ''SUBV var (variable) x (int or float)''
  
Standalone command. <br />
+
Subtracts ''x'' from ''var'', i.e. performs <code>var = var - x</code>. If the types of ''var'' and ''x'' do not match, ''var'' will be cast to the best precision; so if ''var'' is int and ''x'' is float, ''var'' will become a float.
Subtracts Y from X.<br />
 
  
 
==Examples==
 
==Examples==
<i>SUBV</i> being used to decrease a variable:
+
''SUBV'' used to decrease a variable:
 
<pre>
 
<pre>
SUBV va02 1
+
setv va00 3
 +
subv va00 1.2
 +
outv va00
 +
  1.800000
 +
</pre>
 +
 
 +
Adapted from the [[basic interactive plant script]], used to shrink the plant down into an immature phase:
 +
<pre>
 +
doif pose gt 0 
 +
  setv va00 pose 
 +
  subv va00 1 
 +
  pose va00 
 +
endi 
 
</pre>
 
</pre>
  
 
==See also==
 
==See also==
*[[ADDV]]
+
*[[ADDV]], the inverse
*[[SETV]]
+
 
 
[[category:C3 CAOS Commands]]
 
[[category:C3 CAOS Commands]]

Latest revision as of 07:40, 9 September 2018

SUBV is a CAOS command used to subtract from a variable.

Usage[edit]

Syntax: SUBV var (variable) x (int or float)

Subtracts x from var, i.e. performs var = var - x. If the types of var and x do not match, var will be cast to the best precision; so if var is int and x is float, var will become a float.

Examples[edit]

SUBV used to decrease a variable:

setv va00 3
subv va00 1.2
outv va00
  1.800000

Adapted from the basic interactive plant script, used to shrink the plant down into an immature phase:

doif pose gt 0  
   setv va00 pose   
   subv va00 1   
   pose va00  
endi   

See also[edit]