1
0
mirror of https://github.com/Sokomine/cottages.git synced 2025-07-08 19:00:28 +02:00

stylua fixes

This commit is contained in:
flux
2023-01-22 19:36:23 -08:00
parent b58368ea6a
commit 0157649fa5
50 changed files with 945 additions and 980 deletions

View File

@ -42,7 +42,7 @@ function api.decrease_liquid_amount(pos)
end
local function empty_and_liquid(bucket_empty, liquid)
return table.concat({bucket_empty, liquid}, "::")
return table.concat({ bucket_empty, liquid }, "::")
end
function api.register_barrel_liquid(def)
@ -100,8 +100,8 @@ function api.add_barrel_liquid(pos, bucket_full)
api.increase_liquid_amount(pos)
minetest.sound_play(
{name = api.input_sound_by_liquid[liquid]},
{pos = pos, loop = false, gain = 0.5, pitch = 2.0}
{ name = api.input_sound_by_liquid[liquid] },
{ pos = pos, loop = false, gain = 0.5, pitch = 2.0 }
)
return api.get_bucket_empty(bucket_full)
@ -113,8 +113,8 @@ function api.drain_barrel_liquid(pos, bucket_empty)
api.decrease_liquid_amount(pos)
minetest.sound_play(
{name = api.output_sound_by_liquid[liquid]},
{pos = pos, loop = false, gain = 0.5, pitch = 2.0}
{ name = api.output_sound_by_liquid[liquid] },
{ pos = pos, loop = false, gain = 0.5, pitch = 2.0 }
)
return api.get_bucket_full(bucket_empty, liquid)

View File

