Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-16-2002, 05:08 AM
LilNiglet LilNiglet is offline
Registered User
Join Date: Jun 2001
Posts: 3,178
LilNiglet is on a distinguished road
%

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

=X
Reply With Quote
  #2  
Old 01-16-2002, 05:14 AM
grim_squeaker_x grim_squeaker_x is offline
Retired Oldbie
grim_squeaker_x's Avatar
Join Date: Mar 2001
Posts: 3,084
grim_squeaker_x will become famous soon enough
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
__________________

Reply With Quote
  #3  
Old 01-16-2002, 05:17 AM
LilNiglet LilNiglet is offline
Registered User
Join Date: Jun 2001
Posts: 3,178
LilNiglet is on a distinguished road
What is it useful for?
Reply With Quote
  #4  
Old 01-16-2002, 05:19 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
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]
Reply With Quote
  #5  
Old 01-16-2002, 05:20 AM
grim_squeaker_x grim_squeaker_x is offline
Retired Oldbie
grim_squeaker_x's Avatar
Join Date: Mar 2001
Posts: 3,084
grim_squeaker_x will become famous soon enough
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.
__________________


Last edited by grim_squeaker_x; 01-16-2002 at 05:33 AM..
Reply With Quote
  #6  
Old 01-16-2002, 08:19 PM
KJS KJS is offline
The one, The only -
KJS's Avatar
Join Date: Apr 2001
Location: USA, Minnesota
Posts: 1,012
KJS is on a distinguished road
Send a message via AIM to KJS
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
__________________
Thanks,
-KJL
Reply With Quote
  #7  
Old 01-16-2002, 09:11 PM
WHIPENIE4 WHIPENIE4 is offline
I am X-Mann
Join Date: Aug 2001
Location: PA
Posts: 2,715
WHIPENIE4 is on a distinguished road
Send a message via ICQ to WHIPENIE4 Send a message via AIM to WHIPENIE4
[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
__________________
Mind over Matter. If your body dont mind, why does it matter?

- X-Mann (Blessing Graal since 1998) Haha

- Graal 2000 Project (Contact Me to get Apart of this expierience

Windows Vista. Graal. Not a Good Combination.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:20 AM.


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