Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-29-2011, 10:17 AM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
Var value from var name

PHP Code:
//#CLIENTSIDE
public function getVarFromName(varname) {
  if (
varname.pos(".") == -1) return -1;
  
temp.tokens varname.tokenize(".");
  
temp.objvar = new TStaticVar();
  
temp.objvar.copyfrom((@temp.tokens[0]));
  return 
getSubObj(temp.objvartemp.tokens.subarray(1temp.tokens.size() - 2)).(@temp.tokens[temp.tokens.size() - 1]);
}

public function 
getSubObj(obj,subobjstrarray) {
  if (
subobjstrarray.size()) return getSubObj(obj.(@subobjstrarray[0]), subobjstrarray.subarray(1subobjstrarray.size() - 1));
  else return 
obj;

In 'getVarFromName', the function returns -1 if the input string does not have an object prefix. I would like to return a variable that does not have an object prefix but I am having trouble figuring out how to do so.

this.(@"name"), since there is an object prefix, gives me the correct result. (The name of the weapon)

(@"mousescreenx") gives me 'mousescreenx' as a string.

Is there a solution this problem?
__________________
Reply With Quote
 


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:42 PM.


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