Advertisement
montana_1

placeTorch

Nov 16th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.52 KB | None | 0 0
  1. -- Function to place torch --
  2. function placeTorch() -- Optionally add functionality to place torch when no torch can be placed
  3.     local torch = false
  4.     for i = 1, 16 do -- loop through the slots
  5.         turtle.select(i) -- change to the slot
  6.         local x = turtle.getItemDetail(i)
  7.         if(x ~= nil) then
  8.             local istr = string.sub(x.name,string.find(x.name,":",0)+1)
  9.             if(istr == "torch") then
  10.                 if(turtle.place()) then
  11.                     torch = true
  12.                     turtle.select(1)
  13.                 end
  14.             end
  15.         end
  16.     end
  17.     turtle.select(1)
  18.     return torch
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement