Advertisement
Myros27

chunkLoader.lua

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