View Single Post
  #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