Advertisement
TheIncgi

Craft blocks 7.7.6+

Jul 10th, 2019
1,125
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. --set to gui open event
  2. local args = {...}
  3. if args[1] ~= "event" or args[2] ~= "GUIOpened" then
  4.   log("&7Block crafting script should be set to the GUIOpened event")  
  5.   return
  6. end
  7. if args[4] ~= "crafting table" then
  8.   return
  9. end
  10.  
  11. local item = "minecraft:iron_ingot"
  12. local inv  = openInventory()
  13. local map  = inv.mapping[args[4]]
  14.  
  15. local function findItem( inv, map, itemName )
  16.   local matches = {}
  17.   local n = 1
  18.   for a,b in pairs( map.main ) do
  19.     local item = inv.getSlot(b)
  20.     if item and item.id==itemName then
  21.       matches[n] = b
  22.       n = n+1
  23.     end
  24.   end
  25.   for a,b in pairs( map.hotbar ) do
  26.     local item = inv.getSlot(b)
  27.     if item and item.id==itemName then
  28.       matches[n] = b
  29.       n = n+1
  30.     end
  31.   end
  32.   return matches
  33. end
  34.  
  35.  
  36.  
  37. local function craftBlocks( inv, map, itemName )
  38.   local matches = findItem( inv, map, itemName )
  39.   while #matches >= 9 and args[3].isOpen() do
  40.     local ready = true
  41.     repeat
  42.       ready = true
  43.       matches = findItem( inv, map, itemName )
  44.       for i = 1, 9 do
  45.         if not inv.getSlot(map.craftingIn[i]) then
  46.           ready = false
  47.           inv.click( table.remove(matches,1))
  48.           inv.click( map.craftingIn[i] )
  49.           waitTick()
  50.         end
  51.       end
  52.     until(ready)
  53.     waitTick()
  54.     inv.quick(map.craftOut )  
  55.   end
  56. end
  57.  
  58. craftBlocks( inv, map, item )
Advertisement
Comments
  • TheOddChicken
    299 days
    # text 0.03 KB | 0 0
    1. what is this supposted to do?
    • TheIncgi
      298 days
      # text 0.12 KB | 0 0
      1. Advanced Macros for Minecraft.
      2. This script waits for a user to open a crafting table then auto crafts iron blocks from ingots
      • TheOddChicken
        298 days
        # text 0.04 KB | 0 0
        1. is it possible to change it to something else?
        • TheIncgi
          297 days
          # text 0.28 KB | 0 0
          1. Yea, around lines 43 & 44 you could look for specific items and put them in certain slots
          2.  
          3. 43, replace itemName with the ingredient you need (or lookup in a table or whatever)
          4. You can move it into the for loop too which may make it easier to pick out items per slot based on `i`
Add Comment
Please, Sign In to add comment
Advertisement