This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ETHANATOR360's profile picture

[lua] [question] is there a way to go to a certain line in lua

Started by ETHANATOR360, 14 July 2012 - 03:49 PM
ETHANATOR360 #1
Posted 14 July 2012 - 05:49 PM
i am trying to make an OS but i want to know if there is a way to go to a certain line like the GOTO command in BASIC so i can simply cut back to the main menu of the OS
MysticT #2
Posted 14 July 2012 - 06:20 PM
GOTO?? No please! :P/>/>

Use if, elseif and else:

if <condition> then
  -- code
end

if <condition> then
  -- code
else
  -- code
end

if <condition> then
  -- code
elseif <condition2> then
  -- code
end
And functions:

local function doSomething()
  -- code
end

doSomething()
ETHANATOR360 #3
Posted 15 July 2012 - 02:58 AM
ok thanks for the help and this OS was inspired by yours :P/>/>