Lupus590

[CC] Name assignment via redstone strength

Nov 17th, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. local function sendID(ID) -- ID is a number which is tracked outside of this function, it should always be between 1 and 15
  2.   redstone.setAnalogOutput("front", ID) -- turn on redstone
  3.   repeat
  4.     print("waiting for confirmation")
  5.     os.pullEvent("redstone")
  6.   until redstone.getInput("front") -- this works directly against the turtle but not if there is redstone
  7.   redstone.setAnalogOutput("front", 0) -- turn off redstone
  8. end
  9.  
  10. local function reciveID()
  11.   while redstone.getAnalogInput("back") == 0 do -- if no signal then wait for one
  12.     os.pullEvent("redstone")
  13.   end
  14.   os.setComputerLabel("T"..tostring(redstone.getAnalogInput("back"))) -- signal strength is our number
  15.   redstone.setOutput("back", true) -- send confirmation signal
  16.   while redstone.getAnalogInput("back") ~= 0 do -- if the ID signal is still there then they haven't seen our confirmation yet
  17.     os.pullEvent("redstone")  -- when the ID signal is gone then they have seen our confirmation
  18.   end
  19.   redstone.setOutput("back", false) -- turn off confirmation signal
  20. end
Advertisement
Add Comment
Please, Sign In to add comment