Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

Commit 24d8fae

Browse files
committed
Minor style cleaning
1 parent 58b2f49 commit 24d8fae

File tree

1 file changed

+31
-25
lines changed

1 file changed

+31
-25
lines changed

init.lua

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ local function get_usages(item)
556556
end
557557

558558
local function get_burntime(item)
559-
return get_craft_result({method = "fuel", items = {item}}).time
559+
return get_craft_result{method = "fuel", items = {item}}.time
560560
end
561561

562562
local function cache_fuel(item)
@@ -929,15 +929,21 @@ local function get_panels(data, fs)
929929

930930
if k ~= "favs" then
931931
local fav = is_fav(data)
932+
local nfavs = #data.favs
932933

933934
fs[#fs + 1] = fmt(
934935
"style[fav;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]",
935936
fmt("craftguide_fav%s.png", fav and "" or "_off"),
936937
fmt("craftguide_fav%s.png", fav and "_off" or ""),
937938
fmt("craftguide_fav%s.png", fav and "_off" or ""))
938939

939-
fs[#fs + 1] = fmt(FMT.image_button,
940-
14, spacing, 0.5, 0.45, "", "fav", "")
940+
if nfavs < 6 or (nfavs >= 6 and fav) then
941+
fs[#fs + 1] = fmt(FMT.image_button,
942+
14, spacing, 0.5, 0.45, "", "fav", "")
943+
end
944+
945+
fs[#fs + 1] = fmt("tooltip[fav;%s]",
946+
fav and ES"Unmark this item" or ES"Mark this item")
941947
end
942948
end
943949

@@ -1369,20 +1375,20 @@ local function handle_drops_table(name, drop)
13691375
end
13701376

13711377
for item, count in pairs(drop_sure) do
1372-
craftguide.register_craft({
1378+
craftguide.register_craft{
13731379
type = "digging",
13741380
items = {name},
13751381
output = fmt("%s %u", item, count),
1376-
})
1382+
}
13771383
end
13781384

13791385
for item, data in pairs(drop_maybe) do
1380-
craftguide.register_craft({
1386+
craftguide.register_craft{
13811387
type = "digging_chance",
13821388
items = {name},
13831389
output = fmt("%s %u", item, data.output),
13841390
rarity = data.rarity,
1385-
})
1391+
}
13861392
end
13871393
end
13881394

@@ -1391,11 +1397,11 @@ local function register_drops(name, def)
13911397
local dstack = ItemStack(drop)
13921398

13931399
if not dstack:is_empty() and dstack:get_name() ~= name then
1394-
craftguide.register_craft({
1400+
craftguide.register_craft{
13951401
type = "digging",
13961402
items = {name},
13971403
output = drop,
1398-
})
1404+
}
13991405
elseif is_table(drop) then
14001406
handle_drops_table(name, drop)
14011407
end
@@ -1506,10 +1512,10 @@ local function get_init_items()
15061512
fuel = fuel_cache,
15071513
}
15081514

1509-
http.fetch_async({
1515+
http.fetch_async{
15101516
url = craftguide.export_url,
15111517
post_data = write_json(post_data),
1512-
})
1518+
}
15131519
end
15141520

15151521
print()
@@ -1720,29 +1726,29 @@ else
17201726
end
17211727
})
17221728

1723-
core.register_craft({
1729+
core.register_craft{
17241730
output = "craftguide:book",
17251731
type = "shapeless",
17261732
recipe = {"default:book"}
1727-
})
1733+
}
17281734

1729-
core.register_craft({
1735+
core.register_craft{
17301736
type = "fuel",
17311737
recipe = "craftguide:book",
17321738
burntime = 3
1733-
})
1739+
}
17341740

1735-
core.register_craft({
1741+
core.register_craft{
17361742
output = "craftguide:sign",
17371743
type = "shapeless",
17381744
recipe = {"default:sign_wall_wood"}
1739-
})
1745+
}
17401746

1741-
core.register_craft({
1747+
core.register_craft{
17421748
type = "fuel",
17431749
recipe = "craftguide:sign",
17441750
burntime = 10
1745-
})
1751+
}
17461752

17471753
if rawget(_G, "sfinv_buttons") then
17481754
sfinv_buttons.register_button("craftguide", {
@@ -1958,29 +1964,29 @@ if progressive_mode then
19581964
end
19591965

19601966
data.hud = {
1961-
bg = player:hud_add({
1967+
bg = player:hud_add{
19621968
hud_elem_type = "image",
19631969
position = {x = 0.78, y = 1},
19641970
alignment = {x = 1, y = 1},
19651971
scale = {x = 370, y = 112},
19661972
text = PNG.bg,
1967-
}),
1973+
},
19681974

1969-
book = player:hud_add({
1975+
book = player:hud_add{
19701976
hud_elem_type = "image",
19711977
position = {x = 0.79, y = 1.02},
19721978
alignment = {x = 1, y = 1},
19731979
scale = {x = 4, y = 4},
19741980
text = PNG.book,
1975-
}),
1981+
},
19761982

1977-
text = player:hud_add({
1983+
text = player:hud_add{
19781984
hud_elem_type = "text",
19791985
position = {x = 0.84, y = 1.04},
19801986
alignment = {x = 1, y = 1},
19811987
number = 0xfff,
19821988
text = "",
1983-
}),
1989+
},
19841990
}
19851991
end)
19861992

0 commit comments

Comments
 (0)