mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-12-01 22:43:43 +01:00
Fix drops
This commit is contained in:
parent
6f2c79e7e1
commit
1c990f6476
66
init.lua
66
init.lua
@ -68,6 +68,7 @@ local LINES = sfinv_only and 5 or 10
|
|||||||
local IPP = ROWS * LINES
|
local IPP = ROWS * LINES
|
||||||
local WH_LIMIT = 8
|
local WH_LIMIT = 8
|
||||||
local MAX_FAVS = 6
|
local MAX_FAVS = 6
|
||||||
|
local ITEM_BTN_SIZE = 1.1
|
||||||
|
|
||||||
local XOFFSET = sfinv_only and 3.83 or 11.2
|
local XOFFSET = sfinv_only and 3.83 or 11.2
|
||||||
local YOFFSET = sfinv_only and 4.9 or 1
|
local YOFFSET = sfinv_only and 4.9 or 1
|
||||||
@ -831,25 +832,27 @@ local function get_output_fs(data, fs, rcp, shapeless, right, btn_size, _btn_siz
|
|||||||
fs[#fs + 1] = fmt(FMT.tooltip, pos_x, pos_y, 0.5, 0.5, ESC(tooltip))
|
fs[#fs + 1] = fmt(FMT.tooltip, pos_x, pos_y, 0.5, 0.5, ESC(tooltip))
|
||||||
end
|
end
|
||||||
|
|
||||||
local arrow_X = right + (_btn_size or 1.1)
|
local arrow_X = right + (_btn_size or ITEM_BTN_SIZE)
|
||||||
local output_X = arrow_X + 0.9
|
local output_X = arrow_X + 0.9
|
||||||
local Y = YOFFSET + (sfinv_only and 2 or 0) + spacing
|
local Y = YOFFSET + (sfinv_only and 2 or 0) + spacing
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(FMT.image, arrow_X, Y + 0.2, 0.9, 0.7, PNG.arrow)
|
fs[#fs + 1] = fmt(FMT.image, arrow_X, Y + 0.2, 0.9, 0.7, PNG.arrow)
|
||||||
|
|
||||||
if rcp.type == "fuel" then
|
if rcp.type == "fuel" then
|
||||||
fs[#fs + 1] = fmt(FMT.animated_image, output_X, Y, 1.1, 1.1, PNG.fire_anim, 8, 180)
|
fs[#fs + 1] = fmt(FMT.animated_image, output_X, Y,
|
||||||
|
ITEM_BTN_SIZE, ITEM_BTN_SIZE, PNG.fire_anim, 8, 180)
|
||||||
else
|
else
|
||||||
local item = rcp.output
|
local item = rcp.output
|
||||||
item = clean_name(item)
|
item = clean_name(item)
|
||||||
local name = match(item, "%S*")
|
local name = match(item, "%S*")
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(FMT.image, output_X, Y, 1.1, 1.1, PNG.selected)
|
fs[#fs + 1] = fmt(FMT.image, output_X, Y,
|
||||||
|
ITEM_BTN_SIZE, ITEM_BTN_SIZE, PNG.selected)
|
||||||
|
|
||||||
local _name = sfinv_only and name or fmt("_%s", name)
|
local _name = sfinv_only and name or fmt("_%s", name)
|
||||||
|
|
||||||
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s;%s]",
|
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s;%s]",
|
||||||
output_X, Y, 1.1, 1.1, item, _name, "")
|
output_X, Y, ITEM_BTN_SIZE, ITEM_BTN_SIZE, item, _name, "")
|
||||||
|
|
||||||
|
|
||||||
local def = reg_items[name]
|
local def = reg_items[name]
|
||||||
@ -881,7 +884,7 @@ end
|
|||||||
|
|
||||||
local function get_grid_fs(data, fs, rcp, spacing)
|
local function get_grid_fs(data, fs, rcp, spacing)
|
||||||
local width = rcp.width or 1
|
local width = rcp.width or 1
|
||||||
local right, btn_size, _btn_size = 0, 1.1
|
local right, btn_size, _btn_size = 0, ITEM_BTN_SIZE
|
||||||
local cooktime, shapeless
|
local cooktime, shapeless
|
||||||
|
|
||||||
if rcp.type == "cooking" then
|
if rcp.type == "cooking" then
|
||||||
@ -1131,11 +1134,12 @@ local function get_panels(data, fs)
|
|||||||
local Y = spacing + 0.4
|
local Y = spacing + 0.4
|
||||||
|
|
||||||
if data.query_item == item then
|
if data.query_item == item then
|
||||||
fs[#fs + 1] = fmt(FMT.image, X, Y, 1.1, 1.1, PNG.selected)
|
fs[#fs + 1] = fmt(FMT.image, X, Y,
|
||||||
|
ITEM_BTN_SIZE, ITEM_BTN_SIZE, PNG.selected)
|
||||||
end
|
end
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(FMT.item_image_button,
|
fs[#fs + 1] = fmt(FMT.item_image_button,
|
||||||
X, Y, 1.1, 1.1, item, item, "")
|
X, Y, ITEM_BTN_SIZE, ITEM_BTN_SIZE, item, item, "")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1228,7 +1232,8 @@ local function make_fs(data)
|
|||||||
fs[#fs + 1] = fmt(FMT.image, X, Y, 1, 1, PNG.selected)
|
fs[#fs + 1] = fmt(FMT.image, X, Y, 1, 1, PNG.selected)
|
||||||
end
|
end
|
||||||
|
|
||||||
fs[#fs + 1] = fmt("item_image_button[%f,%f;1,1;%s;%s_inv;]", X, Y, item, item)
|
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s_inv;]",
|
||||||
|
X, Y, 1, 1, item, item)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (data.recipes and #data.recipes > 0) or (data.usages and #data.usages > 0) then
|
if (data.recipes and #data.recipes > 0) or (data.usages and #data.usages > 0) then
|
||||||
@ -1253,7 +1258,7 @@ craftguide.register_craft_type("digging", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
craftguide.register_craft_type("digging_chance", {
|
craftguide.register_craft_type("digging_chance", {
|
||||||
description = ES"Digging Chance",
|
description = ES"Digging (by chance)",
|
||||||
icon = "craftguide_mesepick.png",
|
icon = "craftguide_mesepick.png",
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -1440,12 +1445,21 @@ local function handle_drops_table(name, drop)
|
|||||||
if not dstack:is_empty() and dname ~= name then
|
if not dstack:is_empty() and dname ~= name then
|
||||||
local dcount = dstack:get_count()
|
local dcount = dstack:get_count()
|
||||||
|
|
||||||
if #di.items == 1 and di.rarity == 1 and max_start then
|
if #di.items == 1 and (not di.rarity or
|
||||||
|
di.rarity <= 1) and max_start then
|
||||||
|
-- TODO: add `tools`
|
||||||
if not drop_sure[dname] then
|
if not drop_sure[dname] then
|
||||||
drop_sure[dname] = 0
|
drop_sure[dname] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
drop_sure[dname] = drop_sure[dname] + dcount
|
if not drop_sure[dname].output then
|
||||||
|
drop_sure[dname].output = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
drop_sure[dname] = {
|
||||||
|
output = drop_sure[dname].output + dcount,
|
||||||
|
tools = di.tools,
|
||||||
|
}
|
||||||
|
|
||||||
if max_items_left then
|
if max_items_left then
|
||||||
max_items_left = max_items_left - 1
|
max_items_left = max_items_left - 1
|
||||||
@ -1474,12 +1488,12 @@ local function handle_drops_table(name, drop)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for item, count in pairs(drop_sure) do
|
for item, data in pairs(drop_sure) do
|
||||||
craftguide.register_craft{
|
craftguide.register_craft{
|
||||||
type = "digging",
|
type = "digging",
|
||||||
items = {name},
|
items = {name},
|
||||||
output = fmt("%s %u", item, count),
|
output = fmt("%s %u", item, data.output),
|
||||||
tools = drop.tools,
|
tools = data.tools,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1495,14 +1509,15 @@ local function handle_drops_table(name, drop)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function register_drops(name, drop)
|
local function register_drops(name, drop)
|
||||||
|
if true_str(drop) then
|
||||||
local dstack = ItemStack(drop)
|
local dstack = ItemStack(drop)
|
||||||
|
|
||||||
if not dstack:is_empty() and dstack:get_name() ~= name then
|
if not dstack:is_empty() and dstack:get_name() ~= name then
|
||||||
craftguide.register_craft{
|
craftguide.register_craft{
|
||||||
type = "digging",
|
type = "digging",
|
||||||
items = {name},
|
items = {name},
|
||||||
output = drop,
|
output = drop,
|
||||||
}
|
}
|
||||||
|
end
|
||||||
elseif is_table(drop) then
|
elseif is_table(drop) then
|
||||||
handle_drops_table(name, drop)
|
handle_drops_table(name, drop)
|
||||||
end
|
end
|
||||||
@ -1562,10 +1577,12 @@ local function get_init_items()
|
|||||||
recipes_cache = dslz(storage:get "recipes_cache")
|
recipes_cache = dslz(storage:get "recipes_cache")
|
||||||
else
|
else
|
||||||
print "[craftguide] Caching data (this may take a while)"
|
print "[craftguide] Caching data (this may take a while)"
|
||||||
local hash = {}
|
local _select, _preselect = {}, {}
|
||||||
|
|
||||||
for name, def in pairs(reg_items) do
|
for name, def in pairs(reg_items) do
|
||||||
if show_item(def) then
|
if name ~= "" and show_item(def) then
|
||||||
|
register_drops(name, def.drop)
|
||||||
|
|
||||||
if not fuel_cache[name] then
|
if not fuel_cache[name] then
|
||||||
cache_fuel(name)
|
cache_fuel(name)
|
||||||
end
|
end
|
||||||
@ -1575,16 +1592,19 @@ local function get_init_items()
|
|||||||
end
|
end
|
||||||
|
|
||||||
cache_usages(name)
|
cache_usages(name)
|
||||||
register_drops(name, def.drop)
|
|
||||||
|
|
||||||
if name ~= "" and recipes_cache[name] or usages_cache[name] then
|
_preselect[name] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for name in pairs(_preselect) do
|
||||||
|
if recipes_cache[name] or usages_cache[name] then
|
||||||
init_items[#init_items + 1] = name
|
init_items[#init_items + 1] = name
|
||||||
hash[name] = true
|
_select[name] = true
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
handle_aliases(hash)
|
handle_aliases(_select)
|
||||||
sort(init_items)
|
sort(init_items)
|
||||||
|
|
||||||
storage:set_string("init_items", slz(init_items))
|
storage:set_string("init_items", slz(init_items))
|
||||||
|
@ -56,7 +56,7 @@ No node pointed=Aucun bloc visé
|
|||||||
You don't know a recipe or usage for this item=Tu ne connais aucune recette pour ce bloc
|
You don't know a recipe or usage for this item=Tu ne connais aucune recette pour ce bloc
|
||||||
No recipe or usage for this item=Aucune recette pour ce bloc
|
No recipe or usage for this item=Aucune recette pour ce bloc
|
||||||
Digging=Destruction
|
Digging=Destruction
|
||||||
Digging Chance=Destruction chanceuse
|
Digging (by chance)=Destruction chanceuse
|
||||||
@1 of chance to drop=@1 de chance de tomber
|
@1 of chance to drop=@1 de chance de tomber
|
||||||
Mark this item=Mettre en favori.
|
Mark this item=Mettre en favori.
|
||||||
Unmark this item=Enlever des favoris.
|
Unmark this item=Enlever des favoris.
|
||||||
|
@ -56,7 +56,7 @@ No node pointed=
|
|||||||
You don't know a recipe or usage for this item=
|
You don't know a recipe or usage for this item=
|
||||||
No recipe or usage for this item=
|
No recipe or usage for this item=
|
||||||
Digging=
|
Digging=
|
||||||
Digging Chance=
|
Digging (by chance)=
|
||||||
@1 of chance to drop=
|
@1 of chance to drop=
|
||||||
Mark this item=
|
Mark this item=
|
||||||
Unmark this item=
|
Unmark this item=
|
||||||
|
Loading…
Reference in New Issue
Block a user