@ -1,6 +1,8 @@
local S = cottages.S
local F = minetest.formspec_escape
local FS = function(...) return F(S(...)) end
local FS = function(...)
return F(S(...))
end
local max_liquid_amount = cottages.settings.barrel.max_liquid_amount
@ -14,7 +16,6 @@ function barrel.get_barrel_info(pos)
barrel.get_liquid_amount(pos),
max_liquid_amount
)
else
return S("Empty Barrel")
end
@ -22,17 +23,17 @@ end
function barrel.get_barrel_fs_parts(pos)
local parts = {
("size[8,9]"),
"size[8,9]",
("label[0,0.0;%s]"):format(FS("barrel (liquid storage)")),
("label[3,0;%s]"):format(FS("fill:")),
("list[context;input;3,0.5;1,1;]"),
"list[context;input;3,0.5;1,1;]",
("label[5,3.3;%s]"):format(FS("drain:")),
("list[context;output;5,3.8;1,1;]"),
("list[current_player;main;0,5;8,4;]"),
("listring[context;output]"),
("listring[current_player;main]"),
("listring[context;input]"),
("listring[current_player;main]"),
"list[context;output;5,3.8;1,1;]",
"list[current_player;main;0,5;8,4;]",
"listring[context;output]",
"listring[current_player;main]",
"listring[context;input]",
"listring[current_player;main]",
}
local liquid = barrel.get_barrel_liquid(pos)
@ -40,35 +41,50 @@ function barrel.get_barrel_fs_parts(pos)
if liquid then
local liquid_texture = barrel.texture_by_liquid[liquid]
table.insert(parts, ("image[2.6,2;2,3;%s^[resize:%ix%i^[lowpart:%s:%s]"):format(
F(cottages.textures.furniture),
max_liquid_amount, max_liquid_amount,
math.floor(max_liquid_amount * liquid_amount / max_liquid_amount),
F(liquid_texture
.. futil.escape_texture(("^[resize:%ix%i"):format(max_liquid_amount, max_liquid_amount)))
))
table.insert(parts, ("tooltip[2.6,2;2,3;%s]"):format(
F(("%s (%i/%i)"):format(
barrel.name_by_liquid[liquid],
barrel.get_liquid_amount(pos),
max_liquid_amount
)))
table.insert(
parts,
("image[2.6,2;2,3;%s^[resize:%ix%i^[lowpart:%s:%s]"):format(
F(cottages.textures.furniture),
max_liquid_amount,
max_liquid_amount,
math.floor(max_liquid_amount * liquid_amount / max_liquid_amount),
F(
liquid_texture
.. futil.escape_texture(("^[resize:%ix%i"):format(max_liquid_amount, max_liquid_amount))
)
)
)
table.insert(
parts,
("tooltip[2.6,2;2,3;%s]"):format(
F(
("%s (%i/%i)"):format(
barrel.name_by_liquid[liquid],
barrel.get_liquid_amount(pos),
max_liquid_amount
)
)
)
)
else
table.insert(parts, ("image[2.6,2;2,3;%s^[resize:%ix%i^[lowpart:%s:%s]"):format(
F(cottages.textures.furniture),
max_liquid_amount, max_liquid_amount,
0,
F(cottages.textures.furniture
.. futil.escape_texture(("^[resize:%ix%i"):format(max_liquid_amount, max_liquid_amount)))
))
table.insert(
parts,
("image[2.6,2;2,3;%s^[resize:%ix%i^[lowpart:%s:%s]"):format(
F(cottages.textures.furniture),
max_liquid_amount,
max_liquid_amount,
0,
F(
cottages.textures.furniture
.. futil.escape_texture(("^[resize:%ix%i"):format(max_liquid_amount, max_liquid_amount))
)
)
)
end
return parts
end
function barrel.can_dig(pos, player)
return barrel.get_liquid_amount(pos) == 0
end
@ -89,7 +105,6 @@ function barrel.allow_metadata_inventory_move(pos, from_list, from_index, to_lis
if barrel.can_drain(pos, item) then
return 1
end
elseif to_list == "output" then
if barrel.can_fill(pos, item) then
return 1
@ -106,7 +121,6 @@ function barrel.allow_metadata_inventory_put(pos, listname, index, stack, player
if barrel.can_drain(pos, item) then
return 1
end
elseif listname == "output" then
if barrel.can_fill(pos, item) then
return 1
@ -124,7 +138,6 @@ function barrel.on_metadata_inventory_put(pos, listname, index, stack, player)
if listname == "input" then
local empty = barrel.add_barrel_liquid(pos, name)
inv:set_stack(listname, index, empty)
elseif listname == "output" then
local full = barrel.drain_barrel_liquid(pos, name)
inv:set_stack(listname, index, full)
@ -144,13 +157,13 @@ cottages.api.register_machine("cottages:barrel", {
paramtype2 = "facedir",
drawtype = "mesh",
mesh = "cottages_barrel_closed.obj",
tiles = {"cottages_barrel.png"},
tiles = { "cottages_barrel.png" },
is_ground_content = false,
groups = {
snappy = 1,
choppy = 2,
oddly_breakable_by_hand = 1,
flammable = 2
flammable = 2,
},
sounds = cottages.sounds.wood,

View File

@ -8,7 +8,7 @@ local rotations = {
minetest.register_lbm({
label = "Convert lying barrels",
name = "cottages:convert_lying_barrels",
nodenames = {"cottages:barrel_lying", "cottages:barrel_lying_open"},
nodenames = { "cottages:barrel_lying", "cottages:barrel_lying_open" },
run_at_every_load = false,
action = function(pos, node)
node.name = string.gsub(node.name, "_lying", "")
@ -16,5 +16,5 @@ minetest.register_lbm({
minetest.swap_node(pos, node)
cottages.api.update(pos, node)
end
end,
})

View File

@ -4,18 +4,18 @@ if ci.wood and ci.steel then
minetest.register_craft({
output = "cottages:barrel",
recipe = {
{ci.wood, ci.wood, ci.wood},
{ci.steel, "", ci.steel},
{ci.wood, ci.wood, ci.wood},
{ ci.wood, ci.wood, ci.wood },
{ ci.steel, "", ci.steel },
{ ci.wood, ci.wood, ci.wood },
},
})
minetest.register_craft({
output = "cottages:barrel_open",
recipe = {
{ci.wood, "", ci.wood},
{ci.steel, "", ci.steel},
{ci.wood, ci.wood, ci.wood},
{ ci.wood, "", ci.wood },
{ ci.steel, "", ci.steel },
{ ci.wood, ci.wood, ci.wood },
},
})
end
@ -23,14 +23,14 @@ end
minetest.register_craft({
output = "cottages:tub 2",
recipe = {
{"cottages:barrel"},
{ "cottages:barrel" },
},
})
minetest.register_craft({
output = "cottages:barrel",
recipe = {
{"cottages:tub"},
{"cottages:tub"},
{ "cottages:tub" },
{ "cottages:tub" },
},
})

View File

@ -7,7 +7,7 @@ minetest.register_node("cottages:barrel_open", {
paramtype = "light",
paramtype2 = "facedir",
mesh = "cottages_barrel.obj",
tiles = {"cottages_barrel.png"},
tiles = { "cottages_barrel.png" },
is_ground_content = false,
groups = {
snappy = 1,
@ -23,22 +23,24 @@ minetest.register_node("cottages:tub", {
paramtype = "light",
drawtype = "mesh",
mesh = "cottages_tub.obj",
tiles = {"cottages_barrel.png"},
tiles = { "cottages_barrel.png" },
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.1, 0.5},
}},
collision_box = {
{ -0.5, -0.5, -0.5, 0.5, -0.1, 0.5 },
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.1, 0.5},
}},
{ -0.5, -0.5, -0.5, 0.5, -0.1, 0.5 },
},
},
groups = {
snappy = 1,
choppy = 2,
oddly_breakable_by_hand = 1,
flammable = 2
flammable = 2,
},
is_ground_content = false,
})