Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Just wondering if this is possible (https://forums.graalonline.com/forums/showthread.php?t=134264281)

Tricxta 08-22-2011 01:07 AM

Just wondering if this is possible
 
Hey guys,

Im trying to learn GS2 now and im making some system that will read a string then spit out some data according to it.

So an example of what i'm trying to do is:

I want to get the information from a particular string but the program doesn't know what strings its going to receive so a predefined array is useless.

PHP Code:

clientr.some_weapon_ 

starts the string and this much I know, I also know that the weapon corresponding to the string ends with the same characters as the string.
So the weapon name could be weapons/bat and the string could be clientr.some_weapon_bat

So to construct the string I need I would do:
PHP Code:

temp.wname="bat";
temp.sname="clientr.some_" temp.wname

But now the actual problem... how would I tokenize the string to give me the value of client.some_weapon_bat ?

I've tried doing
PHP Code:

temp.wname="bat";
temp.sname="clientr.some_" temp.wname;
temp.tokens=temp.sname.tokenize(); 

But that didn't work... So is what i'm trying to do actually possible and if so how?

Deas_Voice 08-22-2011 01:12 AM

it is possible, and is done all the time!

you would need to 'convert' the string into an 'object' eg;
PHP Code:

clientr.(@"some_" temp.wname); 

to tokenize it... (editing... please hold.)
edit; sorry, can't get my head to work, i guess i'm too tired for that, but i've done it before.

fowlplay4 08-22-2011 01:19 AM

Yep.

I.e:

PHP Code:

function onCreated() {
  
temp."sword";
  
temp.("example_" temp.w) = "a b c d e";
  
temp.tokens temp.("example_" temp.w).tokenize();
  echo(
temp.tokens);



Tricxta 08-22-2011 01:25 AM

Wow, thank you very much for the quickly reply :)


All times are GMT +2. The time now is 10:18 AM.

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