Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local obelisk = peripheral.find "weather_obelisk"
- local weather_type = settings.get "wcscs.type"
- local modem = peripheral.find "modem"
- modem.open(666)
- local weather_modes = {
- sun = 1,
- rain = 2,
- thunder = 3
- }
- local function send(msg)
- modem.transmit(666, 666, msg)
- end
- while true do
- local _, _, _, _, msg = os.pullEvent "modem_message"
- -- protocol: { message type [command/error/result], command, params }
- if type(msg) == "table" and msg[1] == "command" and msg[2] == "set_weather" then
- local set_to = msg[3]
- local mode = weather_modes[set_to]
- if not mode then
- send {"error", msg[2], "invalid weather type " .. tostring(set_to)}
- else
- if weather_type == set_to then
- print("setting weather to", set_to)
- local result = obelisk.activate()
- send { "result", msg[2], result }
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement