Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Help With For(); (https://forums.graalonline.com/forums/showthread.php?t=69567)

Rapidwolve 10-21-2006 07:19 PM

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

Yen 10-21-2006 07:20 PM

PHP Code:

for (iclientr.items) {



i will be every element of clientr.items

Rapidwolve 10-21-2006 07:32 PM

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

xAndrewx 10-21-2006 07:32 PM

for (curItem: getstringkeys("clientr.items"))
{
curItem stuff
}

To new one:
What is 'this.library'?

Yen 10-21-2006 07:41 PM

getstringkeys() requires a bit of hacking when you use it like that.

Rapidwolve 10-21-2006 07:46 PM

Quote:

Originally Posted by xAndrewx (Post 1233920)
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))

xAndrewx 10-21-2006 07:52 PM

Quote:

Originally Posted by Rapidwolve (Post 1233925)
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()'

Rapidwolve 10-21-2006 07:53 PM

Ahh getdynamicvarnames(); Worked, except it returns the "item_" too.

xAndrewx 10-21-2006 08:10 PM

Maybe use file.substring(5) or maybe makevar would fix it, not too sure. =]

Rapidwolve 10-21-2006 08:13 PM

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

xAndrewx 10-21-2006 08:17 PM

Quote:

Originally Posted by Rapidwolve (Post 1233935)
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

Rapidwolve 10-21-2006 08:20 PM

Now it doesnt show the commas x_X
It returns: 372402

But I fixed using
PHP Code:

temp.newItems @= temp.reMake.substring(5) @","


xAndrewx 10-21-2006 08:24 PM

hehe, glad it works =]

Rapidwolve 10-21-2006 08:29 PM

Thanks.


All times are GMT +2. The time now is 09:16 AM.

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