Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   % (https://forums.graalonline.com/forums/showthread.php?t=21248)

LilNiglet 01-16-2002 05:08 AM

%
 
How exactly do you use %? What is it used for?

=X

grim_squeaker_x 01-16-2002 05:14 AM

Basically, % divides by the number behind percent, but leaves the part which can't be divided into a whole number.

3%2=1
500%5=0

LilNiglet 01-16-2002 05:17 AM

What is it useful for?

Python523 01-16-2002 05:19 AM

It's used in clocks (only thing I've seen it in) and it tells the var/string what the limit is and when to go back to 0
like:
blah= blah2%60;
when it reaches 60, it will reset back to 0
[EDIT] That's what I think it is for, I may be wrong =/ [/EDIT]

grim_squeaker_x 01-16-2002 05:20 AM

Quote:

Originally posted by LilNiglet
What is it useful for?
In certain for loops, E.G.
NPC Code:
if (created||timeout) {
for (this.i=0;this.i<3;this.i++) if (keydown(this.i)){
this.selected=(this.selected+vecx(this.i))%weapons count;
}
timeout=0.05;
}

Would mean that even if you are selecting your last weapon it'd reset back to the first one if you push right while on that weapon.
I also used it for the online time system Munkee requested.

KJS 01-16-2002 08:19 PM

Quote:

% mod; a%b = a - int(a/b)*b;
its used for things like when you want to find the left over value of something...

like you have 38 apples and this guy takes 35 apples if you say something like

currentapples%35 would = 3

WHIPENIE4 01-16-2002 09:11 PM

[screen_name says:]

what if you do this

73 % 35 = 3 apples left !@!@!?!@

so you could use that formula

you would just have to subtract

73 - 35 = 38 apples left, ahh more like it


All times are GMT +2. The time now is 11:35 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.