Advertisement
Terraxel

Computercraft : Mobfarms server

Nov 14th, 2023 (edited)
802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | Gaming | 0 0
  1. os.loadAPI("touchpoint")
  2.  
  3. -- Setup rednet connection
  4. local protocolName = "megaleader_mobfarm"
  5. rednet.open("back")
  6.  
  7. -- Draw buttons
  8. local t = touchpoint.new("top")
  9. t:add("Blaze", nil, 2, 2, 14, 4)
  10. t:add("Enderman", nil, 17, 2, 28, 4)
  11.  
  12. t:add("Wither sk.", nil, 2, 6, 14, 8)
  13. t:add("Other 1", nil, 17, 6, 28, 8)
  14.  
  15. t:add("Other 2", nil, 2, 10, 14, 12)
  16. t:add("Pink slime", nil, 17, 10, 28, 12)
  17.  
  18. t:add("Global", nil, 2, 14, 28, 16)
  19.  
  20. t:draw()
  21.  
  22. -- Wait for events
  23. while true do
  24.     local event, mobId = t:handleEvents(os.pullEvent())
  25.     if event == "button_click" then
  26.         t:toggleButton(mobId)
  27.         local receiverMachine = rednet.lookup(protocolName, mobId)
  28.  
  29.         if receiverMachine == nil then
  30.             print("Machine not found")
  31.             t:toggleButton(mobId)
  32.         else
  33.             print("Toggling machine " ..mobId .."(" .. receiverMachine ..")")
  34.             rednet.send(receiverMachine, t:getActive(mobId), protocolName)
  35.         end
  36.     end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement