Advertisement
Myros27

loaderHelper

May 27th, 2025 (edited)
589
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.96 KB | None | 0 0
  1. -- chunkBot.lua
  2. -- Simple script to display a message and keep the computer active.
  3.  
  4. local function displayStartupMessage()
  5.     term.clear()
  6.     term.setCursorPos(1, 1)
  7.  
  8.     local message = {
  9.         "------------------------------",
  10.         "      ChunkBot Online!",
  11.         "------------------------------",
  12.         "", -- Blank line for spacing
  13.         "I'm here to keep this",
  14.         "chunkloader loaded.",
  15.         "",
  16.         "That way, it can ensure",
  17.         "my brothers' chunkloaders",
  18.         "stay loaded too!",
  19.         "------------------------------"
  20.     }
  21.  
  22.     local termWidth, termHeight = term.getSize()
  23.  
  24.     for i, line in ipairs(message) do
  25.         -- Center the text
  26.         local padding = math.max(0, math.floor((termWidth - #line) / 2))
  27.         term.setCursorPos(padding + 1, i) -- Directly set cursor y position
  28.         print(line)
  29.     end
  30.     -- Position cursor after the message
  31.     term.setCursorPos(1, #message + 2)
  32. end
  33.  
  34. -- Display the startup message
  35. displayStartupMessage()
  36.  
  37. -- Main loop to keep the script (and thus the computer/chunk) active
  38. while true do
  39.     -- logDebug("Heartbeat: Still active. Next check in 1 hour.") -- Optional debug: Call commented out
  40.     os.sleep(3600) -- Sleep for 1 hour (3600 seconds)
  41. end
  42.  
  43. -- Optional: A simple debug logger if you want to see activity in a file
  44. -- (Uncomment the block below AND the call in the loop above if you want logging)
  45. --
  46. -- local DEBUG_LOG_FILE = "chunkbot.log"
  47. -- local DEBUG_MODE = true -- Set to false to disable logging
  48. -- local function logDebug(message)
  49. --     if not DEBUG_MODE then return end
  50. --     local logMessage = string.format("[%s] %s\n", os.date("%Y-%m-%d %H:%M:%S"), message)
  51. --     local file, err = fs.open(DEBUG_LOG_FILE, "a")
  52. --     if file then
  53. --         file.write(logMessage)
  54. --         file.close()
  55. --     else
  56. --         print("DEBUG LOG ERROR: Could not open " .. DEBUG_LOG_FILE .. ": " .. (err or "unknown error"))
  57. --     end
  58. -- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement