View Single Post
  #1  
Old 05-24-2010, 12:31 PM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
Question about "autodetecting" variables.

okay, so i'm trying to set up my system to read a variable and use that variable to create the name of another variable to read from. say if i wanted a weapon to calculate damage from an unusual stat such as say, accuracy. i could just put something like damagebase=accuracy in the weapon file to make things easier.

in this example, we're just going to manually set the kind of damage the weapon would be using in client.weapon_damagebase.

with this line, i can get it to put together an existing variable name:
PHP Code:
this.damagebase "client.stats_" client.weapon_damagebase
so if i send this.damagebase through to the player's chat, they'll say "client.stats_accuracy"

now the actual problem is that although i've managed to make it put that together, i cant figure out how to tell it to read from that variable since my attempts have always made this.damagebase return "client.stats_accuracy". i think my problem is that it's treating what's stored, as a string, and not actually a variable. what would i use to tell it to read from the actual client.stats_accuracy variable in this manner?
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote