Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- TODO add prefix modification via command
- -- Written by: Sara Mae (bellezacelestial)
- -- Discord: @1000#0001
- -- If The username has not been found, you can reach her in the MMD Public Server at https://discord.gg/BurN6C3
- -- FUNCTIONS
- for a, b in pairs(rs.getSides()) do
- if peripheral.getType(b) == "manipulator" then
- chat = peripheral.wrap(b)
- break
- end
- end
- for a, b in pairs(rs.getSides()) do
- if peripheral.getType(b) == "modem" then
- rednet.open(b)
- break
- end
- end
- function _help()
- _say("The list of prefixes is wrapped in square brackets: "..prefix)
- _say("The commands are: day, night, clear, rain, storm, update, and printsides")
- end
- function send(command)
- rednet.send(client, command)
- return "Command Sent: \""..command.."\""
- end
- -- VARIABLES
- version = "0.2.7"
- saraIsOnline = false
- prefix = "[?!`~]"
- client = 75
- day = "SET_TO_DAY"
- night = "SET_TO_NIGHT"
- clear = "SET_TO_CLEAR"
- rain = "SET_TO_RAIN"
- storm = "SET_TO_STORM"
- hasSaid = false
- sara = "bellezacelestial"
- print("Version: "..version)
- while true do
- function _say(command)
- -- if saraIsOnline then
- chat.say("[Sara's Weather & Time Bot]: "..command)
- -- end
- -- This is just out of laziness, from when I had to check if I was online
- end
- local _, player, message, uuid = os.pullEvent("chat_message") -- Waits for a message
- -- Checking what commands are available
- if rs.getAnalogInput("left") >= 3 then
- canMakeDay = true
- canMakeNight = false
- else
- canMakeNight = true
- canMakeDay = false
- end
- if rs.getInput("back") then
- canClear = true
- canRain = false
- canStorm = false
- else
- canClear = false
- canRain = true
- canStorm = true
- end
- -- Seeing if Sara is online
- if message:find(prefix.."[Oo]nline") and player == sara then
- chat.say("Sara is now marked online! Chat printing is enabled!")
- saraIsOnline = true
- elseif message:find(prefix.."[Oo]ffline") then
- saraIsOnline = false
- -- Checking for commands
- elseif message:find(prefix.."[Dd]ay") and canMakeDay then
- print(send(day))
- _say("Setting time to day...")
- elseif message:find(prefix.."[Nn]ight") and canMakeNight then
- print(send(night))
- _say("Setting time to night...")
- elseif message:find(prefix.."[Cc]lear") and canClear then
- print(send(clear))
- _say("Clearing the weather...")
- elseif message:find(prefix.."[Rr]ain") and canRain then
- print(send(rain))
- _say("Makin' it rain ;)")
- elseif message:find(prefix.."[Rr]ain") and canRain == false then
- _say("If it is currently storming and you want it to rain without lightning, please set it to clear, and then try again.")
- elseif message:find(prefix.."[Ss]torm") and canStorm then
- print(send(storm))
- _say("Creating a storm...")
- elseif message:find(prefix.."[Ss]torm") and canStorm == false then
- _say("If it is currently raining and you want a storm, please set it to clear, and then run the command.")
- elseif message:find(prefix.."[Pp]rint_sides") and player == sara then
- print(send("PRINT_SIDES"))
- -- TODO add the printing
- elseif message:find(prefix.."[Ss]ource") then
- _say("You can find the source for the server program here: https://pastebin.com/edit/e3YpAR0j")
- _say("You can find the source for the client program here: https://pastebin.com/V3dNaWvw")
- --chat.say("You can find the instructions here: ")
- elseif message:find(prefix.."[Uu]pdate") and player == sara then
- _say("Rebooting now!")
- os.reboot()
- elseif message:find(prefix.."[Pp]layer[Ii]nfo") then
- print("Username: "..player)
- _say("Username: "..player)
- elseif message:find(prefix.."[Hh]elp") then
- _help()
- elseif message:find(prefix.."[Uu]pdate") and player == not sara then
- _say("You do not have permissions. Please contact Sara (bellezacelestial) for permissions.")
- elseif message:find(prefix.."[Pp]rintsides") and player == not sara then
- _say("You do not have permissions. Please contact Sara (bellezacelestial) for permissions.")
- elseif message:find(prefix.."[Ii]s[Oo]nline") then
- _say("saraIsOnline = "..tostring(saraIsOnline))
- --AUTOMATIC COMMANDS
- elseif message:find(prefix.."[Aa]uto[Dd]ay") then
- _say("Will automatically set to day, at nightfall.")
- repeat
- os.pullEvent("redstone")
- if rs.getAnalogInput("left") >= 3 and hasSaid == false then
- rednet.send(client, "SET_TO_DAY")
- _say("Automatically setting to day. Type the commmand \"autoStop\" with your preferred prefix to stop.")
- hasSaid = true
- end
- if rs.getInput("right") then
- _say("Stopping the automatic time change!")
- end
- until rs.getInput("right")
- elseif message:find(prefix.."[Aa]uto[Nn]ight") then
- _say("Will automatically set to night, at sunrise.")
- repeat
- os.pullEvent("redstone")
- if rs.getAnalogInput("left") <= 3 and hasSaid == false then
- rednet.send(client, "SET_TO_DAY")
- _say("Automatically setting to night. Type the commmand \"autoStop\" with your preferred prefix to stop.")
- hasSaid = true
- end
- if rs.getInput("right") then
- _say("Stopping the automatic time change!")
- end
- until rs.getInput("right")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment