ComputerCraft Forums

ComputerCraft => Ask a Pro => Topic started by: Yoshim3to on Jan 03, 2021, 07:55 PM

Title: Make Text Move Along a Slope? (1.12.2)
Post by: Yoshim3to on Jan 03, 2021, 07:55 PM
Just started ComputerCraft about a week or two ago, and I'm very new to coding in general.

I'm working on a project to create a DVD screensaver on a ComputerCraft monitor. Eventually I want to write a function that calculates slope when bouncing off of walls/corners, but for now I need to figure out how to make text move along a line in the first place. I assume it'll have something to do with getting the coordinates of each point on the line and writing the text using those coordinates as CursorPos, but I'm not sure how to grab that data from the line. Here's my code so far, just for drawing the line:


local monitorA = peripheral.wrap("right")
local heightA, widthA = monitorA.getSize()
print(heightA.."x"..widthA)
monitorA.setBackgroundColor(colors.black)
monitorA.clear()
monitorA.setTextScale(0.5)
term.redirect(monitorA)
paintutils.drawLine(0, 0, heightA, widthA, colors.red)

Any help is appreciated. Thanks :)
Title: Make Text Move Along a Slope? (1.12.2)
Post by: Lupus590 on Jan 03, 2021, 09:01 PM
I would put your text into a window and use window.reposition() to move the window and thus it's contained text.

As for going along a line, I would look at the souce code of paint utils and how it's draw line function works.

https://tweaked.cc/module/window.html#ty:Window:reposition