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

I need help with a monitor text

Started by dennissie48, 28 July 2014 - 12:39 AM
dennissie48 #1
Posted 28 July 2014 - 02:39 AM
Hello there,

I'm a big noob with computercraft and I don't realy understand all that lua stuff.

I am making a military base and i want to put a monitor (about 3x2 blocks) with a blinking tekst in the middle.

For example:

——————————————————————–
|…………………………………………………………………………|
|…………………………………………………………………………|
|…………………………….MISSILE……………………………… |
|………………………….LAUNCHED…….(blinking)………….|
|…………………………………………………………………………|
|__________________________________________|

I am realy happy if someone can make a program for me and explain how to let it start automaticly when I turn on the PC and how to put it on a monitor

Good luck!
Edited on 28 July 2014 - 10:33 AM
CCJJSax #2
Posted 28 July 2014 - 06:06 PM
I'll tell you a few basic things to get you started. (I don't have much time so it's going to be brief)

1) to make it startup when the chunk is loaded, name the program "startup".

2) to make something write to a monitor you need to do this

mon = peripheral.wrap("left") -- string side.  change to your side
mon.write("hello world") -- writes at the top left postion.
mon.setCursorPos(5, 5) -- sets monitor cursor to 5, 5
mon.setTextColor(colors.red) -- sets monitor text color to red
mon.setBackgroundColor(colors.black) -- black is default so this wont do anything, but you know how to do it now.
mon.write("Missile Launched")

basic rundown of how to do basic things. I'll help you out better later tonight if nobody else does before I get back.
Carrots084 #3
Posted 28 July 2014 - 08:33 PM
okay im going to explain the code in the above post to the best of my abilities.

mon = peripheral.wrap("left")
This wraps the monitor to the left side under the variable "mon".

mon.setCursorPos(5, 5)
This sets the text to write at the coordinates 5,5. You may have to adjust this to fit your screen.

mon.setTextColour(colours.red)
This sets your text colour to red.

mon.setBackgroundColour(colours.black)
This sets the background of the monitor to a solid black state.

mon.write("Missile Launched")
This writes Missile Launched.
Personally I would do it slightly Differently. I would add a function that centers the text on X and Y axis, and then use that to print in the middle.

Usually we aren't supposed to give code in Ask A Pro, but I'm going to explain what each part does so as to help you.

I have notes and everything in the pastebin
Just replace left with whatever side your monitor is in. This is tested :)/>
Edited on 28 July 2014 - 06:34 PM
dennissie48 #4
Posted 28 July 2014 - 09:48 PM
I'll tell you a few basic things to get you started. (I don't have much time so it's going to be brief)

1) to make it startup when the chunk is loaded, name the program "startup".

2) to make something write to a monitor you need to do this

mon = peripheral.wrap("left") -- string side.  change to your side
mon.write("hello world") -- writes at the top left postion.
mon.setCursorPos(5, 5) -- sets monitor cursor to 5, 5
mon.setTextColor(colors.red) -- sets monitor text color to red
mon.setBackgroundColor(colors.black) -- black is default so this wont do anything, but you know how to do it now.
mon.write("Missile Launched")

basic rundown of how to do basic things. I'll help you out better later tonight if nobody else does before I get back.

Thank you, but is there a way to make the text a little bit bigger and make it blink?
hilburn #5
Posted 28 July 2014 - 10:11 PM
On a monitor you have access to the following commands http://computercraft.info/wiki/Term_(API)

Yes it is possible to change the text size and to make it blink
Carrots084 #6
Posted 29 July 2014 - 12:52 AM
to make it blink? Let me edit the code for that.

http://pastebin.com/i4MhiWJX

To add blinking and bigger text:
http://pastebin.com/FEJddW85

These still have notes explaining each line. Study it as much as you need, and try making your own code for it :)/>

EDIT: You may need to change text scale to 1.5 after i tested it
Edited on 28 July 2014 - 10:56 PM
dennissie48 #7
Posted 29 July 2014 - 01:48 PM
to make it blink? Let me edit the code for that.

http://pastebin.com/i4MhiWJX

To add blinking and bigger text:
http://pastebin.com/FEJddW85

These still have notes explaining each line. Study it as much as you need, and try making your own code for it :)/>

EDIT: You may need to change text scale to 1.5 after i tested it

Uhm, when I copy this, save it and reboot my computer, I get an error message: startup:13: attempt to call nil
Why?
Carrots084 #8
Posted 29 July 2014 - 03:25 PM
to make it blink? Let me edit the code for that.

http://pastebin.com/i4MhiWJX

To add blinking and bigger text:
http://pastebin.com/FEJddW85

These still have notes explaining each line. Study it as much as you need, and try making your own code for it :)/>

EDIT: You may need to change text scale to 1.5 after i tested it

Uhm, when I copy this, save it and reboot my computer, I get an error message: startup:13: attempt to call nil
Why?
Try using "pastebin get FEJddW85 <filename>" in-game and if it still says that ill double check my code

EDIT:I think you may have forgot parentheses or quotations or incorrect camelcasing on centerText("Missile Launched"). in coding, capitalization must be exact. If its off by one letter, your code will not run.
Edited on 29 July 2014 - 01:28 PM
dennissie48 #9
Posted 29 July 2014 - 04:34 PM
to make it blink? Let me edit the code for that.

http://pastebin.com/i4MhiWJX

To add blinking and bigger text:
http://pastebin.com/FEJddW85

These still have notes explaining each line. Study it as much as you need, and try making your own code for it :)/>

EDIT: You may need to change text scale to 1.5 after i tested it

Uhm, when I copy this, save it and reboot my computer, I get an error message: startup:13: attempt to call nil
Why?
Try using "pastebin get FEJddW85 <filename>" in-game and if it still says that ill double check my code

EDIT:I think you may have forgot parentheses or quotations or incorrect camelcasing on centerText("Missile Launched"). in coding, capitalization must be exact. If its off by one letter, your code will not run.

Ok, everything works now, I made a small stupid typo
Thank you very much!