Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --config--
- local channel = 43
- modem = peripheral.wrap("back")
- --vars--
- local power = true
- -- func split--
- function split(pString,pPattern)
- local Table = {}
- local fpat = "(.-)"..pPattern
- local last_end = 1
- local s,e,cap = pString:find(fpat,1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(Table,cap)
- end
- last_end = e+1
- s,e,cap = pString:find(fpat,last_end)
- end
- if last_end <= #pString then
- cap = pString:sub(last_end)
- table.insert(Table,cap)
- end
- return Table
- end
- --func decode--
- function decode(msg)
- if msg == "rain" then
- commands.toggledownfall()
- elseif msg == "sunrise" then
- commands.time("set", 0)
- elseif msg == "midday" then
- commands.time("set", 5000)
- elseif msg == "sunset" then
- commands.time("set", 12000)
- elseif msg == "midnight" then
- commands.time("set", 13000)
- elseif msg == "zero_hour" then
- commands.time("set", 18000)
- elseif msg == "world_survival" then
- commands.defaultgamemode(0)
- elseif msg == "world_creative" then
- commands.defaultgamemode(1)
- elseif msg == "shutdown" then
- shell.run("shutdown")
- elseif msg == "weather_rain" then
- commands.weather("rain")
- elseif msg == "weather_clear" then
- commands.weather("clear")
- elseif msg == "weather_thunder" then
- commands.weather("thunder")
- else
- data = split(msg,"#")
- if data[1] == "gamemode" then
- commands.gamemode(data[2],data[3])
- end
- if data[1] == "xp" then
- commands.xp(data[2],data[3])
- end
- if data[1] == "setblock" then
- print("set Block:"..data[5])
- commands.setblock(data[2],data[3],data[4],data[5])
- end
- if data[1] == "give" then
- commands.give(data[2],data[3],data[4])
- end
- --....---
- end
- end
- --program--
- print("start command Server");
- print("start modem on channel "..channel)
- modem.open(channel)
- print("command Server started")
- --open pull event--
- while power == true do
- event, modemside, sendchan, replaychan, message, dist = os.pullEvent("modem_message")
- print(message)
- decode(message)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement