ceil, floor & round commands
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6503 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -130,6 +130,12 @@ docargument [A] [action] [] [0];
|
||||
docexample [p = 1; push p 2; echo $p] [Output: 2];
|
||||
docident [result] [sets the result value of a CubeScript block];
|
||||
docargument [R] [the result] [] [0];
|
||||
docident [round] [Round a float and returns an integer];
|
||||
docargument [F] [The float number to be rounded] [] [0];
|
||||
docident [ceil] [Return the ceil value (integer) of a float];
|
||||
docargument [F] [The float number] [] [0]
|
||||
docident [floor] [Return the floor value (integer) of a float];
|
||||
docargument [F] [The float number] [] [0]
|
||||
docident [rnd] [Random value];
|
||||
docargument [A] [The upper limit of the random value] [] [0];
|
||||
docident [rrnd] [Ranged random value];
|
||||
|
||||
@@ -378,6 +378,30 @@
|
||||
<return token="R" description="The random value" valueNotes="larger or equal 0 and smaller than A"/>
|
||||
</command>
|
||||
|
||||
<command name="round">
|
||||
<description>Round the given float</description>
|
||||
<arguments>
|
||||
<argument token="F" description="The float number to round" valueNotes=""/>
|
||||
</arguments>
|
||||
<return token="I" description="The rounded integer" valueNotes="The precision is 1 unit"/>
|
||||
</command>
|
||||
|
||||
<command name="ceil">
|
||||
<description>Upper value of a float number</description>
|
||||
<arguments>
|
||||
<argument token="F" description="The float number to get the ceil from" valueNotes=""/>
|
||||
</arguments>
|
||||
<return token="I" description="The ceil value (integer)"/>
|
||||
</command>
|
||||
|
||||
<command name="floor">
|
||||
<description>Floor value of a float number</description>
|
||||
<arguments>
|
||||
<argument token="F" description="The float number to get the floor from" valueNotes=""/>
|
||||
</arguments>
|
||||
<return token="I" description="The floor value (integer)"/>
|
||||
</command>
|
||||
|
||||
<command name="strcmp">
|
||||
<description>Determines if two strings are equal.</description>
|
||||
<examples>
|
||||
|
||||
@@ -1272,6 +1272,11 @@ int lt(int a, int b) { return (int)(a<b); } COMMANDN(<, lt, ARG_2EXP);
|
||||
int gt(int a, int b) { return (int)(a>b); } COMMANDN(>, gt, ARG_2EXP);
|
||||
int lte(int a, int b) { return (int)(a<=b); } COMMANDN(<=, lte, ARG_2EXP);
|
||||
int gte(int a, int b) { return (int)(a>=b); } COMMANDN(>=, gte, ARG_2EXP);
|
||||
|
||||
COMMANDF(round, ARG_1STR, (char *a) { intret((int)round(atof(a))); });
|
||||
COMMANDF(ceil, ARG_1STR, (char *a) { intret((int)ceil(atof(a))); });
|
||||
COMMANDF(floor, ARG_1STR, (char *a) { intret(atoi(a)); });
|
||||
|
||||
#define COMPAREF(opname, func, op) \
|
||||
void func(char *a, char *b) { intret((int)(atof(a) op atof(b))); } \
|
||||
COMMANDN(opname, func, ARG_2STR)
|
||||
|
||||
Reference in New Issue
Block a user