![]() |
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? -_- |
with a dynamic variable call:
PHP Code:
That's the basic idea behind the calls. |
Quote:
PHP Code:
|
@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..." |
Quote:
|
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. |
Quote:
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.