Jump to content




trying to learn - monitor


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

#1 Dustmuz

  • Members
  • 174 posts
  • LocationDenmark

Posted 11 September 2014 - 11:52 AM

Hello fellow crafters :D

i'm trying to learn this lua on my own a bit, and taking by error and trial.

i've gotten as far as monitors and playing a bit with them
im trying to write a program that
1: wraps the monitor to the right (Done - works)
2: sets the background color to blue (cant get it to work, did it in another program, and copied the line from that program)
3: finds the monitor and writes on the monitor, which side it is located (Done works)
4: finds the monitors height and width and writes it onscree (Done works)

Entire code so far, including the notes i made myself


-- wrapping monitor, clearing it and setting cursor pos to top left
local monitor = peripheral.wrap("right")
monitor.setBackgroundColor(colors.Blue) --this line i cant get to work
monitor.clear()
monitor.setCursorPos(1,1)

-- write on the monitor, which side of the computer it is
local sides = { "top", "bottom", "left", "right", "front", "back" }

monitor.write("Finding monitors...")
monitor.setCursorPos(1,2)
for i = 1, #sides do
if peripheral.isPresent(sides[i]) then
if peripheral.getType(sides[i]) == "monitor" then
monitor.write("Fundet: "..sides[i])
end
end
end

-- Writing to screen how big it is
local widthA, heightA = monitor.getSize()

monitor.setCursorPos(1,1)
monitor.write("hvor stor er den")

monitor.setCursorPos(1,3)
monitor.write("vandret = "..widthA)

monitor.setCursorPos(1,4)
monitor.write("lodret = "..heightA)

-- clears screen after 10 seconds
sleep(10)
monitor.clear()

Edited by Dustmuz, 11 September 2014 - 11:55 AM.


#2 Lignum

  • Members
  • 558 posts

Posted 11 September 2014 - 12:16 PM

Lua is case sensitive. It should be colours.blue, not colours.Blue.

#3 Dustmuz

  • Members
  • 174 posts
  • LocationDenmark

Posted 11 September 2014 - 12:29 PM

View PostLignum, on 11 September 2014 - 12:16 PM, said:

Lua is case sensitive. It should be colours.blue, not colours.Blue.

Doh.. hehe.. didn't see that tiny mistake..

thanks alot for that :)
have been staring at this for the past 2 hours, trying to figure out what i did wrong :D
and then it was such a tiny thing.. whoops :D

#4 Lignum

  • Members
  • 558 posts

Posted 11 September 2014 - 01:41 PM

You're welcome! It's always the tiny things that break everything.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users