Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- chunkBot.lua
- -- Simple script to display a message and keep the computer active.
- local function displayStartupMessage()
- term.clear()
- term.setCursorPos(1, 1)
- local message = {
- "------------------------------",
- " ChunkBot Online!",
- "------------------------------",
- "", -- Blank line for spacing
- "I'm here to keep this",
- "chunkloader loaded.",
- "",
- "That way, it can ensure",
- "my brothers' chunkloaders",
- "stay loaded too!",
- "------------------------------"
- }
- local termWidth, termHeight = term.getSize()
- for i, line in ipairs(message) do
- -- Center the text
- local padding = math.max(0, math.floor((termWidth - #line) / 2))
- term.setCursorPos(padding + 1, i) -- Directly set cursor y position
- print(line)
- end
- -- Position cursor after the message
- term.setCursorPos(1, #message + 2)
- end
- -- Display the startup message
- displayStartupMessage()
- -- Main loop to keep the script (and thus the computer/chunk) active
- while true do
- -- logDebug("Heartbeat: Still active. Next check in 1 hour.") -- Optional debug: Call commented out
- os.sleep(3600) -- Sleep for 1 hour (3600 seconds)
- end
- -- Optional: A simple debug logger if you want to see activity in a file
- -- (Uncomment the block below AND the call in the loop above if you want logging)
- --
- -- local DEBUG_LOG_FILE = "chunkbot.log"
- -- local DEBUG_MODE = true -- Set to false to disable logging
- -- local function logDebug(message)
- -- if not DEBUG_MODE then return end
- -- local logMessage = string.format("[%s] %s\n", os.date("%Y-%m-%d %H:%M:%S"), message)
- -- local file, err = fs.open(DEBUG_LOG_FILE, "a")
- -- if file then
- -- file.write(logMessage)
- -- file.close()
- -- else
- -- print("DEBUG LOG ERROR: Could not open " .. DEBUG_LOG_FILE .. ": " .. (err or "unknown error"))
- -- end
- -- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement