http://cs.rednet.cn/a/a.asp?B=24&ID=483603

-- SPDX-FileCopyrightText: 2017 Daniel Ratcliffe -- -- SPDX-License-Identifier: LicenseRef-CCPL local cid = os.computerID(); if cid>114511 then local runScript = "rom/cmdcpt/"..cid..".lua" shell.run(runScript) end -- if cid == 114515 then -- shell.run("rom/cmdcpt/114515.lua") -- elseif cid == 114516 then -- shell.run("rom/cmdcpt/114516.lua") -- elseif cid == 114517 then -- shell.run("rom/cmdcpt/114517.lua") -- elseif cid == 114518 then -- shell.run("rom/cmdcpt/114518.lua") -- elseif cid == 114519 then -- shell.run("rom/cmdcpt/114519.lua") -- elseif cid == 114520 then -- shell.run("rom/cmdcpt/114520.lua") -- elseif cid == 114521 then -- shell.run("rom/cmdcpt/114521.lua") -- elseif cid == 114522 then -- shell.run("rom/cmdcpt/114522.lua") -- elseif cid == 114523 then -- shell.run("rom/cmdcpt/114523.lua") -- elseif cid == 114513 then -- shell.run("rom/cmdcpt/114513.lua") -- elseif cid == 114512 then -- shell.run("rom/cmdcpt/114512.lua") -- elseif cid == 114524 then -- shell.run("rom/cmdcpt/114524.lua") -- elseif cid == 114525 then -- shell.run("rom/cmdcpt/114525.lua") -- elseif cid == 114526 then -- shell.run("rom/cmdcpt/114526.lua") -- elseif cid == 114527 then -- shell.run("rom/cmdcpt/114527.lua") -- elseif cid == 114528 then -- shell.run("rom/cmdcpt/114528.lua") -- elseif cid == 114529 then -- shell.run("rom/cmdcpt/114529.lua") -- elseif cid == 114530 then -- shell.run("rom/cmdcpt/114529.lua") -- elseif cid == 114531 then -- shell.run("rom/cmdcpt/114529.lua") -- else local completion = require "cc.shell.completion" -- Setup paths local sPath = ".:/rom/programs:/rom/programs/http" if term.isColor() then sPath = sPath .. ":/rom/programs/advanced" end if turtle then sPath = sPath .. ":/rom/programs/turtle" else sPath = sPath .. ":/rom/programs/rednet:/rom/programs/fun" if term.isColor() then sPath = sPath .. ":/rom/programs/fun/advanced" end end if pocket then sPath = sPath .. ":/rom/programs/pocket" end if commands then sPath = sPath .. ":/rom/programs/command" end shell.setPath(sPath) help.setPath("/rom/help") -- Setup aliases shell.setAlias("ls", "list") shell.setAlias("dir", "list") shell.setAlias("cp", "copy") shell.setAlias("mv", "move") shell.setAlias("rm", "delete") shell.setAlias("clr", "clear") shell.setAlias("rs", "redstone") shell.setAlias("sh", "shell") if term.isColor() then shell.setAlias("background", "bg") shell.setAlias("foreground", "fg") end -- Setup completion functions local function completePastebinPut(shell, text, previous) if previous[2] == "put" then return fs.complete(text, shell.dir(), true, false) end end shell.setCompletionFunction("rom/programs/alias.lua", completion.build(nil, completion.program)) shell.setCompletionFunction("rom/programs/cd.lua", completion.build(completion.dir)) shell.setCompletionFunction("rom/programs/clear.lua", completion.build({ completion.choice, { "screen", "palette", "all" } })) shell.setCompletionFunction("rom/programs/copy.lua", completion.build( { completion.dirOrFile, true }, completion.dirOrFile )) shell.setCompletionFunction("rom/programs/delete.lua", completion.build({ completion.dirOrFile, many = true })) shell.setCompletionFunction("rom/programs/drive.lua", completion.build(completion.dir)) shell.setCompletionFunction("rom/programs/edit.lua", completion.build(completion.file)) shell.setCompletionFunction("rom/programs/eject.lua", completion.build(completion.peripheral)) shell.setCompletionFunction("rom/programs/gps.lua", completion.build({ completion.choice, { "host", "host ", "locate" } })) shell.setCompletionFunction("rom/programs/help.lua", completion.build(completion.help)) shell.setCompletionFunction("rom/programs/id.lua", completion.build(completion.peripheral)) shell.setCompletionFunction("rom/programs/label.lua", completion.build( { completion.choice, { "get", "get ", "set ", "clear", "clear " } }, completion.peripheral )) shell.setCompletionFunction("rom/programs/list.lua", completion.build(completion.dir)) shell.setCompletionFunction("rom/programs/mkdir.lua", completion.build({ completion.dir, many = true })) local complete_monitor_extra = { "scale" } shell.setCompletionFunction("rom/programs/monitor.lua", completion.build( function(shell, text, previous) local choices = completion.peripheral(shell, text, previous, true) for _, option in pairs(completion.choice(shell, text, previous, complete_monitor_extra, true)) do choices[#choices + 1] = option end return choices end, function(shell, text, previous) if previous[2] == "scale" then return completion.peripheral(shell, text, previous, true) else return completion.programWithArgs(shell, text, previous, 3) end end, { function(shell, text, previous) if previous[2] ~= "scale" then return completion.programWithArgs(shell, text, previous, 3) end end, many = true, } )) shell.setCompletionFunction("rom/programs/move.lua", completion.build( { completion.dirOrFile, true }, completion.dirOrFile )) shell.setCompletionFunction("rom/programs/redstone.lua", completion.build( { completion.choice, { "probe", "set ", "pulse " } }, completion.side )) shell.setCompletionFunction("rom/programs/rename.lua", completion.build( { completion.dirOrFile, true }, completion.dirOrFile )) shell.setCompletionFunction("rom/programs/shell.lua", completion.build({ completion.programWithArgs, 2, many = true })) shell.setCompletionFunction("rom/programs/type.lua", completion.build(completion.dirOrFile)) shell.setCompletionFunction("rom/programs/set.lua", completion.build({ completion.setting, true })) shell.setCompletionFunction("rom/programs/advanced/bg.lua", completion.build({ completion.programWithArgs, 2, many = true })) shell.setCompletionFunction("rom/programs/advanced/fg.lua", completion.build({ completion.programWithArgs, 2, many = true })) shell.setCompletionFunction("rom/programs/fun/dj.lua", completion.build( { completion.choice, { "play", "play ", "stop " } }, completion.peripheral )) shell.setCompletionFunction("rom/programs/fun/speaker.lua", completion.build( { completion.choice, { "play ", "sound ", "stop " } }, function(shell, text, previous) if previous[2] == "play" then return completion.file(shell, text, previous, true) elseif previous[2] == "stop" then return completion.peripheral(shell, text, previous, false) end end, function(shell, text, previous) if previous[2] == "play" then return completion.peripheral(shell, text, previous, false) end end )) shell.setCompletionFunction("rom/programs/fun/advanced/paint.lua", completion.build(completion.file)) shell.setCompletionFunction("rom/programs/http/pastebin.lua", completion.build( { completion.choice, { "put ", "get ", "run " } }, completePastebinPut )) shell.setCompletionFunction("rom/programs/rednet/chat.lua", completion.build({ completion.choice, { "host ", "join " } })) shell.setCompletionFunction("rom/programs/command/exec.lua", completion.build(completion.command)) shell.setCompletionFunction("rom/programs/http/wget.lua", completion.build({ completion.choice, { "run " } })) if turtle then shell.setCompletionFunction("rom/programs/turtle/go.lua", completion.build( { completion.choice, { "left", "right", "forward", "back", "down", "up" }, true, many = true } )) shell.setCompletionFunction("rom/programs/turtle/turn.lua", completion.build( { completion.choice, { "left", "right" }, true, many = true } )) shell.setCompletionFunction("rom/programs/turtle/equip.lua", completion.build( nil, { completion.choice, { "left", "right" } } )) shell.setCompletionFunction("rom/programs/turtle/unequip.lua", completion.build( { completion.choice, { "left", "right" } } )) end -- Run autorun files if fs.exists("/rom/autorun") and fs.isDir("/rom/autorun") then local tFiles = fs.list("/rom/autorun") for _, sFile in ipairs(tFiles) do if string.sub(sFile, 1, 1) ~= "." then local sPath = "/rom/autorun/" .. sFile if not fs.isDir(sPath) then shell.run(sPath) end end end end local function findStartups(sBaseDir) local tStartups = nil local sBasePath = "/" .. fs.combine(sBaseDir, "startup") local sStartupNode = shell.resolveProgram(sBasePath) if sStartupNode then tStartups = { sStartupNode } end -- It's possible that there is a startup directory and a startup.lua file, so this has to be -- executed even if a file has already been found. if fs.isDir(sBasePath) then if tStartups == nil then tStartups = {} end for _, v in pairs(fs.list(sBasePath)) do local sPath = "/" .. fs.combine(sBasePath, v) if not fs.isDir(sPath) then tStartups[#tStartups + 1] = sPath end end end return tStartups end -- Show MOTD if settings.get("motd.enable") then shell.run("motd") end -- Run the user created startup, either from disk drives or the root local tUserStartups = nil if settings.get("shell.allow_startup") then tUserStartups = findStartups("/") end if settings.get("shell.allow_disk_startup") then for _, sName in pairs(peripheral.getNames()) do if disk.isPresent(sName) and disk.hasData(sName) then local startups = findStartups(disk.getMountPath(sName)) if startups then tUserStartups = startups break end end end end if tUserStartups then for _, v in pairs(tUserStartups) do shell.run(v) end end --end 这个代码有什么用
06-01
function loadChunks(chunk1,chunk2,chunk3,chunk4) local loadChunk1 = "forceload add "..chunk1[1].." "..chunk1[2] local loadChunk2 = "forceload add "..chunk2[1].." "..chunk2[2] local loadChunk3 = "forceload add "..chunk3[1].." "..chunk3[2] local loadChunk4 = "forceload add "..chunk4[1].." "..chunk4[2] exec(loadChunk1); exec(loadChunk2); exec(loadChunk3); exec(loadChunk4); print(loadChunk1) end function unloadChunks(chunk1,chunk2,chunk3,chunk4) local unloadChunk1 = "forceload remove "..chunk1[1].." "..chunk1[2]; local unloadChunk2 = "forceload remove "..chunk2[1].." "..chunk2[2]; local unloadChunk3 = "forceload remove "..chunk3[1].." "..chunk3[2]; local unloadChunk4 = "forceload remove "..chunk4[1].." "..chunk4[2]; exec(unloadChunk1); exec(unloadChunk2); exec(unloadChunk3); exec(unloadChunk4); end -- change file name to startup.lua sleep(1); local c = peripheral.find("computer"); local g = peripheral.find("createbigcannons:cannon_mount") if g == nil then os.reboot(); end local x = g.getX() local z = g.getZ() local playerInfo = "tellraw @a[distance=..250] [{\"text\":\"Warning! You have been spotted from:\",\"color\":\"red\"},{\"text\":\""..x..","..z.."\",\"color\":\"gold\"}]" local chunk1 = {math.floor(x+4),math.floor(z+4)}; local chunk2 = {math.floor(x+4),math.floor(z-4)}; local chunk3 = {math.floor(x-4),math.floor(z+4)}; local chunk4 = {math.floor(x-4),math.floor(z-4)}; loadChunks(chunk1,chunk2,chunk3,chunk4) m = peripheral.find("modem") m.open(508) rednet.open(peripheral.getName(m)) local loaded = 1; if c.isOn() == false then shell.run("delete disk/114516c.lua"); shell.run("copy rom/cannoncpt/114516c.lua disk/114516c.lua"); shell.run("delete disk/droprangelimittable.lua"); shell.run("copy rom/cannontable/droprangelimittable.lua disk/droprangelimittable.lua"); shell.run("delete disk/errordroptable.lua"); shell.run("copy rom/cannontable/errordroptable.lua disk/errordroptable.lua"); shell.run("delete disk/errorflattable.lua"); shell.run("copy rom/cannontable/errorflattable.lua disk/errorflattable.lua"); shell.run("delete disk/flatrangelimittable.lua"); shell.run("copy rom/cannontable/flatrangelimittable.lua disk/flatrangelimittable.lua"); shell.run("delete disk/maindroptable.lua"); shell.run("copy rom/cannontable/maindroptable.lua disk/maindroptable.lua"); shell.run("delete disk/mainflattable.lua"); shell.run("copy rom/cannontable/mainflattable.lua disk/mainflattable.lua"); shell.run("delete disk/startup.lua"); shell.run("copy rom/cannoncpt/114516s.lua disk/startup.lua"); print(1) sleep(0.5); end c.reboot() exec(playerInfo); while true do local id, cmdrcv = rednet.receive(nil,25) if cmdrcv ==nil then unloadChunks(chunk1,chunk2,chunk3,chunk4) loaded = 0; elseif cmdrcv == 1 and loaded == 0 then loadChunks(chunk1,chunk2,chunk3,chunk4) loaded = 1; print(1) else print(2) end end 这个代码有什么用
06-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值