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

error in gui!

Started by thegreatstudio, 07 July 2013 - 07:12 AM
thegreatstudio #1
Posted 07 July 2013 - 09:12 AM
Welll the gui doesn't work

build = "4.2"
desktop = "gnome"
screenX, screenY = term.getSize()
print("Setting up the API")
sleep(2)
while true do
term.clear()
term.setBackgroundColor(colors.cyan)
term.clear()
paintutils.drawLine(1, 1, screenX, 1, colors.black)
term.setCursorPos(2, 1)
term.setTextColor(colors.white)
print("(Activities)")
term.setCursorPos(42, 1)
term.setTextColor(colors.white)
print("(Shutdown)")
local event, button, X, Y = os.pullEvent("mouse_click")
if event == "mouse_click" then
if X >= 2 and X <= 10 and Y == 1 and button == 1 then
shell.run("active")
elseif X >= 42 and X <= 20 and Y == 1 and button == 1 then
break
end
end
end
well.
thegreatstudio #2
Posted 07 July 2013 - 09:18 AM
no loop to break?
Engineer #3
Posted 07 July 2013 - 09:26 AM
It will only trigger when the x is bigger than 42 and smaller than 20. Impossible.
thegreatstudio #4
Posted 07 July 2013 - 09:59 AM

function active.lua()
term.clear()
term.setBackgroundColor(colors.cyan)
term.clear()
paintutils.drawLine(1, 1, screenX, 1, colors.black)
term.setCursorPos(1, 1)
term.setTextColor(colors.white)
print("[<---]")
term.setCursorPos(1, 2)
term.setTextColor(colors.white)
print("[File Browser *]")
local event, button, X, Y = os.pullEvent("mouse_click")
if event == "mouse_click" then
if X >= 1 and X <= 20 and Y == 1 and button == 1 then
break
end
end
end
build = "4.2"
desktop = "gnome"
screenX, screenY = term.getSize()
print("Setting up the API")
sleep(2)
while true do
term.clear()
term.setBackgroundColor(colors.cyan)
term.clear()
paintutils.drawLine(1, 1, screenX, 1, colors.black)
term.setCursorPos(1, 1)
term.setTextColor(colors.white)
print("(Activities)")
term.setCursorPos(42, 1)
term.setTextColor(colors.white)
print("(Shutdown)")
local event, button, X, Y = os.pullEvent("mouse_click")
if event == "mouse_click" then
if X >= 1 and X <= 30 and Y == 1 and button == 1 then
active.lua()
elseif X >= 42 and X <= 60 and Y == 1 and button == 1 then
os.shutdown()
end
end
end

This is the one that has errors and i have update the code in the upside.

ERROR: No loop to break
TheOddByte #5
Posted 07 July 2013 - 10:29 AM
You have the break above the loop and in a function where there isn't a loop going on..


For example

evt, p1 = os.pullEvent()
if evt == "key" then 
break
end
while true do
-- Do Stuff
end
Will error..

But this won't


bRunning = true

evt = os.pullEvent()
if evt == "key" then
bRunning = false
end

while bRunning do
-- Do Stuff
end