Advertisement
Sir_Popsilots

CastingMechine

Aug 3rd, 2021 (edited)
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. local modem = peripheral.find("modem")
  2. modem.open(3777)
  3.  
  4. local function CastBlocks(numOfBlocks)
  5.     while numOfBlocks > 0 do
  6.         print("smelting",numOfBlocks,"blocks")
  7.         if numOfBlocks >=3 then
  8.             numOfBlocks = numOfBlocks - 3
  9.             redstone.setOutput("back",true)
  10.             sleep(1)
  11.             redstone.setOutput("back",false)
  12.         elseif numOfBlocks >=2 then
  13.             numOfBlocks = numOfBlocks - 2
  14.             redstone.setOutput("front",true)
  15.             sleep(0.15)
  16.             redstone.setOutput("left",true)
  17.             sleep(1)
  18.             redstone.setOutput("front",false)
  19.             redstone.setOutput("left",false)
  20.         else
  21.             numOfBlocks = numOfBlocks - 1
  22.             redstone.setOutput("front",true)
  23.             sleep(1)
  24.             redstone.setOutput("front",false)
  25.         end
  26.         sleep(1)
  27.         os.pullEvent("redstone")
  28.         print("A redstone input has changed!")
  29.         sleep(2)
  30.     end
  31. end
  32.  
  33. local function CastIngots(numOfIngots)
  34.     while numOfIngots > 0 do
  35.         print("smelting",numOfIngots,"Ingots")
  36.         redstone.setOutput("right",true)
  37.         sleep(1)
  38.         redstone.setOutput("right",false)
  39.         sleep(0.3)
  40.         numOfIngots = numOfIngots - 1
  41.         os.pullEvent("redstone")
  42.         print("A redstone input has changed!")
  43.         sleep(2)
  44.     end
  45. end
  46.  
  47. while true do
  48.     local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  49.     if message[2] == "Blocks" then
  50.         CastBlocks(message[1])
  51.         modem.transmit(3777,3777,"done")
  52.     elseif message[2] == "Ingots" then
  53.         CastIngots(message[1])
  54.         modem.transmit(3777,3777,"done")
  55.     end
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement