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 02-13-2009, 02:15 PM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm will become famous soon enough
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? -_-
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #2  
Old 02-13-2009, 02:23 PM
thatdwarf thatdwarf is offline
Former UN Dev Admin
Join Date: Nov 2005
Posts: 42
thatdwarf is on a distinguished road
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.
Reply With Quote
  #3  
Old 02-13-2009, 02:25 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by thatdwarf View Post
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"
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #4  
Old 02-13-2009, 02:38 PM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm will become famous soon enough
@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..."
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #5  
Old 02-13-2009, 03:36 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Tyhm View Post
@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.
__________________

Last edited by Crow; 02-13-2009 at 03:58 PM..
Reply With Quote
  #6  
Old 02-13-2009, 03:45 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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.
Reply With Quote
  #7  
Old 02-13-2009, 04:50 PM
thatdwarf thatdwarf is offline
Former UN Dev Admin
Join Date: Nov 2005
Posts: 42
thatdwarf is on a distinguished road
Quote:
Originally Posted by xXziroXx View Post
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
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 11:11 PM.


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