lua - How do I access a variable in a elseif statement -
--if statement elseif line:match("^if") local v, e, c, v2 = line:match("^if (.+) = (.+) > (.+) > (.+)") if vars[v] == e if c == "print" print(v2) elseif c == "run" if funcs[v2] if funcs[v2] == "print" print("hi") end end end end --functions elseif line:match("^func") local n, c, o = line:match("^func (.+) > (.+) > (.+)") funcs[n] = c end
this code used programming language im developing , im having troubles running functions
while code there works, there 1 problem... want print off var "o" set in elseif statement under "--functions", detecting want print in function dont know how access variable o in different elseif statement, because in "--if statement" area looking see if code in file looks similar if var = 1 > run > functionname
, code in file function looks func functionname > print > hello
works , dev purposes made print off "hi" detecting in function want print but, in section ("--function") have variable called o, supposed printed off, hope explaned , hope guys understand, , in advance
ok fixed self after posted messing around
so create variable called fcom (function command) in "--functions" section set fcom equal o , have made multiple functions test out , work
this new code:
--if statement elseif line:match("^if") local v, e, c, v2 = line:match("^if (.+) = (.+) > (.+) > (.+)") if vars[v] == e if c == "print" print(v2) elseif c == "run" if funcs[v2] if funcs[v2] == "print" --[[ edited --]] print(fcom) end end end end --functions elseif line:match("^func") local n, c, o = line:match("^func (.+) > (.+) > (.+)") funcs[n] = c --[[ edited --]] fcom = o end
Comments
Post a Comment