- Joined
- Nov 17, 2010
- Messages
- 6,812
- Solutions
- 582
- Reaction score
- 5,372
I've been wracking my brain trying to figure this out.. xD
So in the source we basically have this..
in the script I have this..
How do I convert user_input into the variable name, so that I can then use it to compare against what's in the table without needing to explicitly write out a look-up table?
So in the source we basically have this..
Lua:
CONST_ME_NONE = 0
CONST_ME_DRAWBLOOD = 1
CONST_ME_LOSEENERGY = 2
in the script I have this..
Lua:
local effects = {CONST_ME_NONE, CONST_ME_DRAWBLOOD, CONST_ME_LOSEENERGY}
local user_input = "CONST_ME_NONE"
for i = 1, #effects do
if effects[i] == user_input then
-- do something
end
end
How do I convert user_input into the variable name, so that I can then use it to compare against what's in the table without needing to explicitly write out a look-up table?