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

[Lua] [Error] Please help

Started by mibac138, 18 November 2012 - 11:39 AM
mibac138 #1
Posted 18 November 2012 - 12:39 PM
what is wrong in this code?


mon = peripheral.wrap("back")


mon.setTextScale(2)

if colors.test(front, colors.lime) == true then
	mon.setCursorPos(1,1)
	mon.clearLine(1)
	mon.write("Power Level: 100%")
   elseif colors.test(front, colors.yellow) == true then
	mon.setCursorPos(1,1)
	mon.clearLine(1)
	mon.write("Power Level: 75%")
   elseif colors.test(front, colors.lightBlue) == true then
	mon.setCursorPos(1,1)
	mon.clearLine(1)
	mon.write("Power Level: 50%")
   elseif colors.test(front, colors.magneta) == true then
	mon.setCursorPos(1,1)
	mon.clearLine(1)
	mon.write("Power Level: 25%")
   else
	mon.setCursorPos(1,1)
	mon.clearLine(1)
	mon.write("Power Level: 0%")
end
Edited by
Doyle3694 #2
Posted 18 November 2012 - 12:44 PM
colors.test(front, colors.magneta)

front should be in quotes " "

mon.clearLine(1)

should not have any arguments, it clears the current line the cursor is on
mibac138 #3
Posted 18 November 2012 - 12:47 PM
Still not working writing error:

bit:40: bad argument: number expected, got string
Doyle3694 #4
Posted 18 November 2012 - 12:51 PM
is this the full code?
Doyle3694 #5
Posted 18 November 2012 - 12:53 PM
change your colors.test() to rs.getBundledInput()
mibac138 #6
Posted 18 November 2012 - 12:53 PM
yes, but I'm programming still this code added:

if colors.test("front", colors.white) == true then
mon.setCursorPos(1,2)
mon.clearLine()
mon.write("Quarry: Off")
else
mon.setCursorPos(1,2)
mon.clearLine()
mon.write("Quarry: On")
end
mibac138 #7
Posted 18 November 2012 - 12:56 PM
Now it's writing:

bios:206: [string "startup"]:32: '<eof>' expected
mibac138 #8
Posted 18 November 2012 - 12:57 PM
Working! :D/>/> thanks a lot (i'm from Poland i'm not good at english :)/>/> )
mibac138 #9
Posted 18 November 2012 - 12:59 PM
How to do Automatic update?
Kingdaro #10
Posted 18 November 2012 - 01:06 PM
http://www.computercraft.info/forums2/index.php?/topic/5067-tutorial-making-an-updater-for-your-operating-system/

A nice tutorial for creating an automatic updater. ^^
Doyle3694 #11
Posted 18 November 2012 - 01:31 PM
If you mean that you want it to update the current power, then you can use
while true do
--code
sleep(0) -- This is so the program yields, otherwise it can get canceled because it havent yielded for 10 seconds
end