Difference between revisions of "Mod"

From WikiManual
Jump to: navigation, search
m (Reverted edit of Retard, changed back to last version by Numsgil)
m (Fixed typos)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
===[[Operators]]:===
 +
{{Basic Commands}}
 +
 
Modular Math Operator.  '''BINARY'''
 
Modular Math Operator.  '''BINARY'''
  
Line 5: Line 8:
 
  351 69 mod
 
  351 69 mod
  
is the same as (351 mod 69), which is 6.  Thus "351 69 mod" is equivelant to writing "6".
+
is the same as (351 mod 69), which is 6.  Thus "351 69 mod" is equivalent to writing "6".
 +
 
 +
Mod allows a user to check whenever a given value is a multiple of a specific number. Ie.
 +
 
 +
cond
 +
*.robage 5 mod 0 =
 +
start
 +
'do something every 5 cy's
 +
stop
 +
 
 +
This particular code allows a bot to essentially set an action to activate every 5 cycles.
 +
 
 +
=== Pre 2.4 ===
 +
 
 +
In versions before 2.4, you cannot do maths in conditions. You can however, use the stack to the same effect:
 +
 
 +
cond
 +
start
 +
*.robage 5 mod
 +
stop
 +
 +
cond
 +
0 =
 +
start
 +
'do something every 5 cy's
 +
stop

Latest revision as of 21:05, 14 February 2014

Operators:

Basic Commands:

add & sub
mult & div
rnd
*
mod
sgn
abs

Modular Math Operator. BINARY

Removes two values from the stack. Performs modular arithmetic on the two values, placing the result onto the stack.

351 69 mod

is the same as (351 mod 69), which is 6. Thus "351 69 mod" is equivalent to writing "6".

Mod allows a user to check whenever a given value is a multiple of a specific number. Ie.

cond
*.robage 5 mod 0 =
start
'do something every 5 cy's
stop

This particular code allows a bot to essentially set an action to activate every 5 cycles.

Pre 2.4

In versions before 2.4, you cannot do maths in conditions. You can however, use the stack to the same effect:

cond
start
*.robage 5 mod
stop

cond
0 =
start
'do something every 5 cy's
stop