Jump to content




[Lua] [Error] Please help


  • You cannot reply to this topic
10 replies to this topic

#1 mibac138

  • Members
  • 132 posts
  • LocationPoland

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 Lyqyd, 18 November 2012 - 01:01 PM.
Change quote tags to code tags


#2 Doyle3694

  • Members
  • 815 posts

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

#3 mibac138

  • Members
  • 132 posts
  • LocationPoland

Posted 18 November 2012 - 12:47 PM

Still not working writing error:

bit:40: bad argument: number expected, got string

#4 Doyle3694

  • Members
  • 815 posts

Posted 18 November 2012 - 12:51 PM

is this the full code?

#5 Doyle3694

  • Members
  • 815 posts

Posted 18 November 2012 - 12:53 PM

change your colors.test() to rs.getBundledInput()

#6 mibac138

  • Members
  • 132 posts
  • LocationPoland

Posted 18 November 2012 - 12:53 PM

yes, but I'm programming still this code added:

Quote

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


#7 mibac138

  • Members
  • 132 posts
  • LocationPoland

Posted 18 November 2012 - 12:56 PM

Now it's writing:

bios:206: [string "startup"]:32: '<eof>' expected

#8 mibac138

  • Members
  • 132 posts
  • LocationPoland

Posted 18 November 2012 - 12:57 PM

Working! :D/> thanks a lot (i'm from Poland i'm not good at english :)/> )

#9 mibac138

  • Members
  • 132 posts
  • LocationPoland

Posted 18 November 2012 - 12:59 PM

How to do Automatic update?

#10 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 18 November 2012 - 01:06 PM

http://www.computerc...erating-system/

A nice tutorial for creating an automatic updater. ^^

#11 Doyle3694

  • Members
  • 815 posts

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






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users