Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --set to gui open event
- local args = {...}
- if args[1] ~= "event" or args[2] ~= "GUIOpened" then
- log("&7Block crafting script should be set to the GUIOpened event")
- return
- end
- if args[4] ~= "crafting table" then
- return
- end
- local item = "minecraft:iron_ingot"
- local inv = openInventory()
- local map = inv.mapping[args[4]]
- local function findItem( inv, map, itemName )
- local matches = {}
- local n = 1
- for a,b in pairs( map.main ) do
- local item = inv.getSlot(b)
- if item and item.id==itemName then
- matches[n] = b
- n = n+1
- end
- end
- for a,b in pairs( map.hotbar ) do
- local item = inv.getSlot(b)
- if item and item.id==itemName then
- matches[n] = b
- n = n+1
- end
- end
- return matches
- end
- --return true if at or before version
- local function versionCompare(v)
- local check = v:gmatch("(%d+)%.?")
- for now in _MOD_VERSION:gmatch("(%d+)%.?") do
- if tonumber(check()) < tonumber(now) then
- return false
- end
- end
- return true
- end
- local function craftBlocks( inv, map, itemName )
- local matches = findItem( inv, map, itemName )
- while #matches >= 9 and args[3].isOpen() do
- local ready = true
- repeat
- ready = true
- matches = findItem( inv, map, itemName )
- for i = 1, 9 do
- if not inv.getSlot(map.craftingIn[i]) then
- ready = false
- inv.click( table.remove(matches,1))
- inv.click( map.craftingIn[i] )
- waitTick()
- end
- end
- until(ready)
- waitTick()
- inv.quick(map.craftOut + (versionCompare("7.7.6") and 1 or 0) )
- end
- end
- craftBlocks( inv, map, item )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement