Math Functions
|
Version 0.6.0 introduced math functions to EventScripts. Here's what it looks like:
Performs the math operator (+, -, /, *,add, subtract, multiply, or divide) on variable and value and stores the result in variable. EventScripts will expand any variables it finds. (Equivalent to running "es es_xformat".) This is fairly easy-- this just lets you perform math functions when you need to. Here's an example for any config file: // EventScripts v0.6.0 es_xsetinfo myvar 10 es_xmath myvar multiply 3 es echo server_var(myvar) This code would echo to the console something along these lines: 30 because "myvar" has been set to 30 as you requested. (Instead of "multiply" you could use the "*" symbol and achieve the same result.) es_math tries to keep float and integer values intact, but currently reverts to using floats when dividing. In v0.7.5, EventScripts added support for random number generation. For example, you can use es_rand to generate a random number between 1 and 6 in myvar: // EventScripts v0.7.5 // initialize es_setinfo myvar 0 es_rand myvar 1 6 es_msg The die rolled a server_var(myvar) might broadcast something like this: The die rolled a 4 |
|
