Saturday, 15 August 2015

lua - How do I turn a string into an argument? -


I'm using App TouchLua.

I argue with a logic from a table that this is the only way I want to table.

  b = {} b [1] = "010,010, draw.blue" function drawn for drawButtons () i = 1,2. File (tunbombar (string.sub (b [i], 1,3), tonerbar (string. Sub (b [i], 5,7), tonbar (string sub. (B [i], 1,3 ); +10, tonbar (string.sub (b [i], 5,7), string. Sub (b [i], 9)) and end draw buttons ()  

eval that print (eval ("draw.blue")) broadly print (draw.blue) , there is a quick and dirty version here:

  local function eval (s, e) come back (load ("return "..s," = Eval "," t ", e or _g)) () end-global variables Dignity = {blue = 2} print (eval ("draw.blue"))  

If you are using the older Lea version compared to 5.2, You will need to call loadstring and an additional setfenv instead of load . Of course, using load Instead, you can parse the string s and manually list the table e or _g .

The above code assumes that draw is a global variable. If you want the code to work with local variables, then you have to use the debug library:

  - Local local local local = {blue = 3} for print (localdraw.blue) - - Debugging is required, so will not work with the stripped biodecode! Local work is local (local) T, I, N, V ​​= {}, 1, debug.Titocolal (2, 1) while N ~ = zero T [n], I = V, I + 1N, V = debug. Getlocal (2, i) end return t end print (eval ("localdraw.blue", local ()))  

No comments:

Post a Comment