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

Error With My Code :( Please Help!

Started by thegreatstudio, 31 August 2013 - 08:05 AM
thegreatstudio #1
Posted 31 August 2013 - 10:05 AM


function systemchooser()
term.clear()
sleep(1)
while true do
term.clear()
term.setBackgroundColor(colors.cyan)
term.clear()
paintutils.drawLine(1, 1, displayX, 1, colors.lightBlue)
term.setBackgroundColor(colors.lightBlue)
term.setTextColor(colors.black)
term.setCursorPos(46, 1)
print("Build version "..build)
term.setBackgroundColor(colors.lightBlue)
term.setTextColor(colors.black)
term.setCursorPos(1,1)
print("System Chooser")
term.setBackgroundColor(colors.lightBlue)
term.setTextColor(colors.black)
term.setCursorPos(1, 3)
print("Restart PC")
term.setBackgroundColor(colors.lightBlue)
term.setTextColor(colors.black)
term.setCursorPos(1,4)
print("Shutdown PC")
term.setBackgroundColor(colors.lightBlue)
term.setTextColor(colors.black)
term.setCursorPos(1,5)
print("[Exit]")
local event, button, X, Y = os.pullEvent("mouse_click")
if event == "mouse_click" then
if X >= 1 and X <= 20 and Y == 3 and button == 1 then
  term.clear()
  term.setBackgroundColor(colors.black)
  term.clear()
  term.setTextColor(colors.white)
  print("Armian OS version 7.1")
  print(" ")
  print(" ")
  print("System will restart! Saving your work!")
  sleep(1.5)
  os.reboot()
elseif X >= 1 and X <= 19 and Y == 4 and button == 1 then
  term.clear()
  term.setBackgroundColor(colors.black)
  term.clear()
  term.setTextColor(colors.white)
  print("Armian OS version 7.1")
  print(" ")
  print(" ")
  print("System will shutdown! Saving your work!")
  sleep(1.5)
  os.shutdown()
elseif X >= 1 and X <= 18 and Y == 5 and button == 1 then
  break
end
end
end
end
build = "7.1"
osname = "Armian OS Lua Edition"
author = "Arman Ian Isaac A. Sapelino"
code_name = "Universal XII"
displayX, displayY = term.getSize()
term.clear()
sleep(0)
while true do
term.clear()
term.setBackgroundColor(colors.cyan)
term.clear()
paintutils.drawLine(1, 1, displayX, 1, colors.lightBlue)
term.setCursorPos(46,1)
print("Build version "..build)
term.setCursorPos(1,1)
print("[Armian OS]")
local event, button, X, Y = os.pullEvent("mouse_click")
if event == "mouse_click" then
  if X >= 1 and X <= 10 and Y == 1 and button == 1 then
	paintutils.drawLine(1, 1, 9, 1, colors.gray)
	paintutils.drawLine(1, 2, 15, 2, colors.gray)
	paintutils.drawLine(1, 3, 15, 3, colors.gray)
	paintutils.drawLine(1, 4, 15, 4, colors.gray)
	term.setCursorPos(1,1)
	print("[Armian OS]")
	print("[Applications]")
	print("Run")
	print("[System Chooser]")
b = false
local event, button, X, Y = os.pullEvent("mouse_click")
if event == "mouse_click" then
  if X >= 1 and X <= 6 then
	term.setBackgroundColor(colors.cyan)
	term.clear()
	paintutils.drawLine(1, 1, screenX, 1, colors.lightBlue)
	term.setCursorPos(1,1)
	term.setTextColor(colors.black)
  if Y == 2 then
	shell.run("/system/program.apx")
  elseif Y == 3 then
	print("Run")
	input = read()
	shell.run(input)
  elseif Y == 4 then
	systemchooser()
end
end
end
end
end
end


The error said: paintutils:45: bad argument: double expected, got nil
LBPHacker #2
Posted 31 August 2013 - 10:08 AM
Line 94: screenX is never defined
kreezxil #3
Posted 31 August 2013 - 10:27 AM
Line 94: screenX is never defined
I agree, he should change screenX to displayX and the program will work. I tested that and it did work afterwards.

Something to keep in mind when copying other peoples codes and trying to make it your own, if you decide to change variable names and function names make sure they are changed throughout the entire code structure to the new names.
thegreatstudio #4
Posted 31 August 2013 - 10:57 AM
wow thanks :D/>