All topics about ZGameEditor goes here.
Moderator: Moderators
-
turshija
- Posts: 127
- Joined: Sat Feb 17, 2007 9:26 am
- Location: Novi Sad, Serbia
-
Contact:
Post
by turshija »
I wanted to know how to use modulation ? in most of programming languages its MOD or % but doesn't work in ZGE...
10 mod 5 = 0
10 % 5 = 0
12 % 5 = 2
i need it now

Yo mama's so fat that a recursive function computing her weight causes a stack overflow.
-
VilleK
- Site Admin
- Posts: 2371
- Joined: Mon Jan 15, 2007 4:50 pm
- Location: Stockholm, Sweden
-
Contact:
Post
by VilleK »
You can use frac-funtion which returns the decimal part.
frac(10.5) = 0.5
frac(10) = 0.0
Temp1=12/5; //2.4
Temp2=Temp1-frac(Temp1); //2.0
Temp1=Temp1*5 - Temp2*5; //2.0
Temp1 now has the mod-value.
Maybe if you tell me what you want to do then I can suggest an
easier variant?
I will add a mod-function in a later version.
-
beldus
- Posts: 3
- Joined: Thu Feb 01, 2007 6:41 pm
- Location: Sweden
Post
by beldus »
turshija wrote:I wanted to know how to use modulation ? in most of programming languages its MOD or % but doesn't work in ZGE...
10 mod 5 = 0
10 % 5 = 0
12 % 5 = 2
i need it now

I'm not totally up to date with the syntax in ZGE but couldn't you do?
modvalue =frac(X/Y)*Y
Where from your example x=10 and y=5
-
VilleK
- Site Admin
- Posts: 2371
- Joined: Mon Jan 15, 2007 4:50 pm
- Location: Stockholm, Sweden
-
Contact:
Post
by VilleK »
beldus wrote:
modvalue =frac(X/Y)*Y
Where from your example x=10 and y=5
Ah, clever!
I knew there must be a simpler solution then what I suggested.
-
turshija
- Posts: 127
- Joined: Sat Feb 17, 2007 9:26 am
- Location: Novi Sad, Serbia
-
Contact:
Post
by turshija »
beldus wrote:
modvalue =frac(X/Y)*Y
Where from your example x=10 and y=5
nice ...
I'm happy there are more people online because there are more ideas
Thanks ...
Yo mama's so fat that a recursive function computing her weight causes a stack overflow.