Syntax question?

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
turshija
Posts: 127
Joined: Sat Feb 17, 2007 9:26 am
Location: Novi Sad, Serbia
Contact:

Syntax question?

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.
User avatar
VilleK
Site Admin
Posts: 2277
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

Re: Syntax question?

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
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Syntax question?

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.
User avatar
turshija
Posts: 127
Joined: Sat Feb 17, 2007 9:26 am
Location: Novi Sad, Serbia
Contact:

Re: Syntax question?

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.
Post Reply