1
0
mirror of https://github.com/Sokomine/cottages.git synced 2025-07-12 21:00:19 +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

@ -4,9 +4,9 @@ if ci.stick and ci.tree and ci.stick and ci.bucket then
minetest.register_craft({
output = "cottages:water_gen",
recipe = {
{ci.stick, "", ""},
{ci.tree, ci.bucket, ci.tree},
{ci.tree, ci.tree, ci.tree},
}
{ ci.stick, "", "" },
{ ci.tree, ci.bucket, ci.tree },
{ ci.tree, ci.tree, ci.tree },
},
})
end

View File

@ -5,8 +5,8 @@ minetest.register_entity("cottages:bucket_entity", {
visual = "wielditem",
automatic_rotate = 1,
wield_item = ci.bucket,
visual_size = {x = 0.33, y = 0.33},
collisionbox = {0, 0, 0, 0, 0, 0},
visual_size = { x = 0.33, y = 0.33 },
collisionbox = { 0, 0, 0, 0, 0, 0 },
pointable = false,
physical = false,
static_save = false,
@ -25,8 +25,8 @@ minetest.register_entity("cottages:bucket_entity", {
local obj = self.object
obj:set_properties({wield_item = staticdata})
obj:set_armor_groups({immortal = 1})
obj:set_properties({ wield_item = staticdata })
obj:set_armor_groups({ immortal = 1 })
end,
on_punch = function()

View File

@ -1,6 +1,8 @@
local F = minetest.formspec_escape
local S = cottages.S
local FS = function(...) return F(S(...)) end
local FS = function(...)
return F(S(...))
end
local s = cottages.sounds
local t = cottages.textures
@ -16,7 +18,7 @@ local well_fill_time = cottages.settings.water.well_fill_time
function water.get_well_fs_parts(pos)
return {
("size[8,9]"),
"size[8,9]",
("label[3.0,0.0;%s]"):format(FS("Tree trunk well")),
("label[0,0.7;%s]"):format(FS("Punch the well while wielding an empty bucket.")),
("label[0,1.0;%s]"):format(FS("Your bucket will slowly be filled with river water.")),
@ -25,9 +27,9 @@ function water.get_well_fs_parts(pos)
("label[1.0,2.9;%s]"):format(FS("Internal bucket storage (passive storage only):")),
("item_image[0,2.8;1.0,1.0;%s]"):format(F(ci.bucket)),
("item_image[0,3.8;1.0,1.0;%s]"):format(F(ci.bucket_filled)),
("list[context;main;1,3.3;8,1;]"),
("list[current_player;main;0,4.85;8,4;]"),
("listring[]"),
"list[context;main;1,3.3;8,1;]",
"list[current_player;main;0,4.85;8,4;]",
"listring[]",
}
end
@ -42,7 +44,7 @@ function water.use_well(pos, puncher)
local pinv = puncher:get_inventory()
local bucket = meta:get("bucket")
local entity_pos = vector.add(pos, vector.new(0, 1/4, 0))
local entity_pos = vector.add(pos, vector.new(0, 1 / 4, 0))
if not bucket then
local wielded = puncher:get_wielded_item()
@ -58,19 +60,13 @@ function water.use_well(pos, puncher)
timer:start(well_fill_time)
water.add_filling_effects(pos)
elseif wielded_name == ci.bucket_filled then
-- empty a bucket
pinv:remove_item("main", ci.bucket_filled)
pinv:add_item("main", ci.bucket)
minetest.sound_play(
{name = s.water_empty},
{pos = entity_pos, gain = 0.5, pitch = 2.0},
true
)
minetest.sound_play({ name = s.water_empty }, { pos = entity_pos, gain = 0.5, pitch = 2.0 }, true)
end
elseif bucket == ci.bucket then
minetest.chat_send_player(player_name, S("Please wait until your bucket has been filled."))
local timer = minetest.get_node_timer(pos)
@ -78,11 +74,10 @@ function water.use_well(pos, puncher)
timer:start(well_fill_time)
water.add_filling_effects(pos)
end
elseif bucket == ci.bucket_filled then
meta:set_string("bucket", "")
for _, obj in ipairs(minetest.get_objects_inside_radius(entity_pos, .1)) do
for _, obj in ipairs(minetest.get_objects_inside_radius(entity_pos, 0.1)) do
local ent = obj:get_luaentity()
if ent and ent.name == "cottages:bucket_entity" then
obj:remove()
@ -94,7 +89,7 @@ function water.use_well(pos, puncher)
end
function water.add_filling_effects(pos)
local entity_pos = vector.add(pos, vector.new(0, 1/4, 0))
local entity_pos = vector.add(pos, vector.new(0, 1 / 4, 0))
local spos = minetest.hash_node_position(pos)
@ -103,15 +98,15 @@ function water.add_filling_effects(pos)
minetest.sound_stop(previous_handle)
end
sound_handles_by_pos[spos] = minetest.sound_play(
{name = s.water_fill},
{pos = entity_pos, loop = true, gain = 0.5, pitch = 2.0}
{ name = s.water_fill },
{ pos = entity_pos, loop = true, gain = 0.5, pitch = 2.0 }
)
local previous_id = particlespawner_ids_by_pos[spos]
if previous_id then
minetest.delete_particlespawner(previous_id)
end
local particle_pos = vector.add(pos, vector.new(0, 1/2 + 1/16, 0))
local particle_pos = vector.add(pos, vector.new(0, 1 / 2 + 1 / 16, 0))
particlespawner_ids_by_pos[spos] = minetest.add_particlespawner({
amount = 10,
time = 0,
@ -131,12 +126,12 @@ function water.add_filling_effects(pos)
end
function water.fill_bucket(pos)
local entity_pos = vector.add(pos, vector.new(0, 1/4, 0))
local entity_pos = vector.add(pos, vector.new(0, 1 / 4, 0))
for _, obj in ipairs(minetest.get_objects_inside_radius(entity_pos, .1)) do
for _, obj in ipairs(minetest.get_objects_inside_radius(entity_pos, 0.1)) do
local ent = obj:get_luaentity()
if ent and ent.name == "cottages:bucket_entity" then
obj:set_properties({wield_item = ci.bucket_filled})
obj:set_properties({ wield_item = ci.bucket_filled })
end
end
@ -158,7 +153,7 @@ function water.initialize_entity(pos)
local meta = minetest.get_meta(pos)
local bucket = meta:get("bucket")
if bucket then
local entity_pos = vector.add(pos, vector.new(0, 1/4, 0))
local entity_pos = vector.add(pos, vector.new(0, 1 / 4, 0))
minetest.add_entity(entity_pos, "cottages:bucket_entity", bucket)
if bucket == ci.bucket then
@ -173,13 +168,13 @@ end
cottages.api.register_machine("cottages:water_gen", {
description = S("Tree Trunk Well"),
tiles = {t.tree_top, ("%s^[transformR90"):format(t.tree), ("%s^[transformR90"):format(t.tree)},
tiles = { t.tree_top, ("%s^[transformR90"):format(t.tree), ("%s^[transformR90"):format(t.tree) },
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
groups = {choppy = 2, cracky = 1, flammable = 2},
groups = { choppy = 2, cracky = 1, flammable = 2 },
sounds = cottages.sounds.wood,
inv_info = {
@ -190,29 +185,28 @@ cottages.api.register_machine("cottages:water_gen", {
type = "fixed",
fixed = {
-- floor of water bassin
{-0.5, -0.5 + (3 / 16), -0.5, 0.5, -0.5 + (4 / 16), 0.5},
{ -0.5, -0.5 + (3 / 16), -0.5, 0.5, -0.5 + (4 / 16), 0.5 },
-- walls
{-0.5, -0.5 + (3 / 16), -0.5, 0.5, (4 / 16), -0.5 + (2 / 16)},
{-0.5, -0.5 + (3 / 16), -0.5, -0.5 + (2 / 16), (4 / 16), 0.5},
{0.5, -0.5 + (3 / 16), 0.5, 0.5 - (2 / 16), (4 / 16), -0.5},
{0.5, -0.5 + (3 / 16), 0.5, -0.5 + (2 / 16), (4 / 16), 0.5 - (2 / 16)},
{ -0.5, -0.5 + (3 / 16), -0.5, 0.5, (4 / 16), -0.5 + (2 / 16) },
{ -0.5, -0.5 + (3 / 16), -0.5, -0.5 + (2 / 16), (4 / 16), 0.5 },
{ 0.5, -0.5 + (3 / 16), 0.5, 0.5 - (2 / 16), (4 / 16), -0.5 },
{ 0.5, -0.5 + (3 / 16), 0.5, -0.5 + (2 / 16), (4 / 16), 0.5 - (2 / 16) },
-- feet
{-0.5 + (3 / 16), -0.5, -0.5 + (3 / 16), -0.5 + (6 / 16), -0.5 + (3 / 16), 0.5 - (3 / 16)},
{0.5 - (3 / 16), -0.5, -0.5 + (3 / 16), 0.5 - (6 / 16), -0.5 + (3 / 16), 0.5 - (3 / 16)},
{ -0.5 + (3 / 16), -0.5, -0.5 + (3 / 16), -0.5 + (6 / 16), -0.5 + (3 / 16), 0.5 - (3 / 16) },
{ 0.5 - (3 / 16), -0.5, -0.5 + (3 / 16), 0.5 - (6 / 16), -0.5 + (3 / 16), 0.5 - (3 / 16) },
-- real pump
{0.5 - (4 / 16), -0.5, -(2 / 16), 0.5, 0.5 + (4 / 16), (2 / 16)},
{ 0.5 - (4 / 16), -0.5, -(2 / 16), 0.5, 0.5 + (4 / 16), (2 / 16) },
-- water pipe inside wooden stem
{0.5 - (8 / 16), 0.5 + (1 / 16), -(1 / 16), 0.5, 0.5 + (3 / 16), (1 / 16)},
{ 0.5 - (8 / 16), 0.5 + (1 / 16), -(1 / 16), 0.5, 0.5 + (3 / 16), (1 / 16) },
-- where the water comes out
{0.5 - (15 / 32), 0.5, -(1 / 32), 0.5 - (12 / 32), 0.5 + (1 / 16), (1 / 32)},
{ 0.5 - (15 / 32), 0.5, -(1 / 32), 0.5 - (12 / 32), 0.5 + (1 / 16), (1 / 32) },
},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5 + (4 / 16), 0.5}
fixed = { -0.5, -0.5, -0.5, 0.5, 0.5 + (4 / 16), 0.5 },
},
get_fs_parts = water.get_well_fs_parts,
get_info = water.get_well_info,
@ -245,9 +239,9 @@ cottages.api.register_machine("cottages:water_gen", {
use = water.use_well,
on_destruct = function(pos)
local entity_pos = vector.add(pos, vector.new(0, 1/4, 0))
local entity_pos = vector.add(pos, vector.new(0, 1 / 4, 0))
for _, obj in ipairs(minetest.get_objects_inside_radius(entity_pos, .1)) do
for _, obj in ipairs(minetest.get_objects_inside_radius(entity_pos, 0.1)) do
local ent = obj:get_luaentity()
if ent and ent.name == "cottages:bucket_entity" then
minetest.add_item(pos, obj:get_properties().wield_item)
@ -271,15 +265,14 @@ cottages.api.register_machine("cottages:water_gen", {
if cottages.has.node_entity_queue then
node_entity_queue.api.register_node_entity_loader("cottages:water_gen", water.initialize_entity)
else
minetest.register_lbm({
name = "cottages:add_well_entity",
label = "Initialize entity to cottages well",
nodenames = {"cottages:water_gen"},
nodenames = { "cottages:water_gen" },
run_at_every_load = true,
action = function(pos, node)
water.initialize_entity(pos)
end
end,
})
end