Skip to content
This repository has been archived by the owner on Aug 20, 2020. It is now read-only.

Commit

Permalink
[skyblock_levels] Remember to compare item groups
Browse files Browse the repository at this point in the history
 - Fix #167 by always comparing item groups
 - Some logging was cleaned up
  • Loading branch information
Lymkwi committed Sep 15, 2016
1 parent 1231fb9 commit ab41ebb
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions mods/skyblock_levels/register_misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ minetest.register_on_dieplayer(function(player)

end)

-- "group:xxxx" should always be a
function compare_items(a, b)
return a == b or minetest.get_item_group(b, a:split(':')[2]) > 0
end

-- player receive fields
minetest.register_on_player_receive_fields(function(player, formname, fields)
-- restart
Expand Down Expand Up @@ -91,7 +96,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local all_possible_recipes = minetest.get_all_craft_recipes(outstack.name)
local our_recipe

if not all_possible_recipes then return end -- This is a toolrepair, and for some reason it has nothing registered
if not all_possible_recipes then
minetest.log("Error 0")
return
end -- This is a toolrepair, and for some reason it has nothing registered
if #all_possible_recipes == 1 then
our_recipe = all_possible_recipes[1]
end
Expand Down Expand Up @@ -157,7 +165,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)

-- Step 4.1.2.2.2 : Recipe with one of width
elseif recipe.width == 1 then
minetest.log(dump(recipe))
-- Step 4.1.2.2.2.1 : Vertical analysis of the items
local recheight = #recipe.items
local reclock = (recheight == 3)
Expand Down Expand Up @@ -190,7 +197,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
iterdelay = iterdelay + 1
end
if iterlock then -- We start to check from here
valid = valid and ((stack or {name=nil}).name == recipe.items[y - iterdelay])
valid = valid and compare_items(recipe.items[y - iterdelay], (stack or {name=nil}).name)
end
end
if valid then
Expand Down Expand Up @@ -228,7 +235,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
if iterlock then -- We've gotta check from here
valid = valid and
(stack or {name = nil}).name == recipe.items[(x-iterdelay-1)*2+({[3]=y,[1]=y-1})[emptycol]]
compare_items(recipe.items[(x-iterdelay-1)*2+({[3]=y,[1]=y-1})[emptycol]], (stack or {name = nil}).name)
end
end
if not valid then break end
Expand All @@ -242,12 +249,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- Step 4.1.2.2.4
elseif recipe.width == 3 then
-- Easier since we can just check one by one
minetest.log(dump(recipe))
local valid = true
for y=1,3 do
for x = 1,3 do
local stack = craftgrid[x][y]
valid = valid and (stack or {name = nil}).name == recipe.items[(y-1)*3+x]
valid = valid and compare_items(recipe.items[(y-1)*3+x], (stack or {name = nil}).name)
end
if not valid then minetest.log(y) break end
end
Expand Down

0 comments on commit ab41ebb

Please sign in to comment.