91 posts
Posted 21 January 2013 - 06:20 PM
I need help how do i make a print program for a screen with a diff backround color it needs to start on startup
like this but color and on a screen
print( [[To-Do List
1.Get boxite
2.Finish strip mine
3.Get redstone]] )
barkround white
2088 posts
Location
South Africa
Posted 21 January 2013 - 06:24 PM
term.setTextColour(colours.black) -- to set the colour of the text
term.setBackgroundColour(colours.white) -- to set the colour of the background
term.clear() -- to clear the screen so the screen will become whit
term.setCursorPos(1, 1) -- reset the cursor
print([[
1. Get boxite
2. Finish strip mine
3. Get redstone]])
91 posts
Posted 21 January 2013 - 06:26 PM
That is vary help full but in the first line isnt it Colors?
and how do i get it to print on my monitor?
48 posts
Location
Colorado, USA
Posted 21 January 2013 - 06:42 PM
You could just wrap the monitor and replace "term" with the variable (That's how I do it anyway)
so something like this
mon = peripheral.wrap("<side of monitor>")
mon.setTextColour(colours.black) -- to set the colour of the text
mon.setBackgroundColour(colours.white) -- to set the colour of the background
mon.clear() -- to clear the screen so the screen will become white
mon.setCursorPos(1, 1) -- reset the cursor
print([[
1. Get boxite
2. Finish strip mine
3. Get redstone]])
and the other part of your question…I assume you mean Color vs. Colour? Either way works.
91 posts
Posted 21 January 2013 - 07:01 PM
where in the code does it say desplay on back monitor because i really do want to learn
thx if you can respond
2088 posts
Location
South Africa
Posted 21 January 2013 - 07:09 PM
I'd suggest you look into the peripheral api. The first thing you do is wrap the monitor.
Monitor = peripheral.wrap("right") -- where the monitor is on the right of the computer.
Now you can use the monitor as if it was term.function. Instead of usimg term, you use monitor.
-- so like this in the above code
Monitor.setBackgroundColour(colours.white)
Monitor.setTextColour(coliurs.black)
Monitor.clear()
-- monitors only have a write function so printing is not allowed so eaxh new line you will need to reset cursor pos. Or try this
Monitor.write([[
Txt
Text
Text]])
Typed this on my phone… Was quite difficult
7508 posts
Location
Australia
Posted 21 January 2013 - 07:11 PM
You could just wrap the monitor and replace "term" with the variable
Or you could do this
local mon = peripheral.wrap("left")
term.redirect(mon)
-- anything with term API or print and write will now go to the monitor
term.restore()
-- now everything is back on the computer
Using this method you can use print… :)/>
48 posts
Location
Colorado, USA
Posted 21 January 2013 - 07:11 PM
in the wrap at the top. Where I wrote
mon = peripheral.wrap("<side of monitor>")
just replace the <side of monitor> with back. That will tell the computer the monitor is on the back.
I missed the bottom of the code, but you could just edit to write instead of print.
You can use any of these
http://computercraft.../wiki/Term_(API) just replace the "term" with "mon".
There is probably a more efficient way that editing each line to "mon.write()" but that's how I know how to do it.
mon = peripheral.wrap("back")
mon.setTextColour(colours.black) -- to set the colour of the text
mon.setBackgroundColour(colours.white) -- to set the colour of the background
mon.clear() -- to clear the screen so the screen will become white
mon.setCursorPos(1, 1) -- line 1
mon.write("1. Get boxite")
mon.setCursorPos(1,2) --line 2 (might have the 1&2 backwards:P)
mon.write("2. Finish strip mine")
mon.setCursorPos(1,3) --line 3
mon.write("3. Get redstone")
Ninja'd with 2 great suggestions. I'd listen to them:)
91 posts
Posted 21 January 2013 - 07:12 PM
do i need the [cocde] in [cocde]Monitor = peripheral.wrap("right")
48 posts
Location
Colorado, USA
Posted 21 January 2013 - 07:15 PM
No, that was the code tag for the forum, but since he wrote it on his phone, he typo'd.
Just start at "Monitor"
Also, ignore the at the bottom
2088 posts
Location
South Africa
Posted 21 January 2013 - 07:15 PM
No, sorry. That was atypo of 'code' for the code tags. And I cant edit my post on my phone… Fail.
91 posts
Posted 21 January 2013 - 07:18 PM
Monitor = peripheral.wrap("right")so do i need to do peripheral.wrap("back") or is there shorter than peripheral because i will forget how to spell that
7508 posts
Location
Australia
Posted 21 January 2013 - 07:19 PM
No, sorry. That was atypo of 'code' for the code tags. And I cant edit my post on my phone… Fail.
Really? I can what kind of phone u got? Touchscreen? Tap on the post and it should give you edit and quote…
48 posts
Location
Colorado, USA
Posted 21 January 2013 - 07:20 PM
Monitor = peripheral.wrap("right")so do i need to do peripheral.wrap("back") or is there shorter than peripheral because i will forget how to spell that
Yea, do peripheral.wrap("back").
Don't think there is a way to shorten it.
7508 posts
Location
Australia
Posted 21 January 2013 - 07:24 PM
Don't think there is a way to shorten it.
You are correct, there is no shorter way like there is with redstone… :/
91 posts
Posted 21 January 2013 - 08:21 PM
2 things i tryed it it doesnt work it stays on one line and 2 its small
http://pastebin.com/Teafh1K2
48 posts
Location
Colorado, USA
Posted 21 January 2013 - 08:29 PM
try this code
mon = peripheral.wrap("back")
mon.setTextColor(colors.blue)
mon.setBackgroundColor(colous.white)
mon.setTextScale(2) --can be 1-5
mon.clear()
mon.setCursorPos(5,1)
mon.write("FuzzyCorp todo list")
mon.setCursorPos(1,2)
mon.write("1.----- 2.----- 3. -----")
mon.setCursorPos(1,3)
mon.write("4. ----- 5. ----- 6. -----")
From there, you'd have to set your cursor position and write each line individually, but it should work.
You'll probably have to adjust the cursor positions here, I just guessed lol
EDIT* Realized I had quotes around the text scale 2, if you've copied already, get rid of those. it's fixed now though.
91 posts
Posted 21 January 2013 - 08:43 PM
error like :4: number expected
48 posts
Location
Colorado, USA
Posted 21 January 2013 - 08:47 PM
oops, add colors instead of colous…typo
91 posts
Posted 21 January 2013 - 08:52 PM
i fixed that but line 4 text Size thing it said number expected
48 posts
Location
Colorado, USA
Posted 21 January 2013 - 08:54 PM
I rewrote the code using TheOriginalBIT's suggestion. I tested it for you and I know it was working for me at least.
Let me know if there are any errors.
local mon = peripheral.wrap("back")
term.redirect(mon)
mon.setTextScale(2)
mon.setTextColor(colors.blue)
mon.setBackgroundColor(colors.white)
mon.clear()
mon.setCursorPos(1, 1)
print([[
FuzzyCorp ToDo List
1. ----- 2. ----- 3. -----
4. ----- 5. ----- 6. -----
7. ----- 8. ----- 9. -----
10. ----- 11. ----- 12. -----
]])
term.restore()
This way, it's all in "print" and should be easier to edit/add more later on if you need to.
2088 posts
Location
South Africa
Posted 21 January 2013 - 09:47 PM
No, sorry. That was atypo of 'code' for the code tags. And I cant edit my post on my phone… Fail.
Really? I can what kind of phone u got? Touchscreen? Tap on the post and it should give you edit and quote…
Lmao. Shot for that xD I never knew about that xD only started using mobile theme recently xD
7508 posts
Location
Australia
Posted 21 January 2013 - 10:47 PM
I rewrote the code using TheOriginalBIT's suggestion. I tested it for you and I know it was working for me at least.
Let me know if there are any errors.
local mon = peripheral.wrap("back")
term.redirect(mon)
mon.setTextScale(2)
mon.setTextColor(colors.blue)
mon.setBackgroundColor(colors.white)
mon.clear()
mon.setCursorPos(1, 1)
print([[
FuzzyCorp ToDo List
1. ----- 2. ----- 3. -----
4. ----- 5. ----- 6. -----
7. ----- 8. ----- 9. -----
10. ----- 11. ----- 12. -----
]])
term.restore()
This way, it's all in "print" and should be easier to edit/add more later on if you need to.
For the record… It's not actually the way I suggested, you still have all the mon.'s … By redirecting the terminal you remove the need to use the mon object, and it also allows you to use the normal print and write on the monitor too…
48 posts
Location
Colorado, USA
Posted 21 January 2013 - 10:52 PM
I tried it with term.'s there, but I was getting an attempt to call nil. I changed it to mon. and it stopped throwing up that error.
7508 posts
Location
Australia
Posted 21 January 2013 - 11:20 PM
I tried it with term.'s there, but I was getting an attempt to call nil. I changed it to mon. and it stopped throwing up that error.
Only textScale needs to be mon as term doesn't have that function. The rest can be term…
2005 posts
Posted 21 January 2013 - 11:26 PM
Yeah, but is there any advantage once you've gone ahead and wrapped the monitor?
48 posts
Location
Colorado, USA
Posted 21 January 2013 - 11:34 PM
I think for simplicity's sake, it all works the same, and it seems to look more organized this way. It's also a little easier to understand for someone new to Lua and the API's from ComputerCraft. I haven't used most of these commands myself (before this), but I understand they are all going to the monitor. With the redirect, I now know that you can print to a monitor, which is very nice. I like how this one looks how it is.
7508 posts
Location
Australia
Posted 21 January 2013 - 11:51 PM
Yeah, but is there any advantage once you've gone ahead and wrapped the monitor?
print… or making having one function that can work on the computer but optionally go to a monitor if a param is passed in or something like that…
2005 posts
Posted 22 January 2013 - 08:18 AM
Yeah, but you've got that from the term.redirect(mon) already. Though I guess that making the setTextScale method optional is a good idea, so that the program can be used without a monitor.