See topic title. The first four would be helpful keystroke-savers, and the latter is useful when trying to work out how many 16s are in a sprite's y value.
See topic title. The first four would be helpful keystroke-savers, and the latter is useful when trying to work out how many 16s are in a sprite's y value.
What does "div" do?
Well in any case the following have been added to the ZScript language in b14:
+=
-=
*=
/=
&&=
||=
&=
|=
^=
<<=
>>=
%=
Div is integer division. Think of it as the counterpart to mod.
Alternatively, you could add floor() (and ceiling()).
I don't think adding those to the language itself is necessary, but I will add the following functions to std.zh, the ZScript standard header that will be included in b14:
std.zh will also include constants like SFX_STAIRS for sound effects and item classes.Code://some utility routines int Floor(int x) { if(x < 0) return (x-.9999)<<0; return x<<0; } int Ceiling(int x) { if(x < 0) return x<<0; return (x+.9999)<<0; }
Actually div() would be a really useful function. Div would essentially be the equivalent of:
Code:result = x / y; if(result > 0) { result = Floor(result); } else { result = Ceiling(result); }
Added.
There are currently 1 users browsing this thread. (0 members and 1 guests)