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

Simple Scrolling Program

Started by urawr, 29 August 2013 - 09:51 AM
urawr #1
Posted 29 August 2013 - 11:51 AM
I would like to have a program which scrolls the words "Tickets Here!" in black font over a white background, with a font size that can be seen well, but isn't too big for the screen (because scale 1 won't cut it). The screen itself is three advanced monitors, connected horizontally. I would like the text to scroll off screen, with a delay of a second or so before you see it scroll again. ..You can edit this time if you want if you think a better delay time would be nicer.

I know enough about computercraft to do nearly everything above except for timing the scrolling.
Lyqyd #2
Posted 29 August 2013 - 12:35 PM
Please post your current code.
urawr #3
Posted 29 August 2013 - 12:54 PM
I would rather "borrow" a code from here, since I'm sure 90%+ of the people here could do it to my simple preferences above in a minute flat. The way I did it was messy, so I would much prefer cleaner code since I'm a bit of a perfectionist.
Lyqyd #4
Posted 29 August 2013 - 02:02 PM
We don't do that in Ask a Pro. Moved to General.
theoriginalbit #5
Posted 29 August 2013 - 03:52 PM
I'm in an exceptionally giving mood today, so I made this for you. However because I like to go above and beyond, I've added quite a few features…

Features
Spoiler
  • Multiple monitor support
  • Multi-sized monitor support (each monitor displays the scroll appropriate for it's size)
  • Determines best scale for each monitor
  • Automatically detects all connected monitors (including networked peripherals)
  • If a monitor is resized will check if it can resize the text (may cause monitors to pause scrolling for a second or so)
  • Detects when new monitors are attached to computer or network (may cause monitors to pause scrolling for a second or so)
  • Detects removal of monitors on computer or network (may cause monitors to pause scrolling for a second or so)
  • Can change the speed at which the text moves (`moveFreq` variable at the top)
  • Can change the text displayed on the monitors (`msg` variable at the top)
  • Text is black on white background on all monitors

Code
SpoilerUncommented (Deployment)
Commented (For Your Learning)

Screenshot
Spoiler

EDIT: Forgot a feature you requested, just added it
EDIT 2: Adding updated screenshot
Edited on 29 August 2013 - 02:25 PM
urawr #6
Posted 29 August 2013 - 03:55 PM

local monitorSide = "left"
local pos = 6						   --I don't know what number this should be
local ts = 2
local TextScale(ts)					 --Setting it to a unvaraibled number vaule (like 2, using brackets or an equal sign) gives me a nil value error for some reason

mon = peripheral.wrap(monitorSide)
term.setBackgroundColor (colors.white)
term.setTextColor (colors.black)
term.clear()
										--Deleted the part of the code involved in scrolling because if was an incorrect infinite loop.
theoriginalbit #7
Posted 29 August 2013 - 04:00 PM
-snip-
Make sure you read the commented version of my program! It will really help you with your programming!
urawr #8
Posted 29 August 2013 - 05:44 PM
[macro]Thank you[/macro]

I understand it better now, but much of what you posted was too much for me (such as adding monitors even though I'm only using a 3x1x1 advanced monitor in a small area above a doorway.) :)/> (You really didn't have to go all out, since the aim was for a simple go-right-and-loop sign. :P/>)

I had to set the starting cursor position at one pos. beyond the length of the monitor (from the right) so it would start off screen, and set the left-most value at a pos where the sentence goes completely off screen heading left. After that, I just set the loop-back value to the right-most pos, so it wold loop. I think i am still having trouble with the scale size, even though I used term.TextScale.
theoriginalbit #9
Posted 30 August 2013 - 02:15 AM
I think i am still having trouble with the scale size, even though I used term.TextScale.
There is no `term.TextScale` … it is a function that is on the monitor object, and it is `[monitorObj].setTextScale( [scale] )` where [monitorObj] the the peripheral.wrap of the monitor, and [scale] is the scale you wish to set.
urawr #10
Posted 30 August 2013 - 01:35 PM
I think i am still having trouble with the scale size, even though I used term.TextScale.
There is no `term.TextScale` … it is a function that is on the monitor object, and it is `[monitorObj].setTextScale( [scale] )` where [monitorObj] the the peripheral.wrap of the monitor, and [scale] is the scale you wish to set.

Thanks again. I didn't think using …peripheral.wrap("<side>").setTextScale(<scale>) was going to work initially due to the fact that I clearly didn't know it had to be used together.