Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-14-2006, 04:07 PM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
Arrays and Reading Them

I haven't played in about 3-6 months now, and I have no clue how to script anymore :O. (Not that I knew anything in gs2 anyway)

this.modes = {0,1,3};

I have an array (above), and I was wondering how I would be able to read it?

if (params[1] == "F") {
this.mode = this.modes[this.mode+1];
}

how would i be able to make it go through this.modes and when it hits 3, reset. Any help appreciated.
Reply With Quote
  #2  
Old 01-14-2006, 06:22 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by KuJi
I haven't played in about 3-6 months now, and I have no clue how to script anymore :O. (Not that I knew anything in gs2 anyway)

this.modes = {0,1,3};

I have an array (above), and I was wondering how I would be able to read it?

if (params[1] == "F") {
this.mode = this.modes[this.mode+1];
}

how would i be able to make it go through this.modes and when it hits 3, reset. Any help appreciated.
Modulus is the answer.

this.mode = this.modes[(this.mode+1)%3];

(Note: the % 3 is not saying when it hits the 3 in the array, it's because there are 3 elements (0,1,2) of the array. I assume what you wanted was to cycle through the array and loop around, so that's what this does.)
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
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:49 PM.


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