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

Gui problems!

Started by thegreatstudio, 20 March 2013 - 06:37 PM
thegreatstudio #1
Posted 20 March 2013 - 07:37 PM
I need help for my OS!! my gui is not working look at this code..

–Vars
build = 3

–Functions
function drawBackgroundDesktop(x, y)
drawBackground = paintutils.loadImage("/gliese/sysfiles/background")
paintutils.drawImage(drawBackground, x, y)

screenX, screenY = term.getSize()
while true do
term.setBackgroundColor(colors.white)
drawBackgroundDesktop(13 ,3)
paintutils.drawLine(1, 1, screenX, 1, colors.blue)
term.setTextColor(colors.black)
term.setCursorPos(1, 1)
print("[Menu]")
local event, button, x, y = os.pullEvent("mouse_click")

if event == "mouse_click" then
if x >=1 and 6 <= x then
if y == 1 then
paintutils.drawLine(1, 1, 6, 1, colors.lightGray)
paintutils.drawLine(1, 2, 8, 2, colors.lightGray)
paintutils.drawLine(1, 3, 8, 4, colors.lightGray)
paintutils.drawLine(1, 4, 8, 4, colors.lightGray)
term.setCursorPos(1, 1)
print("[Menu]")
print("Run")
print("Settings")
print("Taco")
print("Shutdown")
print("Restart")

b = false

local event, button, x, y = os.pullEvent("mouse_click")
if event == "mouse_click" then
if x >= 1 and x <= 8 then
term.setBackgroundColor(colors.white)
term.clear()
paintutils.drawLine(1, 1, screenX, 1, colors.gray)
term.setTextColor(colors.black)
term.setBackgroundColor(colors.white)
if y == 2 then – run
term.setCursorPos(1, 3)
print("Run")
cmd = read()
shell.run(cmd)

elseif y == 3 then
term.setCursorPos(1, 4)
print("Settings")

shell.run("/rom/programs/colors/paint")
elseif y == 4 then
term.setCursorPos(1, 5)
print("Taco")
shell.run("taco")

elseif y == 5 then
term.setCursorPos(1, 6)
print("Shutdown")
os.shutdown()

elseif y == 6 then
term.setCursorPos(1, 7)
print("Restart")
os.reboot()
end
end
end
end
end
end
end
end

Help ME!! PLEASE
Doyle3694 #2
Posted 20 March 2013 - 09:01 PM
Indent and put it up on pastebin. This is unreadable.
Xkonti #3
Posted 20 March 2013 - 09:07 PM
I think you need end after function drawBackgroundDesktop(x, y), before you start your while loop in which you call that function.

Spoiler

--Vars
build = 3
--Functions
function drawBackgroundDesktop(x, y)
drawBackground = paintutils.loadImage("/gliese/sysfiles/background")
paintutils.drawImage(drawBackground, x, y)
screenX, screenY = term.getSize()
end
while true do
term.setBackgroundColor(colors.white)
drawBackgroundDesktop(13 ,3)
paintutils.drawLine(1, 1, screenX, 1, colors.blue)
term.setTextColor(colors.black)
term.setCursorPos(1, 1)
print("[Menu]")
local event, button, x, y = os.pullEvent("mouse_click")
if event == "mouse_click" then
  if x >=1 and 6 <= x then
   if y == 1 then
    paintutils.drawLine(1, 1, 6, 1, colors.lightGray)
    paintutils.drawLine(1, 2, 8, 2, colors.lightGray)
    paintutils.drawLine(1, 3, 8, 4, colors.lightGray)
    paintutils.drawLine(1, 4, 8, 4, colors.lightGray)
    term.setCursorPos(1, 1)
    print("[Menu]")
    print("Run")
    print("Settings")
    print("Taco")
    print("Shutdown")
    print("Restart")
    b = false
    local event, button, x, y = os.pullEvent("mouse_click")
    if event == "mouse_click" then
	 if x >= 1 and x <= 8 then
	  term.setBackgroundColor(colors.white)
	  term.clear()
	  paintutils.drawLine(1, 1, screenX, 1, colors.gray)
	  term.setTextColor(colors.black)
	  term.setBackgroundColor(colors.white)
	  if y == 2 then -- run
	   term.setCursorPos(1, 3)
	   print("Run")
	   cmd = read()
	   shell.run(cmd)
	  elseif y == 3 then
	   term.setCursorPos(1, 4)
	   print("Settings")
	   shell.run("/rom/programs/colors/paint")
	  elseif y == 4 then
	   term.setCursorPos(1, 5)
	   print("Taco")
	   shell.run("taco")
	  elseif y == 5 then
	   term.setCursorPos(1, 6)
	   print("Shutdown")
	   os.shutdown()
	  elseif y == 6 then
	   term.setCursorPos(1, 7)
	   print("Restart")
	   os.reboot()
	  end
	 end
    end
   end
  end
end
end
TheOddByte #4
Posted 22 March 2013 - 06:09 AM
Please post the error you are getting or we can't help you out!
It makes it so much easier
remiX #5
Posted 22 March 2013 - 07:28 AM
Indent please o_O