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

Monitor Help

Started by darkreaper_44, 15 November 2012 - 03:38 PM
darkreaper_44 #1
Posted 15 November 2012 - 04:38 PM
OK im not going to lie, i feel like an absolute idiot lol.

I have seen a few videos and such, and i cant seem to write a program for text to show on the monitor.
Im trying to make a rule list for the server spawn and i cannot get it to work.

here is what i had:


mon = peripheral.wrap("right")
mon.clear()
mon.setTextScale(3)
mon.setCursorPos(3)
mon.write("Rules")
mon.write("1: No greifing ")



thats what i have and it doesnt work

[Added code tags. -L]
Kryptanyte #2
Posted 15 November 2012 - 04:43 PM
First off setting the cursor position requires two numbers not one. its done

term.setCursorPos(x, y)
or in this case
mon.setCursorPos(x, y)

Im not actually on Minecraft at the moment so I cannot test this at the moment. Can you be more specific when you say it doesnt work. like does it give you an error or just stop the program?
darkreaper_44 #3
Posted 15 November 2012 - 04:53 PM
ok give me one sec ill go look
darkreaper_44 #4
Posted 15 November 2012 - 04:56 PM
it says:

rules:2: attempt to index ? (a nil value)

and atm what i have written exactly is:

mon = peripheral.wrap("right")
mon.clear()
mon.setTextScale(3)
mon.write("Rules")
Kryptanyte #5
Posted 15 November 2012 - 05:02 PM
Im not able to test this at the moment but as far as I can see theres something wrong with your clearing function. Are you sure theres a monitor on the right side?
darkreaper_44 #6
Posted 15 November 2012 - 05:04 PM
wait does the wrap need to have the direction of the monitor? because my monitor is on the back :/
Kryptanyte #7
Posted 15 November 2012 - 05:06 PM
Yes. Thats the issue you are having. you need to do mon = peripheral.wrap( "back" )
darkreaper_44 #8
Posted 15 November 2012 - 05:16 PM
ok so i did it and it worked, but now that i added all the rules, it is not working
all i did was add more mon.write("") and added rules below the "Rule" one u seen
Kryptanyte #9
Posted 15 November 2012 - 05:21 PM
Please be more specific.
darkreaper_44 #10
Posted 15 November 2012 - 05:40 PM
ok so like before but now it reads

mon = peripheral.wrap("right")
mon.clear()
mon.setTextScale(3)
mon.write("Rules")
mon.setTextScale(1)
mon.write("1: No Greifing")
mon.write("2: PvP is on but no mass murdering")
mon.write("If you have an issue tell admin not owner")
mon.write("No advertising")
mon.write("To get out say "I like food" ")
mon.write("")
mon.write("")
mon.write("")
mon.write("")

it says on monitor

bios:206: [string "rules"]:10: ')' expected
Kryptanyte #11
Posted 15 November 2012 - 05:43 PM
Theres two "s on line 10. Before you post can you please look at the error message. Theres usually a number and the name of the program thats tells you where the error is.
darkreaper_44 #12
Posted 15 November 2012 - 05:46 PM
ok friend that worked.

i got rid of the double comma but um
it is displaying it ALL on one line or trying to
dissy #13
Posted 15 November 2012 - 05:56 PM
Try it as:

write([[Rules:
#1 - blah
#2 blah
etc…
]])
BigSHinyToys #14
Posted 15 November 2012 - 06:02 PM
ok friend that worked.

i got rid of the double comma but um
it is displaying it ALL on one line or trying to
put a mon.setCursorPos() between each mon.write()
darkreaper_44 #15
Posted 15 November 2012 - 08:35 PM
still dont work :/
Kryptanyte #16
Posted 15 November 2012 - 08:53 PM
Try this


local y = 1
mon = peripheral.wrap("right")
mon.clear()
mon.setTextScale(3)
mon.setCursorPos(1, y)
y = y + 1
mon.write("Rules")
mon.setTextScale(1)
mon.setCursorPos(1, y)
y = y + 1
mon.write("1: No Greifing")
mon.setCursorPos(1, y)
y = y + 1
mon.write("2: PvP is on but no mass murdering")
mon.setCursorPos(1, y)
y = y + 1
mon.write("If you have an issue tell admin not owner")
mon.setCursorPos(1, y)
y = y + 1
mon.write("No advertising")
mon.setCursorPos(1, y)
y = y + 1
mon.write("To get out say; I like food ")
mon.setCursorPos(1, y)
y = y + 1
mon.write("")
mon.setCursorPos(1, y)
y = y + 1
mon.write("")
mon.setCursorPos(1, y)
y = y + 1
mon.write("")
mon.setCursorPos(1, y)
y = y + 1
mon.write("")
dissy #17
Posted 15 November 2012 - 08:58 PM
You have a line that will throw an error, instead
Change this:
mon.write("To get out say "I like food" ")

To this:
mon.write("To get out say 'I like food' ")
Kryptanyte #18
Posted 15 November 2012 - 09:03 PM
I copied the code directly from the above code and didn't fix the error I noticed before. Thanks I'll change that
BigSHinyToys #19
Posted 15 November 2012 - 09:07 PM
This is much better
Spoiler

local function openDevice(sType)
    for i,v in pairs(rs.getSides()) do
	    if peripheral.isPresent(v) and peripheral.getType(v) == sType then
		    return peripheral.wrap(v),v
	    end
    end
end
local mon = openDevice("monitor")
-- add your lines to tList bellow
local tList = {
"item 1 ",
"item 2 ",
"item 3 "
}
if mon then
    mon.setTextScale(3)
    mon.clear()
    for i = 1,#tList do
	    mon.setCursorPos(1,i)
	    mon.write(tList[i])
    end
else
    print("NO monitor")
end
Kryptanyte #20
Posted 15 November 2012 - 09:10 PM
Or that. You could do that. I'm not one to make whole functions to double check stuff like that unless I will use it more than once on different computers….
BigSHinyToys #21
Posted 15 November 2012 - 09:15 PM
Or that. You could do that. I'm not one to make whole functions to double check stuff like that unless I will use it more than once on different computers….
well that is exactly right I use it to open WIFI and ICBM peripherals it works for most devices and makes it easer to use as the code requires no customization to work on differently set up systems.