mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-26 04:23:44 +01:00
Cleaning
This commit is contained in:
parent
64ca5e8188
commit
4b3ab0af5f
43
init.lua
43
init.lua
@ -891,14 +891,13 @@ local function get_stack_max(data, is_recipe, rcp)
|
|||||||
return max_stacks
|
return max_stacks
|
||||||
end
|
end
|
||||||
|
|
||||||
local function craft_stack(player, pname, data, _f)
|
local function craft_stack(player, pname, data, craft_rcp)
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
local rcp_usg = _f.craft_rcp and "recipe" or "usage"
|
local rcp_usg = craft_rcp and "recipe" or "usage"
|
||||||
local output = _f.craft_rcp and
|
local output = craft_rcp and data.recipes[data.rnum].output or data.usages[data.unum].output
|
||||||
data.recipes[data.rnum].output or data.usages[data.unum].output
|
|
||||||
output = ItemStack(output)
|
output = ItemStack(output)
|
||||||
local stackname, stackcount = output:get_name(), output:get_count()
|
local stackname, stackcount = output:get_name(), output:get_count()
|
||||||
local scrbar_val = data[sprintf("scrbar_%s", _f.craft_rcp and "rcp" or "usg")]
|
local scrbar_val = data[sprintf("scrbar_%s", craft_rcp and "rcp" or "usg")]
|
||||||
|
|
||||||
for name, count in pairs(data.export_counts[rcp_usg].rcp) do
|
for name, count in pairs(data.export_counts[rcp_usg].rcp) do
|
||||||
local items = {[name] = count}
|
local items = {[name] = count}
|
||||||
@ -1120,20 +1119,18 @@ local function get_output_fs(fs, data, rcp, shapeless, right, btn_size, _btn_siz
|
|||||||
fs(fmt("image", arrow_X, Y + 0.06, 1, 1, PNG.arrow))
|
fs(fmt("image", arrow_X, Y + 0.06, 1, 1, PNG.arrow))
|
||||||
|
|
||||||
if rcp.type == "fuel" then
|
if rcp.type == "fuel" then
|
||||||
fs(fmt("animated_image",
|
fs(fmt("animated_image", X, Y, ITEM_BTN_SIZE, ITEM_BTN_SIZE, PNG.fire_anim, 8, 180))
|
||||||
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*")
|
||||||
|
local bt_s = ITEM_BTN_SIZE * 1.2
|
||||||
|
|
||||||
fs(fmt("image",
|
fs(fmt("image", X, Y - 0.11, bt_s, bt_s, PNG.selected))
|
||||||
X, Y - 0.11, ITEM_BTN_SIZE * 1.2, ITEM_BTN_SIZE * 1.2, PNG.selected))
|
|
||||||
|
|
||||||
local _name = sprintf("_%s", name)
|
local _name = sprintf("_%s", name)
|
||||||
|
|
||||||
fs(fmt("item_image_button",
|
fs(fmt("item_image_button", X + 0.1, Y, ITEM_BTN_SIZE, ITEM_BTN_SIZE, item, _name, ""))
|
||||||
X + 0.1, Y, ITEM_BTN_SIZE, ITEM_BTN_SIZE, item, _name, ""))
|
|
||||||
|
|
||||||
local def = reg_items[name]
|
local def = reg_items[name]
|
||||||
local unknown = not def or nil
|
local unknown = not def or nil
|
||||||
@ -1227,8 +1224,7 @@ local function get_grid_fs(fs, data, rcp)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not added then
|
if not added then
|
||||||
label = sprintf("%s%s\nR",
|
label = sprintf("%s%s\nR", label ~= "" and "\n" or "", label)
|
||||||
label ~= "" and "\n" or "", label)
|
|
||||||
replace.items[#replace.items + 1] = replacement[2]
|
replace.items[#replace.items + 1] = replacement[2]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1350,16 +1346,14 @@ local function get_title_fs(fs, data)
|
|||||||
local fav_marked = sprintf("craftguide_fav%s.png", fav and "_off" or "")
|
local fav_marked = sprintf("craftguide_fav%s.png", fav and "_off" or "")
|
||||||
|
|
||||||
fs(sprintf("style[fav;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]",
|
fs(sprintf("style[fav;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]",
|
||||||
sprintf("craftguide_fav%s.png", fav and "" or "_off"),
|
sprintf("craftguide_fav%s.png", fav and "" or "_off"), fav_marked, fav_marked),
|
||||||
fav_marked, fav_marked),
|
|
||||||
fmt("image_button", star_x, star_y, star_size, star_size, "", "fav", ""),
|
fmt("image_button", star_x, star_y, star_size, star_size, "", "fav", ""),
|
||||||
sprintf("tooltip[fav;%s]", fav and ES"Unmark this item" or ES"Mark this item"))
|
sprintf("tooltip[fav;%s]", fav and ES"Unmark this item" or ES"Mark this item"))
|
||||||
else
|
else
|
||||||
fs(sprintf("style[nofav;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]",
|
fs(sprintf("style[nofav;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]",
|
||||||
"craftguide_fav_off.png", PNG.nothing, PNG.nothing),
|
"craftguide_fav_off.png", PNG.nothing, PNG.nothing),
|
||||||
fmt("image_button", star_x, star_y, star_size, star_size, "", "nofav", ""),
|
fmt("image_button", star_x, star_y, star_size, star_size, "", "nofav", ""),
|
||||||
sprintf("tooltip[nofav;%s]",
|
sprintf("tooltip[nofav;%s]", ES"Cannot mark this item. Bookmark limit reached."))
|
||||||
ES"Cannot mark this item. Bookmark limit reached."))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fs("style_type[label;font=bold;font_size=+6]",
|
fs("style_type[label;font=bold;font_size=+6]",
|
||||||
@ -1486,8 +1480,7 @@ local function get_panels(fs, data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
fs(fmt("bg9",
|
fs(fmt("bg9", data.xoffset + 0.1, data.yoffset, 7.9, panel.height, PNG.bg_full, 10))
|
||||||
data.xoffset + 0.1, data.yoffset, 7.9, panel.height, PNG.bg_full, 10))
|
|
||||||
|
|
||||||
local is_recipe, is_usage = panel.name == "recipes", panel.name == "usages"
|
local is_recipe, is_usage = panel.name == "recipes", panel.name == "usages"
|
||||||
|
|
||||||
@ -1842,9 +1835,7 @@ local function fields(player, _f)
|
|||||||
if _f.quit then return end
|
if _f.quit then return end
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = pdata[name]
|
local data = pdata[name]
|
||||||
|
local sb_rcp, sb_usg = _f.scrbar_rcp, _f.scrbar_usg
|
||||||
local scrbar_rcp_CHG = _f.scrbar_rcp and sub(_f.scrbar_rcp, 1, 3) == "CHG"
|
|
||||||
local scrbar_usg_CHG = _f.scrbar_usg and sub(_f.scrbar_usg, 1, 3) == "CHG"
|
|
||||||
|
|
||||||
if _f.clear then
|
if _f.clear then
|
||||||
reset_data(data)
|
reset_data(data)
|
||||||
@ -1902,12 +1893,12 @@ local function fields(player, _f)
|
|||||||
data.export_usg = not data.export_usg
|
data.export_usg = not data.export_usg
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif scrbar_rcp_CHG or scrbar_usg_CHG then
|
elseif (sb_rcp and sub(sb_rcp, 1, 3) == "CHG") or (sb_usg and sub(sb_usg, 1, 3) == "CHG") then
|
||||||
data.scrbar_rcp = _f.scrbar_rcp and tonum(match(_f.scrbar_rcp, "%d+"))
|
data.scrbar_rcp = sb_rcp and tonum(match(sb_rcp, "%d+"))
|
||||||
data.scrbar_usg = _f.scrbar_usg and tonum(match(_f.scrbar_usg, "%d+"))
|
data.scrbar_usg = sb_usg and tonum(match(sb_usg, "%d+"))
|
||||||
|
|
||||||
elseif _f.craft_rcp or _f.craft_usg then
|
elseif _f.craft_rcp or _f.craft_usg then
|
||||||
craft_stack(player, name, data, _f)
|
craft_stack(player, name, data, _f.craft_rcp)
|
||||||
else
|
else
|
||||||
select_item(player, data, _f)
|
select_item(player, data, _f)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user