Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sendScore = false
- local score = 0
- s = peripheral.wrap("left")
- w = peripheral.wrap("right")
- w.open(101)
- function hasItemFrameInFront()
- items = s.getEntityIds("item_frame")
- if #items > 0 then
- for i, j in pairs(items) do
- data = s.getEntityData(items[i], "item_frame")
- pos = data.all().position
- if math.floor(pos.x) == 0 and math.floor(pos.y) == 0 and math.floor(pos.z) == 0 then
- return true
- end
- end
- end
- return false
- end
- function receiveData()
- while 1 do
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- if senderChannel == 101 then
- if message == "p" then
- local ok, val = pcall(hasItemFrameInFront)
- if ok == true and val == false then
- sendScore = true
- turtle.place()
- end
- elseif message == "s" then
- exit()
- end
- end
- sleep(0.1)
- end
- end
- function sendData()
- while 1 do
- if sendScore then
- w.transmit(101,101,"+")
- sendScore = false
- end
- sleep(0.1)
- end
- end
- parallel.waitForAll(receiveData, sendData)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement