Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, AndrewAMD), 14,749 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
AUM 27 ai code - value limiting #251369
02/12/09 19:17
02/12/09 19:17
Joined: May 2008
Posts: 331
Lithuania, Vilnius
Jaxas Offline OP
Senior Member
Jaxas  Offline OP
Senior Member

Joined: May 2008
Posts: 331
Lithuania, Vilnius
Hi, i have a question, i wondering what sequent line do:

index %= 49; // limit the "index" value

Whether it's equal to:

if(index == 49)index = 0;

?

I want to understand what %= realy does smile


The smaller the bug, the harder it is to kill.
_________________________________________
Forklift DEMO (3dgs)
Re: AUM 27 ai code - value limiting [Re: Jaxas] #251387
02/12/09 20:26
02/12/09 20:26
Joined: Jan 2009
Posts: 76
V
V_Software Offline
Junior Member
V_Software  Offline
Junior Member
V

Joined: Jan 2009
Posts: 76
the % operator limits the value ( in this case index) to a maximum of 49, so that its impossible to go 50,51 etc.

something similar would be:
if(index > 100) { index = 0; )

but this is bad because it doesn't consider the actual index value, it just sets it to 0.

instead index %= 49 is just an abbreviation for:
index = index % 49;

and the % means just this:
remainder of index / 49
so with % Acknex returns an integer remainder of 2 numbers

Re: AUM 27 ai code - value limiting [Re: Jaxas] #251389
02/12/09 20:37
02/12/09 20:37
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cowabanga Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
It mean the limit of the variable.

Re: AUM 27 ai code - value limiting [Re: Jaxas] #251448
02/13/09 07:15
02/13/09 07:15
Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
George Offline

Expert
George  Offline

Expert

Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
The modulo (%) operator finds the remainder of the division of a number by another. As an example, 7 % 3 = 1, 8 % 4 = 0 and so on.
index %= 49 makes sure that index can't exceed 48; it will be set to 0, 1, 2, ..., 47, 48, 0, 1, 2... as index is incremented.

Re: AUM 27 ai code - value limiting [Re: George] #251479
02/13/09 09:49
02/13/09 09:49
Joined: May 2008
Posts: 331
Lithuania, Vilnius
Jaxas Offline OP
Senior Member
Jaxas  Offline OP
Senior Member

Joined: May 2008
Posts: 331
Lithuania, Vilnius
I get it. I count first 3 values and get that circle laugh i just think now, why i don't count it before, cause i know what is modulo... laugh but thanks for reply wink


The smaller the bug, the harder it is to kill.
_________________________________________
Forklift DEMO (3dgs)

Moderated by  George 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1