t8rt0t

clib.lua

Jul 10th, 2024 (edited)
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. local mag = assert(peripheral.find("magnetic_card_manipulator"))
  2. local blockReader = assert(peripheral.find("blockReader"))
  3. local expect = require("cc.expect").expect
  4.  
  5. local function deployerClick()
  6.     local state = blockReader.getBlockData().State
  7.     while state ~= "EXPANDING" do
  8.         redstone.setAnalogOutput("top",15)
  9.         sleep(0.05)
  10.         state = blockReader.getBlockData().State
  11.     end
  12.     while state == "EXPANDING" do
  13.         redstone.setAnalogOutput("top",15)
  14.         sleep(0.05)
  15.         state = blockReader.getBlockData().State
  16.     end
  17.     redstone.setAnalogOutput("top",0)
  18. end
  19.  
  20. return function(cmd)
  21.     expect(1,cmd,"string")
  22.     local json = textutils.serialiseJSON({
  23.             text=string.format("%x-%x-%x",math.random(16^6),math.random(16^2),math.random(16^5)),
  24.             clickEvent={
  25.                 action="run_command",
  26.                 value=cmd
  27.             }
  28.         })
  29.     while not mag.writeCard(json) do
  30.         sleep(0.05)
  31.     end
  32.     sleep(0.25) --Wait for other deployer to click
  33.     deployerClick()
  34. end
Advertisement
Add Comment
Please, Sign In to add comment