Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-18-2012, 05:35 AM
Vatec Vatec is offline
Lurking
Join Date: Oct 2012
Posts: 27
Vatec is on a distinguished road
Using the 'in' operator with multi dimensional arrays

Hi all, I am working on an events system and want to use multi dimensional arrays but that standard "in" operator doesn't work like that, how else would I be able to check if the event name is correct?

Graal Script Code:
temp.array = {
    {
        
"test""30""30"
    
}, {
        
"event""30""30"
    
}
};
if (
eventName in temp.array) {} 
__________________


Quote:
Originally Posted by GULTHEX View Post
so i think the problem is that onactionclientside isint a real function
Reply With Quote
  #2  
Old 10-18-2012, 06:04 AM
Starfire2001 Starfire2001 is offline
Unholy Nation
Starfire2001's Avatar
Join Date: Dec 2010
Location: The streets.
Posts: 156
Starfire2001 will become famous soon enough
Quote:
Originally Posted by Vatec View Post
Hi all, I am working on an events system and want to use multi dimensional arrays but that standard "in" operator doesn't work like that, how else would I be able to check if the event name is correct?

Graal Script Code:
temp.array = {
    {
        
"test""30""30"
    
}, {
        
"event""30""30"
    
}
};
if (
eventName in temp.array) {} 
Probably easiest to just maintain a separate array with only event names. Or cycle through the array you have and check against the name against the first param of each.
__________________
-Ph8
Reply With Quote
  #3  
Old 10-18-2012, 06:58 AM
Vatec Vatec is offline
Lurking
Join Date: Oct 2012
Posts: 27
Vatec is on a distinguished road
Yeah well if there wasn't a simple way to do that then I think it's best to have an array the names, /thread
__________________


Quote:
Originally Posted by GULTHEX View Post
so i think the problem is that onactionclientside isint a real function
Reply With Quote
  #4  
Old 10-18-2012, 03:34 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
If you want to keep them in the same array do something like this:

Graal Script Code:
temp.events = {
  
"event", {3030"otherdata"},
  
"event2", {2020"loldata"}
};

temp.event_name "event";
temp.event_index temp.events.index(temp.event_name);
if (
temp.event_index >= 0) {
  
temp.event_data temp.events[temp.event_index+1];
  
// do stuff

The in operator will also work as well in this case.
__________________
Quote:
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 10:40 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.