Posted 19 June 2013 - 08:29 AM
had been playing with FORTH for some time, moved over to LUA not long ago and i like it much better. one probelm i have though which is holding me back is the use of functions.
could someone tell me what i am doing wrong with this code? the varable is correctly set with the key press (i confirmed this with a "print (var1)" but the function defined for the key is not executed.
i guess i am using this as a work around for not having a goto in LUA (which i know is bad programing), is the use of functions as "jump to points" bad form?
Thank you in advance for any input.
PS, i've tried executing the "If true then" section below the functions with no change in how it works.
sorry, couldn't figure out how to put it this into the code subwindow like i see in other threads, when i post this all my intdenting goes away..
could someone tell me what i am doing wrong with this code? the varable is correctly set with the key press (i confirmed this with a "print (var1)" but the function defined for the key is not executed.
i guess i am using this as a work around for not having a goto in LUA (which i know is bad programing), is the use of functions as "jump to points" bad form?
Thank you in advance for any input.
PS, i've tried executing the "If true then" section below the functions with no change in how it works.
sorry, couldn't figure out how to put it this into the code subwindow like i see in other threads, when i post this all my intdenting goes away..
if true then
print "Waiting for input:"
print "Press 1 or 2 then Enter"
var1 = read() -- wait for input
if var1 == 1 then -- if 1 is pressed run this
test1() -- jump to function test1
end
if var1 == 2 then -- if 2 is pressed run this
test2() -- jump to function test2
end
function test1()
print "function 1 succussful" -- what to do if 1 is pressed
end
function test2()
print "function 2 succussful" -- what to do if 2 is pressed
end
end
Edited by