Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Turtle Remote Controle Server
- -- Minecraft 1.16.5
- -- Forge 36.1.66
- -- Mod: cc-tweaked-1.16.4-1.96.0.jar
- local Version = "1.0.5"
- local System = os -- Used for System things like os.time() to System.time()
- local Screen = term -- Used for Screen thing on the turtle or computer like term.clear() to Screen.clear()
- local Per = peripheral -- Used shortcut for peripheral
- local Text = textutils -- Used shortcut for textilils
- local Pack = Text.serialize -- Makes a new command for packing ( shortcut used from local Text)
- local UnPack = Text.unserialize -- Makes a new command for unpacking ( shortcut used from local Text)
- local Monitor = {}
- Monitor[0] = Screen -- sets Monitor[0] to term
- local file = fs.exists("/API/Logo.lua")
- if not(file) then
- shell.run("pastebin get s3aBGUVr /API/Logo.lua")
- Monitor[0].clear()
- Monitor[0].setCursorPos(1,1)
- end
- System.loadAPI("/API/Logo.lua")
- local w, h = Monitor[0].getSize()
- Monitor[0].clear()
- Logo.drawLogo(Monitor[0], "Head", math.floor(w/2)-6, math.floor(h/2)-4)
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- Monitor[0].setBackgroundColor(colors.white)
- Monitor[0].setTextColor(colors.black)
- Monitor[0].setCursorPos(math.floor((w - string.len("Looking for file...")) /2), (h-1))
- print("Looking for files...")
- local file0 = fs.exists("/API/Functions.lua")
- local file1 = fs.exists("/API/Button.lua")
- local file2 = fs.exists("/API/MonButton.lua")
- Monitor[0].setBackgroundColor(colors.black)
- Monitor[0].setTextColor(colors.white)
- sleep(1)
- if not(file0) then
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- Monitor[0].setBackgroundColor(colors.white)
- Monitor[0].setTextColor(colors.black)
- Monitor[0].setCursorPos(math.floor((w - string.len("Downloading Function file...")) /2), (h-1))
- print("Downloading Function file...")
- shell.run("pastebin get sujHjqXC /API/Functions.lua")
- Monitor[0].setBackgroundColor(colors.black)
- Monitor[0].setTextColor(colors.white)
- sleep(1)
- end
- if not(file1) then
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- Monitor[0].setBackgroundColor(colors.white)
- Monitor[0].setTextColor(colors.black)
- Monitor[0].setCursorPos(math.floor((w - string.len("Downloading Button file...")) /2), (h-1))
- print("Downloading Button file...")
- shell.run("pastebin get mKpxpWmZ /API/Button.lua")
- Monitor[0].setBackgroundColor(colors.black)
- Monitor[0].setTextColor(colors.white)
- sleep(1)
- end
- if not(file2) then
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- Monitor[0].setBackgroundColor(colors.white)
- Monitor[0].setTextColor(colors.black)
- Monitor[0].setCursorPos(math.floor((w - string.len("Downloading Monitor Button file...")) /2), (h-1))
- print("Downloading Monitor Button file...")
- shell.run("pastebin get mKpxpWmZ /API/MonButton.lua")
- Monitor[0].setBackgroundColor(colors.black)
- Monitor[0].setTextColor(colors.white)
- sleep(1)
- end
- Monitor[0].clear()
- Logo.drawLogo(Monitor[0], "Head", math.floor(w/2)-6, math.floor(h/2)-4)
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- Monitor[0].setBackgroundColor(colors.white)
- Monitor[0].setTextColor(colors.black)
- Monitor[0].setCursorPos(math.floor((w - string.len("Installing files...")) /2), (h-1))
- print("Installing files...")
- System.loadAPI("/API/Functions.lua")
- System.loadAPI("/API/Button.lua")
- System.loadAPI("/API/MonButton.lua")
- Button.setMonitor(false)
- Functions.SetColors(Monitor[0], colors.black, colors.white)
- sleep(1)
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- local Disk = Functions.FindDisk()
- sleep(1)
- if Disk then
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- Functions.SetColors(Monitor[0], colors.white, colors.black)
- Monitor[0].setCursorPos(math.floor((w - string.len("Installing Disk...")) /2), (h-1))
- print("Installing Disk...")
- Disk = Per.wrap(Disk)
- Functions.SetColors(Monitor[0], colors.black, colors.white)
- sleep(1)
- end
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- local Modem = Functions.FindModem()
- sleep(1)
- if Modem then
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- Functions.SetColors(Monitor[0], colors.white, colors.black)
- Monitor[0].setCursorPos(math.floor((w - string.len("Installing Modem...")) /2), (h-1))
- print("Installing Modem...")
- Modem = Per.wrap(Modem)
- Modem.Send = Modem.transmit
- Modem.closeAll()
- Functions.SetColors(Monitor[0], colors.black, colors.white)
- sleep(1)
- end
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- local WModem = Functions.FindWirelessModem()
- sleep(1)
- if WModem then
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- Functions.SetColors(Monitor[0], colors.white, colors.black)
- Monitor[0].setCursorPos(math.floor((w - string.len("Installing Wireless Modem...")) /2), (h-1))
- print("Installing Wireless Modem...")
- WModem = Per.wrap(WModem)
- WModem.Send = WModem.transmit
- WModem.closeAll()
- Functions.SetColors(Monitor[0], colors.black, colors.white)
- sleep(1)
- end
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- Monitor[1] = Functions.FindMonitor()
- sleep(1)
- if Monitor[1] then
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- Functions.SetColors(Monitor[0], colors.white, colors.black)
- Monitor[0].setCursorPos(math.floor((w - string.len("Installing Monitor...")) /2), (h-1))
- print("Installing Monitor...")
- Monitor[1] = Per.wrap(Monitor[1])
- MonButton.setMonitor(true)
- Functions.SetColors(Monitor[0], colors.black, colors.white)
- local mw, mh = Monitor[1].getSize()
- Logo.drawLogo(Monitor[1], "Head", math.floor(mw/2)-6, math.floor(mh/2)-3)
- sleep(1)
- end
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- local Printer = Functions.FindPrinter()
- sleep(1)
- if Printer then
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- Functions.SetColors(Monitor[0], colors.white, colors.black)
- Monitor[0].setCursorPos(math.floor((w - string.len("Installing Printer...")) /2), (h-1))
- print("Installing Printer...")
- Printer = Per.wrap(Printer)
- Functions.SetColors(Monitor[0], colors.black, colors.white)
- sleep(1)
- end
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- local Speaker = Functions.FindSpeaker()
- sleep(1)
- if Speaker then
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- Functions.SetColors(Monitor[0], colors.white, colors.black)
- Monitor[0].setCursorPos(math.floor((w - string.len("Installing Speaker...")) /2), (h-1))
- print("Installing Speaker...")
- Speaker = Per.wrap(Speaker)
- Functions.SetColors(Monitor[0], colors.black, colors.white)
- sleep(1)
- end
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- Monitor[0].setCursorPos(1, (h-1))
- Monitor[0].clearLine()
- Functions.SetColors(Monitor[0], colors.white, colors.black)
- Monitor[0].setCursorPos(math.floor((w - string.len("Done")) /2), (h-1))
- print("Done")
- Functions.SetColors(Monitor[0], colors.black, colors.white)
- sleep(1)
- local Server = {System = {ServerName = "Server 01",
- Status = true,
- Modem = {ServerID = 0,
- HeadServerID = 0,
- foundWireless = false,
- },
- First = true,
- NetherServer = false,
- NetherServerState = false,
- Farms = {Normale = {Overworld = {},
- Nether = {},
- },
- TreeFarm = {},
- },
- },
- }
- local Turtles = {}
- local NetherTurtles = {}
- local BlackListedDigging = {}
- local OreLib = {}
- local Temp = {}
- local Color = { Green = colors.green,
- Red = colors.red,
- Black = colors.black,
- White = colors.white,
- Orange = colors.orange,
- Magenta = colors.magenta,
- LightBlue = colors.lightBlue,
- Yellow = colors.yellow,
- Lime = colors.lime,
- Pink = colors.pink,
- Gray = colors.gray,
- LightGray = colors.lightGray,
- Cyan = colors.cyan,
- Purple = colors.purple,
- Blue = colors.blue,
- Brown = colors.brown,
- }
- function Load()
- if not(Monitor[1]) then
- print("No Monitor Found !")
- error()
- end
- if not(Printer) then
- print("No Printer Found !")
- error()
- end
- if not(WModem) then
- print("No WirelessModem Found !")
- error()
- end
- end
- function LoadOreLib()
- local File = fs.exists("/OS/.Data/.OreLib.txt")
- while not(File) do
- shell.run("pastebin get f8Pw0Ya2 /OS/.Data/.OreLib.txt")
- File = fs.exists("/OS/.Data/.OreLib.txt")
- end
- OreLib = Functions.LoadFile("/OS/.Data/.OreLib.txt")
- end
- function SaveOreLib(SaveData)
- local Map = fs.exists("/OS/.Data")
- if not(Map) then
- fs.makeDir("/OS/.Data")
- end
- Functions.SaveFile("/OS/.Data/.OreLib.txt", "w", SaveData)
- end
- function LoadBlackListedDigging()
- local File = fs.exists("/OS/.Data/.BlackListedDigging.txt")
- while not(File) do
- shell.run("pastebin get TYtxwFZp /OS/.Data/.BlackListedDigging.txt")
- File = fs.exists("/OS/.Data/.BlackListedDigging.txt")
- end
- BlackListedDigging = Functions.LoadFile("/OS/.Data/.BlackListedDigging.txt")
- end
- function SaveBlackListedDigging(SaveData)
- local Map = fs.exists("/OS/.Data")
- if not(Map) then
- fs.makeDir("/OS/.Data")
- end
- Functions.SaveFile("/OS/.Data/.BlackListedDigging.txt", "w", SaveData)
- end
- function SaveLand(SaveData)
- print("Saving Land")
- local Map = fs.exists("/OS/.Data/.Lands")
- if not(Map) then
- fs.makeDir("/OS/.Data/.Lands")
- end
- if SaveData.What == "Normale" then
- local T = Server.System.Farms.Normale.Overworld
- local F = #T + 1
- table.insert(Server.System.Farms.Normale.Overworld, F, SaveData)
- Functions.SaveFile("/OS/.Data/.Lands/."..F..".frm", "w", SaveData)
- Functions.SaveFile("/OS/.Data/.Lands/.Count.cou", "w", F)
- elseif SaveData.What == "Nether" then
- local T = Server.System.Farms.Normale.Nether
- local N = #T + 1
- table.insert(Server.System.Farms.Normale.Nether, N, SaveData)
- Functions.SaveFile("/OS/.Data/.Lands/.N"..N..".frm", "w", SaveData)
- Functions.SaveFile("/OS/.Data/.Lands/.NCount.cou", "w", N)
- end
- end
- function LoadLand()
- print("Loading Land")
- local Max = 0
- local NMax = 0
- Server.System.Farms.Normale.Overworld = {}
- Server.System.Farms.Normale.Nether = {}
- local Map = fs.exists("/OS/.Data/.Lands")
- if not(Map) then
- fs.makeDir("/OS/.Data/.Lands")
- end
- local File1 = fs.exists("/OS/.Data/.Lands/.Count.cou")
- local File2 = fs.exists("/OS/.Data/.Lands/.NCount.cou")
- if File1 then
- Max = Functions.LoadFile("/OS/.Data/.Lands/.Count.cou")
- end
- if File2 then
- NMax = Functions.LoadFile("/OS/.Data/.Lands/.NCount.cou")
- end
- if Max ~= 0 then
- for i = 1, Max do
- local Data = Functions.LoadFile("/OS/.Data/.Lands/."..i..".frm")
- table.insert(Server.System.Farms.Normale.Overworld, i, Data)
- end
- end
- if NMax ~= 0 then
- for i = 1, NMax do
- local Data = Functions.LoadFile("/OS/.Data/.Lands/.N"..i..".frm")
- table.insert(Server.System.Farms.Normale.Nether, i, Data)
- end
- end
- end
- function SaveTreeFarm()
- print("Saving Tree Farm")
- local Map = fs.exists("/OS/.Data/.TreeFarm")
- if not(Map) then
- fs.makeDir("/OS/.Data/.TreeFarm")
- end
- Functions.SaveFile("/OS/.Data/.TreeFarm/.TreeFarm.cor", "w", Server.System.Farms.TreeFarm)
- end
- function LoadTreeFarm()
- print("Loading Tree Farm")
- local Map = fs.exists("/OS/.Data/.TreeFarm")
- if not(Map) then
- fs.makeDir("/OS/.Data/.TreeFarm")
- end
- local File1 = fs.exists("/OS/.Data/.TreeFarm/.TreeFarm.cor")
- if File1 then
- Server.System.Farms.TreeFarm = Functions.LoadFile("/OS/.Data/.TreeFarm/.TreeFarm.cor")
- end
- end
- function Asking()
- Screen.clear()
- Screen.setCursorPos(1, 1)
- print("Welcome :-D")
- print(" ")
- write("Server name: ")
- Server.System.ServerName = read()
- write("ServerId: ")
- Server.System.Modem.ServerID = tonumber(read())
- write("NetherServer Y/N: ")
- local Event, Key, IsHeld = System.pullEvent("key")
- if Key == keys.y then
- Server.System.NetherServer = true
- else
- Server.System.NetherServer = false
- end
- print(" ")
- if Server.System.NetherServer == true then
- write("HeadServer ID: ")
- Server.System.Modem.HeadServerID = tonumber(read())
- end
- end
- function LoadSettings()
- print("Loading Settings")
- local File = fs.exists("/OS/.Data/.Settings.set")
- local Data
- if File then
- Data = Functions.LoadFile("/OS/.Data/.Settings.set")
- Server.System.First = Data.First
- Server.System.Modem.HeadServerID = Data.HeadServer
- Server.System.Modem.ServerID = Data.ServerId
- Server.System.NetherServer = Data.NetherServer
- Server.System.ServerName = Data.ComputerName
- else
- if Server.System.First == true then
- Asking()
- Server.System.First = false
- end
- SaveSettings()
- end
- end
- function SaveSettings()
- print("Saving Settings")
- local Data = {First = Server.System.First, ComputerName = Server.System.ServerName, HeadServer = Server.System.Modem.HeadServerID, ServerId = Server.System.Modem.ServerID, NetherServer = Server.System.NetherServer}
- local Map = fs.exists("/OS/.Data")
- if not(Map) then
- fs.makeDir("/OS/.Data")
- end
- Functions.SaveFile("/OS/.Data/.Settings.set", "w", Data)
- end
- function Startup()
- CheckVersion()
- System.setComputerLabel(Server.System.ServerName)
- LoadSettings()
- Load()
- LoadBlackListedDigging()
- LoadLand()
- LoadTreeFarm()
- WModem.closeAll() -- Closes all channels
- WModem.open(Server.System.Modem.ServerID) -- Opens the givin id channel from local ServerID
- Monitor[1].clear()
- if Server.System.NetherServer then
- sleep(2)
- local Data = {What = "Command", Command = "/N3TH3RCH3CK1N/"}
- WModem.Send(Server.System.Modem.HeadServerID, Sever.System.Modem.ServerID, Pack(Data))
- end
- end
- function CheckVersion()
- local NewServerVersion
- Temp.OldVersion = {}
- Temp.OldVersion.A = tonumber(string.sub (Version, 1, 1))
- Temp.OldVersion.B = tonumber(string.sub (Version, 3, 3))
- Temp.OldVersion.C = tonumber(string.sub (Version, 5, 5))
- file = fs.exists("/OS/.Version.txt")
- if file then
- Functions.DelFile("/OS/.Version.txt")
- shell.run("pastebin get TesjGu7s /OS/.Version.txt")
- NewServerVersion = Functions.LoadFile("/OS/.Version.txt")
- Temp.NewVersion = {}
- Temp.NewVersion.A = tonumber(string.sub(NewServerVersion, 1, 1))
- Temp.NewVersion.B = tonumber(string.sub(NewServerVersion, 3, 3))
- Temp.NewVersion.C = tonumber(string.sub(NewServerVersion, 5, 5))
- if Temp.NewVersion.A == nil or Temp.NewVersion.B == nil or Temp.NewVersion.C == nil or Temp.NewVersion.A > Temp.OldVersion.A or Temp.NewVersion.B > Temp.OldVersion.B or Temp.NewVersion.C > Temp.OldVersion.C then
- file = fs.exists("/OS/.Menu.lua")
- if file then
- Functions.DelFile("/OS/.Menu.lua")
- end
- shell.run("pastebin get 2w6RkVHv /OS/.Menu.lua")
- Monitor[0].clear()
- Text = "Rebooting..."
- Monitor[0].setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Monitor[0].write(Text)
- sleep(3)
- System.reboot()
- end
- else
- shell.run("pastebin get TesjGu7s /OS/.Version.txt")
- NewServerVersion = Functions.LoadFile("/OS/.Version.txt")
- Temp.NewVersion = {}
- Temp.NewVersion.A = tonumber(string.sub(NewServerVersion, 1, 1))
- Temp.NewVersion.B = tonumber(string.sub(NewServerVersion, 3, 3))
- Temp.NewVersion.C = tonumber(string.sub(NewServerVersion, 5, 5))
- if Temp.NewVersion.A == nil or Temp.NewVersion.B == nil or Temp.NewVersion.C == nil or Temp.NewVersion.A > Temp.OldVersion.A or Temp.NewVersion.B > Temp.OldVersion.B or Temp.NewVersion.C > Temp.OldVersion.C then
- file = fs.exists("/OS/.Menu.lua")
- if file then
- Functions.DelFile("/OS/.Menu.lua")
- end
- shell.run("pastebin get 2w6RkVHv /OS/.Menu.lua")
- Monitor[0].clear()
- Text = "Rebooting..."
- Monitor[0].setCursorPos((w - string.len(Text)) /2, (h/2) + 1)
- Monitor[0].write(Text)
- sleep(3)
- System.reboot()
- end
- end
- end
- Monitor[0].clear()
- Monitor[0].setCursorPos(1, 1)
- Startup()
- Monitor[1].setTextScale(1)
- local mw, mh = Monitor[1].getSize()
- local NameLen = 8
- local nHeadOption = 1
- local MaxHeadOptions = 3
- function drawScreen()
- Monitor[0].clear()
- Logo.drawLogo(Monitor[0], "Sub", 1, 1)
- Functions.SetTitle(Monitor[0], Server.System.ServerName)
- Functions.printCentered(Monitor[0], math.floor(h/2) -3, Functions.PadString(" Head Menu",NameLen+8))
- if nHeadOption == 1 then
- Functions.SetColors(Monitor[0], Color.White, Color.Black)
- else
- Functions.SetColors(Monitor[0], Color.Black, Color.White)
- end
- Functions.printCenteredNC(Monitor[0], math.floor(h/2) -1, Functions.PadString(" Nothing",NameLen+8))
- if nHeadOption == 2 then
- Functions.SetColors(Monitor[0], Color.White, Color.Black)
- else
- Functions.SetColors(Monitor[0], Color.Black, Color.White)
- end
- Functions.printCenteredNC(Monitor[0], math.floor(h/2) +0, Functions.PadString(" Reset",NameLen+8))
- if nHeadOption == 3 then
- Functions.SetColors(Monitor[0], Color.White, Color.Black)
- else
- Functions.SetColors(Monitor[0], Color.Black, Color.White)
- end
- Functions.printCenteredNC(Monitor[0], math.floor(h/2) +1, Functions.PadString(" Uninstall",NameLen+8))
- Functions.SetColors(Monitor[0], Color.White, Color.Black)
- Monitor[0].setCursorPos(1, h)
- Monitor[0].write("Press 'Q' to quit.")
- Functions.SetColors(Monitor[0], Color.Black, Color.White)
- end
- function drawMonitor()
- Functions.SetColors(Monitor[1], Color.Black, Color.White)
- Monitor[1].clear()
- Functions.SetTitle(Monitor[1], Server.System.ServerName)
- Functions.printCentered(Monitor[1], 2, "")
- Functions.printCentered(Monitor[1], 3, Functions.PadString("Name:", NameLen+8)..Functions.PadString("ID:", NameLen)..Functions.PadString("Free:", NameLen)..Functions.PadString("Cor:", NameLen+5)..Functions.PadString("Fuel:", NameLen)..Functions.PadString("ToGo:", NameLen)..Functions.PadString("doing:", NameLen+5))
- Functions.printCentered(Monitor[1], 4, "")
- local A = 5
- for i = 1, #Turtles do
- if Turtles[i].LTG == nil then
- Turtles[i].LTG = 0
- end
- if Turtles[i].Status then
- Functions.SetColors(Monitor[1], Color.Black, Color.Lime)
- else
- Functions.SetColors(Monitor[1], Color.Black, Color.Red)
- end
- Functions.printCentered(Monitor[1], A, Functions.PadString(tostring(Turtles[i].Name), NameLen+8)..Functions.PadString(tostring(Turtles[i].Id), NameLen)..Functions.PadString(tostring(Turtles[i].Status), NameLen)..Functions.PadString(tostring(Turtles[i].Cor.X.." "..Turtles[i].Cor.Y.." "..Turtles[i].Cor.Z), NameLen+5)..Functions.PadString(tostring(Turtles[i].FuelLevel), NameLen)..Functions.PadString(tostring(Turtles[i].LTG), NameLen)..Functions.PadString(tostring(Turtles[i].Doing), NameLen+5))
- A = A + 1
- Functions.SetColors(Monitor[1], Color.Black, Color.White)
- end
- if Server.System.NetherServerState then
- A = A + 1
- Functions.printCentered(Monitor[1], A, "Nether")
- A = A + 2
- for i = 1, #NetherTurtles do
- if NetherTurtles[i].LTG == nil then
- NetherTurtles[i].LTG = 0
- end
- if NetherTurtles[i].Status then
- Functions.SetColors(Monitor[1], Color.Black, Color.Lime)
- else
- Functions.SetColors(Monitor[1], Color.Black, Color.Red)
- end
- Functions.printCentered(Monitor[1], A, Functions.PadString(tostring(NetherTurtles[i].Name), NameLen+8)..Functions.PadString(tostring(NetherTurtles[i].Id), NameLen)..Functions.PadString(tostring(NetherTurtles[i].Status), NameLen)..Functions.PadString(tostring(NetherTurtles[i].Cor.X.." "..NetherTurtles[i].Cor.Y.." "..NetherTurtles[i].Cor.Z), NameLen+5)..Functions.PadString(tostring(NetherTurtles[i].FuelLevel), NameLen)..Functions.PadString(tostring(NetherTurtles[i].LTG), NameLen)..Functions.PadString(tostring(NetherTurtles[i].Doing), NameLen+5))
- A = A + 1
- Functions.SetColors(Monitor[1], Color.Black, Color.White)
- end
- end
- if Server.System.NetherServer then
- local Data = {What = "Command", Command = "/N3TH3RUPD4T3/", Data = Turtles}
- WModem.Send(Server.System.HeadServerID, Server.System.ServerID, Pack(Data))
- end
- end
- while Server.System.Status do
- drawScreen()
- drawMonitor()
- local Event, p1, p2, p3, p4, p5 = System.pullEvent()
- if Event == "modem_message" then
- local Data = UnPack(p4)
- if Data.What == "Command" then
- if Data.Command == "/CH3CK1N/" then
- local Deta = {Name = Data.Dita.Name, Id = p3, Status = false, Cor = Data.Dita.Cor, FuelLevel = Data.Dita.FuelLevel, Doing = Data.Dita.Doing, GroupState = Data.Dita.GroupState, Compare = Data.Dita.Compare, Detect = Data.Dita.Detect, Inspect = Data.Dita.Inspect}
- if Turtles[1] == nil then
- table.insert (Turtles, Deta)
- else
- local Already = false
- for i = 1, #Turtles do
- if Turtles[i].Id == p3 then
- Already = true
- end
- end
- if Already == false then
- local Bigger = false
- for i = 1, #Turtles do
- if Turtles[i].Id > p3 then
- table.insert (Turtles, i, Deta)
- Bigger = true
- break
- end
- end
- if Bigger == false then
- table.insert (Turtles, Deta)
- end
- end
- end
- elseif Data.Command == "/N3TH3RCH3CK1N/" then
- Server.System.NetherServerState = true
- elseif Data.Command == "/N3TH3RCH3CK0UT/" then
- NetherTurtles = {}
- Server.System.NetherServerState = false
- elseif Data.Command == "/CH3CK0UT/" then
- for i = 1, #Turtles do
- if Turtles[i].Id == p3 then
- table.remove (Turtles, i)
- break
- end
- end
- elseif Data.Command == "/W0RK1NG/" then
- for i = 1, #Turtles do
- if Turtles[i].Id == p3 then
- Turtles[i].Status = false
- end
- end
- elseif Data.Command == "/FR33/" then
- for i = 1, #Turtles do
- if Turtles[i].Id == p3 then
- Turtles[i].Status = true
- end
- end
- elseif Data.Command == "/CH3CK/" then
- WModem.Send(p3, Server.System.Modem.ServerID, Pack(Turtles))
- elseif Data.Command == "/UPD4T3/" then
- local Have = false
- if Turtles[1] ~= nil then
- for i = 1, #Turtles do
- if Turtles[i].Id == p3 then
- Turtles[i].Name = Data.Data.Name
- Turtles[i].Cor = Data.Data.Cor
- Turtles[i].FuelLevel = Data.Data.FuelLevel
- Turtles[i].LTG = Data.Data.LTG
- Turtles[i].Doing = Data.Data.Doing
- Turtles[i].GroupState = Data.Data.GroupState
- Turtles[i].Inspect = Data.Data.Inspect
- Turtles[i].Compare = Data.Data.Compare
- Turtles[i].Detect = Data.Data.Detect
- Turtles[i].SlotSelected = Data.Data.SlotSelected
- Turtles[i].Slot = Data.Data.Slot
- Have = true
- break
- end
- end
- end
- if not(Have) then
- local Bigger = false
- if Turtles[2] ~= nil then
- for i = 1, #Turtles do
- if Turtles[i].Id > p3 then
- table.insert (Turtles, i, Data.Data)
- Turtles[i].Id = p3
- Turtles[i].Status = false
- Bigger = true
- break
- end
- end
- end
- if Bigger == false then
- table.insert (Turtles, Data.Data)
- Turtles[#Turtles].Status = false
- Turtles[#Turtles].Id = p3
- end
- end
- elseif Data.Command == "/N3TH3RUPD4T3/" then
- if Server.System.NetherServerState == false then
- Server.System.NetherServerState = true
- end
- NetherTurtles = Data.Data
- elseif DataCommand == "/PR1NTL0GST4RT/" then
- local NewPageStarted = Printer.newPage()
- local i = 1
- while not(NewPageStarted) do
- Monitor[0].clear()
- Monitor[0].setCursorPos(1, 1)
- print("Put Paper and/or Dye in the Printer!!")
- read()
- NewPageStarted = Printer.newPage()
- end
- Printer.setPageTitle("Log's "..tostring(i))
- i = i + 1
- local l1n3s = 1
- local X, Y = Printer.getPageSize()
- WModem.Send(p3, Server.System.Modem.ServerID, "R34DY")
- local Event, Part1, Id, RId, Message = System.pullEvent("modem_message")
- while Message do
- if Message ~= "/D0N3/" then
- Printer.setCursorPos(1, l1n3s)
- Printer.write(Message)
- l1n3s = l1n3s + 1
- if l1n3s > Y then
- EndPage = Printer.endPage()
- while not(EndPage) do
- EndPage = Printer.endPage()
- end
- if EndPage then
- NewPageStarted = Printer.newPage()
- while not(NewPageStarted) do
- Monitor[0].clear()
- Monitor[0].setCursorPos(1, 1)
- print("Put Paper and/or Dye in the Printer!!")
- read()
- NewPageStarted = Printer.newPage()
- end
- Printer.setPageTitle("Log's "..tostring(i))
- i = i + 1
- l1n3s = 1
- end
- end
- WModem.Send(p3, Server.System.Modem.ServerID, "R34DY")
- Event, Part1, Id, RId, Message = System.pullEvent("modem_message")
- elseif Message == "/D0N3/" then
- EndPage = Printer.endPage()
- while not(EndPage) do
- EndPage = Printer.endPage()
- end
- break
- end
- end
- elseif Data.Command == "/LoadBlackListedDigging/" then
- LoadBlackListedDigging()
- WModem.Send(p3, Server.System.Modem.ServerID, Pack(BlackListedDigging))
- elseif Data.Command == "/SaveBlackListedDigging/" then
- SaveBlackListedDigging(Data.Data)
- LoadBlackListedDigging()
- elseif Data.Command == "/LoadOreLib/" then
- LoadOreLib()
- WModem.Send(p3, Server.System.Modem.ServerID, Pack(OreLib))
- elseif Data.Command == "/SaveOreLib/" then
- SaveOreLib(Data.Data)
- LoadOreLib()
- elseif Data.Command == "/L04DL4ND/" then
- LoadLand()
- WModem.Send(p3, Server.System.Modem.ServerID, Pack(Server.System.Farms.Normale.Overworld))
- WModem.Send(p3, Server.System.Modem.ServerID, Pack(Server.System.Farms.Normale.Nether))
- elseif Data.Command == "/S4V3L4ND/" then
- SaveLand(Data.Data)
- LoadLand()
- elseif Data.Command == "/L04DTR33F4RM/" then
- LoadTreeFarm()
- WModem.Send(p3, Server.System.Modem.ServerID, Pack(Server.System.Farms.TreeFarm))
- elseif Data.Command == "/S4V3TR33F4RM/" then
- Server.System.Farms.TreeFarm = Data.Data
- SaveTreeFarm()
- end
- end
- elseif Event == "key" then
- if p1 == keys.up or p1 == keys.numPad8 then
- if nHeadOption > 1 then
- nHeadOption = nHeadOption - 1
- end
- elseif p1 == keys.down or p1 == keys.numPad2 then
- if nHeadOption < MaxHeadOptions then
- nHeadOption = nHeadOption + 1
- end
- elseif p1 == keys.enter or p1 == keys.numPadEnter then
- if nHeadOption == 1 then
- elseif nHeadOption == 2 then
- Monitor[0].clear()
- Functions.printCentered(math.floor(h/2), "Reset Server? ... Y/N")
- local Event, p1, p2, p3 = System.pullEvent("key")
- if p1 == keys.y then
- local file = fs.exists("/OS/.Data/.Settings.set")
- if file then
- fs.delete("/OS/.Data/.Settings.set")
- System.reboot()
- end
- end
- elseif nHeadOption == 3 then
- Monitor[0].clear()
- Functions.printCentered(math.floor(h/2), "Run Uninstaller? ... Y/N")
- local Event, p1, p2, p3 = System.pullEvent("key")
- if p1 == keys.y then
- shell.run("/OS/Unintall.lua")
- end
- end
- elseif p1 == keys.q then
- SaveSettings()
- Monitor[1].clear()
- if NetherServer then
- WModem.Send(HeadServer, ServerId, "/N3TH3RCH3CK0UT/")
- end
- System.shutdown()
- elseif p1 == keys.slash then
- SaveSettings()
- Monitor[1].clear()
- if NetherServer then
- WModem.Send(HeadServer, ServerId, "/N3TH3RCH3CK0UT/")
- end
- Server.System.Status = false
- end
- end
- end
- Monitor[0].clear()
- Monitor[0].setCursorPos(1, 1)
- print("Type 'Back' to go back to the menu.")
Add Comment
Please, Sign In to add comment