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 10-21-2006, 07:19 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Help With For();

I am making a QMenu that gets its information from an ItemLib.

Lets say I have clientr.items= 421,320,52. I would use
PHP Code:
for (0clientr.items.size(); i++) 
How would I make it so I can use for(); with something such as:
clientr.item_421
clientr.item_320
clientr.item_52

Without having to have clientr.items
Reply With Quote
  #2  
Old 10-21-2006, 07:20 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
PHP Code:
for (iclientr.items) {


i will be every element of clientr.items
Reply With Quote
  #3  
Old 10-21-2006, 07:32 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
PHP Code:
public function listLib(){
temp.list.loadvars(this.library);
for (
itemp.list.getstringkeys("item-")){
echo(
"Items: " i);
}
return;

I figured out part of it thanks to Yen on aim, its supposed to echo all the id's in the text file. But it's not working
Reply With Quote
  #4  
Old 10-21-2006, 07:32 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
for (curItem: getstringkeys("clientr.items"))
{
curItem stuff
}

To new one:
What is 'this.library'?
__________________
Reply With Quote
  #5  
Old 10-21-2006, 07:41 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
getstringkeys() requires a bit of hacking when you use it like that.
Reply With Quote
  #6  
Old 10-21-2006, 07:46 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Quote:
Originally Posted by xAndrewx View Post
for (curItem: getstringkeys("clientr.items"))
{
curItem stuff
}

To new one:
What is 'this.library'?
this.library is "scriptfiles/ur_itemlib.txt"

Also:

GraalScript: Function getstringKeys not found at line 67 in script of ItemLib (in level databases.nw at pos (30.5, 30))
Reply With Quote
  #7  
Old 10-21-2006, 07:52 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by Rapidwolve View Post
this.library is "scriptfiles/ur_itemlib.txt"

Also:

GraalScript: Function getstringKeys not found at line 67 in script of ItemLib (in level databases.nw at pos (30.5, 30))
Weird?
Works fine for me, I use it all the time:
HTML Code:
  this.shield_1 = {"Basic Shield", "shield1.png", "tom_icon-shield1.png"};
  this.shield_2 = {"Mirror Shield", "shield2.png", "tom_icon-shield2.png"};
  this.shield_3 = {"Lizard Shield", "shield3.png", "tom_icon-shield3.png"};

  for (temp.curShield: getstringkeys("this.shield_"))
  {
    echo(temp.curShield);
  }
I used it earlier today to just do this... o-O


For the file, I think you'd need to use 'getdynamicvarnames()'
__________________
Reply With Quote
  #8  
Old 10-21-2006, 07:53 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Ahh getdynamicvarnames(); Worked, except it returns the "item_" too.

Last edited by Rapidwolve; 10-21-2006 at 08:04 PM..
Reply With Quote
  #9  
Old 10-21-2006, 08:10 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Maybe use file.substring(5) or maybe makevar would fix it, not too sure. =]
__________________
Reply With Quote
  #10  
Old 10-21-2006, 08:13 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Here is the problem with substring.

PHP Code:
echo(temp.list.getdynamicvarnames("item_").substring(5,-1)); 
Echos 372,item_402

It only takes away the first five letters for the first string, and leaves the rest as it is
Reply With Quote
  #11  
Old 10-21-2006, 08:17 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by Rapidwolve View Post
Here is the problem with substring.

PHP Code:
echo(temp.list.getdynamicvarnames("item_").substring(5,-1)); 
Echos 372,item_402

It only takes away the first five letters for the first string, and leaves the rest as it is
Ah yes
simple:
HTML Code:
for (temp.reMake: temp.list.getdynamicvarnames("item_"))
{
  temp.newItems @= temp.reMake.substring(5);
}
message(temp.newItems);
Should work
__________________
Reply With Quote
  #12  
Old 10-21-2006, 08:20 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Now it doesnt show the commas x_X
It returns: 372402

But I fixed using
PHP Code:
temp.newItems @= temp.reMake.substring(5) @","
Reply With Quote
  #13  
Old 10-21-2006, 08:24 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
hehe, glad it works =]
__________________
Reply With Quote
  #14  
Old 10-21-2006, 08:29 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Thanks.
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 05:21 AM.


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