Advertisement
Neon1432

Library\programs\rednet\autofurnace\sender.lua

Apr 9th, 2022
662
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. local param = ...
  2. dofile("bs/apis/wrapper")
  3.  
  4.  
  5.  
  6. --initialization
  7.  
  8.  
  9.  
  10. local args = bs.params.load("bs/files/furnace_sender_params")
  11.  
  12. local hook = bs.rdnt.hook:new()
  13. hook.port = args.port
  14. hook.socketID = args.socketID
  15. hook:connect(1)
  16.  
  17. if param == "connect" then
  18.     args.socketID = nil
  19. end
  20.  
  21.  
  22.  
  23. --methods and classes
  24.  
  25.  
  26.  
  27. local function setParams()
  28.     local stable = {}
  29.     ui.clear()
  30.     stable.port = ui.getInput("Which name should this connection have?")
  31.     ui.clear()
  32.     stable.count = ui.getInput("How many furnaces are setup?", true)
  33.     ui.clear()
  34.     hook:request("setParams", stable)
  35.     args.port = stable.port
  36.     args.socketID = hook.socketID
  37.     hook.port = stable.port
  38.     bs.params.save("bs/files/furnace_sender_params", args)
  39. end
  40.  
  41.  
  42.  
  43. --program start
  44.  
  45.  
  46.  
  47. if args.socketID == nil or args.port == nil then
  48.     hook.port = "autofurnace"
  49.     hook:connect()
  50.     setParams()
  51. end
  52.  
  53. while true do
  54.     local _, returns = hook:request("test", ui.getInput("a test string: "))
  55.     ui.clear()
  56.     print(returns.."\n")
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement