Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Dynamic string names...? (https://forums.graalonline.com/forums/showthread.php?t=84180)

Tyhm 02-13-2009 02:15 PM

Dynamic string names...?
 
So I've apparently inherited a really weird system NPC, and all I need to do to fix it is (I hope) access clientr.item_1.

Only it won't always be clientr.item_1, it'll be a different number every bloody time.

How the hell do we do that nowadays? -_-

thatdwarf 02-13-2009 02:23 PM

with a dynamic variable call:

PHP Code:

itemID 1;
foo "Long Sword";

clientr.item_(@itemID) = foo;

echo(
clientr.item_(@itemID)); 

would echo "Long Sword";

That's the basic idea behind the calls.

xXziroXx 02-13-2009 02:25 PM

Quote:

Originally Posted by thatdwarf (Post 1466058)
with a dynamic variable call:

PHP Code:

itemID 1;
player.clientr.item_(@itemID); 

That's the basic idea behind the calls.

More like this:

PHP Code:

temp.itemID 1// Without a header it won't be a temp variable, tsk tsk!
clientr.(@"item_" temp.itemID) = "foo"


Tyhm 02-13-2009 02:38 PM

@id. Thanks guys, there's no way in hell I would have guessed that one on my own. Seriously. This was my last resort, I went all the way through the wiki (incidentally, there is no mention of Dynamic Variable Call, that would be too easy!). I spent about half an hour trying every variation on clientr.item_#s(id), clientr.item_(id), clientr.item_#v(id)...I think I even did try a couple @s, but I didn't think I was getting any closer.
This is like one a those old text adventures:
"PUSH BUTTON"
"I don't see a Button here"
"PUSH ON BUTTON"
"I don't know how to do that"
"PUSH THE ON BUTTON"
"I don't know how to do that"
"PUSH ON THE BUTTON"
"You push the on button..."

Crow 02-13-2009 03:36 PM

Quote:

Originally Posted by Tyhm (Post 1466061)
@id. Thanks guys, there's no way in hell I would have guessed that one on my own. Seriously. This was my last resort, I went all the way through the wiki (incidentally, there is no mention of Dynamic Variable Call, that would be too easy!). I spent about half an hour trying every variation on clientr.item_#s(id), clientr.item_(id), clientr.item_#v(id)...I think I even did try a couple @s, but I didn't think I was getting any closer.
This is like one a those old text adventures:
"PUSH BUTTON"
"I don't see a Button here"
"PUSH ON BUTTON"
"I don't know how to do that"
"PUSH THE ON BUTTON"
"I don't know how to do that"
"PUSH ON THE BUTTON"
"You push the on button..."

@ is actually an operator and is, therefore, on the operators page of the wiki.

Admins 02-13-2009 03:45 PM

It's actually quite simple:
varname.varname.varname.varname.varname
clientr.something
clientr.("item_" @ myid)
("client" @ "r").something

You just construct the variable name (string concat), and you need to add the brackets so that the compiler knows that it belongs together.

thatdwarf 02-13-2009 04:50 PM

Quote:

Originally Posted by xXziroXx (Post 1466059)
More like this:

PHP Code:

temp.itemID 1// Without a header it won't be a temp variable, tsk tsk!
clientr.(@"item_" temp.itemID) = "foo"


DOH!
Thanks for the correction Ziro :D


All times are GMT +2. The time now is 03:56 PM.

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