Advertisement
Jahn_M_L

Spawner-Send

Mar 14th, 2023 (edited)
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.58 KB | Gaming | 0 0
  1. --start
  2. rednet.open("back")
  3. local c2 = {"sl"}
  4. local c3 = {"s", "z", "b", "e", "w"}
  5. status = {
  6.         fans = true,
  7.         skeleton = nil,
  8.         zombie = nil,
  9.         blaze = nil,
  10.         enderman = nil,
  11.         wither = nil,
  12.         slime = nil
  13.     }
  14.  
  15. --function is locking for the right reciever
  16. local function contains(val)
  17.    for i=1,#c2 do
  18.       if c2[i] == val then
  19.          return 2
  20.       end
  21.    end
  22.    for i=1,#c3 do
  23.       if c3[i] == val then
  24.          return 3
  25.       end
  26.    end
  27.    return false
  28. end
  29. --function for status update
  30. function statusUpdate(internel)
  31.     if (not internel) then
  32.         id, newStatus, pro = rednet.receive()
  33.         if (id==2) then
  34.             status["slime"] = newStatus["slime"]
  35.         elseif (id==3) then
  36.             status["skeleton"] = newStatus["skeleton"]
  37.             status["zombie"] = newStatus["zombie"]
  38.             status["blaze"] = newStatus["blaze"]
  39.             status["enderman"] = newStatus["enderman"]
  40.             status["wither"] = newStatus["wither"]
  41.         end
  42.     end
  43.     term.clear()
  44.     term.setCursorPos(1,1)
  45.     print("Fans: ", not redstone.getOutput("bottom"))
  46.     print("Skeleton: ", status["skeleton"])
  47.     print("Zombie: ", status["zombie"])
  48.     print("Blaze: ", status["blaze"])
  49.     print("Enderman: ", status["enderman"])
  50.     print("Wither-Skelton: ", status["wither"])
  51.     print("SLime: ", status["slime"])
  52. end
  53.  
  54. --main part
  55. statusUpdate(true)
  56. while true do
  57.     msg = read()
  58.     if (msg=="f") then
  59.         redstone.setOutput("bottom", not redstone.getOutput("bottom"))
  60.         statusUpdate(true)
  61.     else
  62.         receiver = contains(msg)
  63.         if (receiver == false) then
  64.             print("ERROR")
  65.         else
  66.             rednet.send(receiver, msg)
  67.             statusUpdate(false)
  68.         end
  69.     end
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement