Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --not my code
- function split(pString, pPattern)
- local Table = {} -- NOTE: use {n = 0} in Lua-5.0
- 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
- --not my code
- --now my code VVV
- local function figureoutwhoiam()
- local cpulabel = os.getComputerLabel()
- local id = split(cpulabel,"_")[3]
- local x = split(id,"-")[2]
- local z = split(id,"-")[1]
- print("I am:",id.."!")
- return {x,z,id}
- end
- local allowed = true
- local modem = peripheral.wrap("left")
- if not modem then turtle.equipLeft() turtle.equipLeft() end
- modem.open(40)
- local iam = figureoutwhoiam()
- coroutine.wrap(function()
- print("Reload Function Waiting")
- while true do
- local event,side,freq,rpfreq,msg,distance = os.pullEvent("modem_message")
- print("Modem Message Received:","ID:",freq)
- if freq == 30+10*iam[2] and msg.Reason ~= nil and msg.Reason == "Reload" then
- print("Reloading")
- allowed = false
- break
- end
- end
- end)
- while allowed do
- if turtle.detect() then
- local suc,data = turtle.inspect()
- if suc and data.name == "minecraft:log" then
- print("Tree Detected")
- modem.transmit(30+10*iam[2],30+10*iam[2],{Reason="TreeGrew",Pos=iam[1]})
- repeat sleep(0.1) until not turtle.detect()
- print("Tree No Longer Detected")
- end
- end
- end
- shell.run("reload")
Add Comment
Please, Sign In to add comment