NMDanny

Auto-Spawner : Spawn

Jul 14th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. local typex="Cow"
  2. local sens=peripheral.wrap("right") -- sensor side
  3. local RSside="left" -- redstone side
  4. local amount=5 -- how many mobs you want to spawn
  5. local active=0
  6. while true do
  7.     local counter=0
  8.     if active==0 then
  9.         print("Press the spacebar button in order to spawn a "..typex.." "..amount.." times.")
  10.         local event,scancode=os.pullEvent("key")
  11.         if scancode==57 then
  12.             redstone.setOutput(RSside,true)
  13.             active=1
  14.         end
  15.     else
  16.    
  17.         for i,v in ipairs(sens.getMobIds()) do
  18.             if sens.getMobData(v)["type"]==typex then
  19.                 counter=counter+1
  20.                 print("Mob number "..counter.." spawned.")
  21.                 if counter==amount then
  22.                     print("All mobs spawned, halting.")
  23.                     redstone.setOutput(RSside,false)
  24.                     active=0
  25.                 end
  26.             end
  27.         end
  28.     end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment