Trying to make a monitor-based to-do list

Started by XSilent_DevilX, Nov 13, 2024, 03:01 AM

Previous topic - Next topic

XSilent_DevilX

Hello, this is my first post on this forum so I apologise if this is the wrong section of the forum.
I am trying to make a to-do list that displays items that need doing on a monitor with the ability to change the color of the text by clicking on each item on the monitor. I want them to be able to change between red, yellow and green text colours. I don't have much experience with interacting with the monitors so any help would be appreciated.

I haven't gotten very far as I dont really know where to begin but here is my code thus far:

local mon = peripheral.wrap("left")
-- Change the text in these brackets to change
-- what the monitor says
local todo1 = "Train infrastructure + Building"
local todo2 = "Train Yard"
local todo3 = "Smeltery"
local todo4 = "Stone Automation"
--
local x = 1
local y = 1
mon.clear()
mon.setTextScale(1)
mon.setCursorPos(x,y)
mon.write(todo1)
mon.setCursorPos(x,y+2)
mon.write(todo2)
mon.setCursorPos(x,y+4)
mon.write(todo3)
mon.setCursorPos(x,y+6)
mon.write(todo4)

Lupus590

If you use term.redirect(mon) then you can use all of the terminal commands that you are familiar with. print will even write to the monitor.

You will be unable to write to the computer's built-in terminal while doing this though.

QuickMuffin8782

Quote from: XSilent_DevilX on Nov 13, 2024, 03:01 AM-formatting snip-

Try this code. Instead of separate variables, utilize the table instead.
local mon = peripheral.wrap("left")
local cterm = term.current() --gets current terminal
local x, y = 1, 1

local list = {
    "Item 1",
    "Item 2",
    "Item 3",
}

term.redirect(mon) --focus onto monitor
term.setCursorPos(x, y)
for k, v in pairs(list) do
    print(v)
end
term.redirect(cterm) --focus back to original terminal

Hopes this helps optimize your code!
"The Blue Blur" - Working on Net Star OS, a new frontier for Red Star OS 3.0
linktr.ee/quickmuffin8782