1
0
Fork 0

fix many codestyle issues

This commit is contained in:
AFCMS 2021-04-16 13:35:03 +02:00
parent 3dd490ed6b
commit 1a58b0c510
13 changed files with 38 additions and 45 deletions

View File

@ -67,7 +67,7 @@ doc_identifier.identify = function(itemstack, user, pointed_thing)
local pos = pointed_thing.under local pos = pointed_thing.under
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
if minetest.registered_nodes[node.name] ~= nil then if minetest.registered_nodes[node.name] ~= nil then
local nodedef = minetest.registered_nodes[node.name] --local nodedef = minetest.registered_nodes[node.name]
if(node.name == "ignore") then if(node.name == "ignore") then
show_message(username, "error_ignore") show_message(username, "error_ignore")
elseif doc.entry_exists("nodes", node.name) then elseif doc.entry_exists("nodes", node.name) then
@ -198,7 +198,7 @@ minetest.register_craft({
if minetest.get_modpath("mcl_core") ~= nil then if minetest.get_modpath("mcl_core") ~= nil then
minetest.register_craft({ minetest.register_craft({
output = "doc_identifier:identifier_solid", output = "doc_identifier:identifier_solid",
recipe = { { "mcl_core:glass" }, recipe = { { "mcl_core:glass" },
{ "group:stick" } } { "group:stick" } }
}) })
end end

View File

@ -907,7 +907,7 @@ doc.add_category("nodes", {
-- Do some cleanup of the probability table -- Do some cleanup of the probability table
if max == 1 or max == nil then if max == 1 or max == nil then
-- Sort by rarity -- Sort by rarity
local comp = function(p1, p2) local comp = function(p1, p2)
return p1.rarity < p2.rarity return p1.rarity < p2.rarity
end end
table.sort(probtables, comp) table.sort(probtables, comp)
@ -1269,7 +1269,6 @@ local function gather_descs()
if type(def._doc_items_hidden) == "boolean" then if type(def._doc_items_hidden) == "boolean" then
hidden = def._doc_items_hidden hidden = def._doc_items_hidden
end end
local custom_image
name = scrub_newlines(name) name = scrub_newlines(name)
local infotable = { local infotable = {
name = name, name = name,

View File

@ -33,7 +33,6 @@ local fmt, find, gmatch, match, sub, split, lower =
local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil
local pairs, next, unpack = pairs, next, unpack local pairs, next, unpack = pairs, next, unpack
local vec_add, vec_mul = vector.add, vector.multiply
local DEFAULT_SIZE = 10 local DEFAULT_SIZE = 10
local MIN_LIMIT, MAX_LIMIT = 10, 12 local MIN_LIMIT, MAX_LIMIT = 10, 12
@ -1001,7 +1000,7 @@ else
end end
end) end)
local function on_use(user) --[[local function on_use(user)
local name = user:get_player_name() local name = user:get_player_name()
if next(recipe_filters) then if next(recipe_filters) then
@ -1011,7 +1010,7 @@ else
end end
show_formspec(name, "mcl_craftguide", make_formspec(name)) show_formspec(name, "mcl_craftguide", make_formspec(name))
end end]]
end end
@ -1098,7 +1097,6 @@ if progressive_mode then
local name = player:get_player_name() local name = player:get_player_name()
init_data(name) init_data(name)
local meta = player:get_meta() local meta = player:get_meta()
local name = player:get_player_name()
local data = player_data[name] local data = player_data[name]
data.inv_items = deserialize(meta:get_string("inv_items")) or {} data.inv_items = deserialize(meta:get_string("inv_items")) or {}
@ -1144,7 +1142,7 @@ else
end end
function mcl_craftguide.show(name) function mcl_craftguide.show(name)
local player = minetest.get_player_by_name(name) local player = get_player_by_name(name)
if next(recipe_filters) then if next(recipe_filters) then
local data = player_data[name] local data = player_data[name]
data.items_raw = get_filtered_items(player) data.items_raw = get_filtered_items(player)

View File

@ -62,7 +62,6 @@ end)
-- nodes which have flower placement rules -- nodes which have flower placement rules
doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def) doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def)
local datastring = ""
if def.groups.place_flowerlike == 1 then if def.groups.place_flowerlike == 1 then
return S("This plant can only grow on grass blocks and dirt. To survive, it needs to have an unobstructed view to the sky above or be exposed to a light level of 8 or higher.") return S("This plant can only grow on grass blocks and dirt. To survive, it needs to have an unobstructed view to the sky above or be exposed to a light level of 8 or higher.")
elseif def.groups.place_flowerlike == 2 then elseif def.groups.place_flowerlike == 2 then
@ -130,7 +129,7 @@ end)
-- Armor -- Armor
doc.sub.items.register_factoid(nil, "use", function(itemstring, def) doc.sub.items.register_factoid(nil, "use", function(itemstring, def)
local def = minetest.registered_items[itemstring] --local def = minetest.registered_items[itemstring]
local s = "" local s = ""
local head = minetest.get_item_group(itemstring, "armor_head") local head = minetest.get_item_group(itemstring, "armor_head")
local torso = minetest.get_item_group(itemstring, "armor_torso") local torso = minetest.get_item_group(itemstring, "armor_torso")
@ -173,7 +172,6 @@ end)
doc.sub.items.register_factoid(nil, "groups", function(itemstring, def) doc.sub.items.register_factoid(nil, "groups", function(itemstring, def)
if def._repair_material then if def._repair_material then
local mdef = minetest.registered_items[def._repair_material] local mdef = minetest.registered_items[def._repair_material]
local desc
if mdef and mdef.description and mdef.description ~= "" then if mdef and mdef.description and mdef.description ~= "" then
return S("This item can be repaired at an anvil with: @1.", mdef.description) return S("This item can be repaired at an anvil with: @1.", mdef.description)
elseif def._repair_material == "group:wood" then elseif def._repair_material == "group:wood" then

View File

@ -233,7 +233,7 @@ if minetest.get_modpath("mcl_farming") then
local wear = mcl_autogroup.get_wear(toolname, "shearsy") local wear = mcl_autogroup.get_wear(toolname, "shearsy")
itemstack:add_wear(wear) itemstack:add_wear(wear)
end end
minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = above}, true) minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = pointed_thing.above}, true)
local dir = vector.subtract(pointed_thing.under, pointed_thing.above) local dir = vector.subtract(pointed_thing.under, pointed_thing.above)
local param2 = minetest.dir_to_facedir(dir) local param2 = minetest.dir_to_facedir(dir)
minetest.swap_node(pointed_thing.under, {name="mcl_farming:pumpkin_face", param2 = param2}) minetest.swap_node(pointed_thing.under, {name="mcl_farming:pumpkin_face", param2 = param2})

View File

@ -151,7 +151,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory
minetest.register_node(nodename.."_"..i, { minetest.register_node(nodename.."_"..i, {
collision_box = { collision_box = {
type = 'fixed', type = 'fixed',
fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16}
}, },
drawtype = "nodebox", drawtype = "nodebox",
@ -180,7 +180,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory
minetest.register_node(nodename.."_16", { minetest.register_node(nodename.."_16", {
drawtype = "nodebox", drawtype = "nodebox",
collision_box = { collision_box = {
type = 'fixed', type = 'fixed',
fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16}
}, },
tiles = tiles, tiles = tiles,
@ -206,7 +206,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory
minetest.register_node(nodename.."_21", { minetest.register_node(nodename.."_21", {
drawtype = "nodebox", drawtype = "nodebox",
collision_box = { collision_box = {
type = 'fixed', type = 'fixed',
fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16}
}, },
tiles = tiles, tiles = tiles,
@ -247,7 +247,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory
fixed = pillar fixed = pillar
}, },
collision_box = { collision_box = {
type = 'fixed', type = 'fixed',
fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16}
}, },
collisionbox = {-0.2, 0, -0.2, 0.2, 1.4, 0.2}, collisionbox = {-0.2, 0, -0.2, 0.2, 1.4, 0.2},

View File

@ -157,7 +157,6 @@ screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses)
if should_rotate and new_param2 ~= node.param2 then if should_rotate and new_param2 ~= node.param2 then
node.param2 = new_param2 node.param2 = new_param2
minetest.swap_node(pos, node) minetest.swap_node(pos, node)
minetest.check_for_falling(pos) minetest.check_for_falling(pos)
if ndef.after_rotate then if ndef.after_rotate then
ndef.after_rotate(vector.new(pos)) ndef.after_rotate(vector.new(pos))

View File

@ -142,7 +142,7 @@ function xpanes.register_pane(name, def)
tiles = {def.textures[3], def.textures[2], def.textures[1]}, tiles = {def.textures[3], def.textures[2], def.textures[1]},
use_texture_alpha = def.use_texture_alpha, use_texture_alpha = def.use_texture_alpha,
groups = groups, groups = groups,
drop = "xpanes:" .. name .. "_flat", drop = drop,
sounds = def.sounds, sounds = def.sounds,
node_box = { node_box = {
type = "connected", type = "connected",
@ -153,7 +153,6 @@ function xpanes.register_pane(name, def)
connect_right = {{1/32, -1/2, -1/32, 1/2, 1/2, 1/32}}, connect_right = {{1/32, -1/2, -1/32, 1/2, 1/2, 1/32}},
}, },
connects_to = {"group:pane", "group:stone", "group:glass", "group:wood", "group:tree"}, connects_to = {"group:pane", "group:stone", "group:glass", "group:wood", "group:tree"},
drop = drop,
_mcl_blast_resistance = def._mcl_blast_resistance, _mcl_blast_resistance = def._mcl_blast_resistance,
_mcl_hardness = def._mcl_hardness, _mcl_hardness = def._mcl_hardness,
_mcl_silk_touch_drop = def._mcl_silk_touch_drop and {"xpanes:" .. name .. "_flat"}, _mcl_silk_touch_drop = def._mcl_silk_touch_drop and {"xpanes:" .. name .. "_flat"},

View File

@ -3906,7 +3906,7 @@ end
-- Decorations in non-Overworld dimensions -- Decorations in non-Overworld dimensions
local function register_dimension_decorations() local function register_dimension_decorations()
--[[ NETHER ]] --[[ NETHER ]]
-- TODO: Nether -- TODO: Nether
--[[ THE END ]] --[[ THE END ]]
@ -3973,7 +3973,7 @@ if mg_name ~= "singlenode" then
if deco_id_chorus_plant then if deco_id_chorus_plant then
mcl_mapgen_core.register_generator("chorus_grow", nil, function(minp, maxp, blockseed) mcl_mapgen_core.register_generator("chorus_grow", nil, function(minp, maxp, blockseed)
local gennotify = minetest.get_mapgen_object("gennotify") local gennotify = minetest.get_mapgen_object("gennotify")
local poslist = {} --local poslist = {}
for _, pos in ipairs(gennotify["decoration#"..deco_id_chorus_plant] or {}) do for _, pos in ipairs(gennotify["decoration#"..deco_id_chorus_plant] or {}) do
local realpos = { x = pos.x, y = pos.y + 1, z = pos.z } local realpos = { x = pos.x, y = pos.y + 1, z = pos.z }
mcl_end.grow_chorus_plant(realpos) mcl_end.grow_chorus_plant(realpos)

View File

@ -9,15 +9,15 @@ function settlements.ground(pos, pr) -- role model: Wendelsteinkircherl, Brannen
while true do while true do
cnt = cnt+1 cnt = cnt+1
if cnt > 20 then break end if cnt > 20 then break end
if cnt>pr:next(2,4) then if cnt>pr:next(2,4) then
mat = "mcl_core:stone" mat = "mcl_core:stone"
end end
minetest.swap_node(p2, {name=mat}) minetest.swap_node(p2, {name=mat})
p2.y = p2.y-1 p2.y = p2.y-1
end end
end end
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- function clear space above baseplate -- function clear space above baseplate
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
function settlements.terraform(settlement_info, pr) function settlements.terraform(settlement_info, pr)
local fheight, fwidth, fdepth, schematic_data local fheight, fwidth, fdepth, schematic_data
@ -30,7 +30,7 @@ function settlements.terraform(settlement_info, pr)
break break
end end
end end
local pos = settlement_info[i]["pos"] local pos = settlement_info[i]["pos"]
if settlement_info[i]["rotat"] == "0" or settlement_info[i]["rotat"] == "180" then if settlement_info[i]["rotat"] == "0" or settlement_info[i]["rotat"] == "180" then
fwidth = schematic_data["hwidth"] fwidth = schematic_data["hwidth"]
fdepth = schematic_data["hdepth"] fdepth = schematic_data["hdepth"]
@ -54,9 +54,9 @@ function settlements.terraform(settlement_info, pr)
-- local p = {x=pos.x+xi, y=pos.y+yi, z=pos.z+zi} -- local p = {x=pos.x+xi, y=pos.y+yi, z=pos.z+zi}
-- local node = mcl_vars.get_node(p) -- local node = mcl_vars.get_node(p)
-- if node and node.name ~= "air" then -- if node and node.name ~= "air" then
-- minetest.swap_node(p,{name="air"}) -- minetest.swap_node(p,{name="air"})
-- end -- end
minetest.swap_node({x=pos.x+xi, y=pos.y+yi, z=pos.z+zi},{name="air"}) minetest.swap_node({x=pos.x+xi, y=pos.y+yi, z=pos.z+zi},{name="air"})
end end
end end
end end

View File

@ -46,7 +46,7 @@ if minetest.get_modpath("mobs_mc") ~= nil then
7, --active_object_count 7, --active_object_count
31000, --max_height 31000, --max_height
nil) --day_toggle nil) --day_toggle
end end
--]] --]]
-- --
@ -85,7 +85,7 @@ if mg_name ~= "singlenode" then
if blockseed % 77 ~= 17 then return end if blockseed % 77 ~= 17 then return end
-- needed for manual and automated settlement building -- needed for manual and automated settlement building
-- don't build settlements on (too) uneven terrain -- don't build settlements on (too) uneven terrain
local heightmap = minetest.get_mapgen_object("heightmap") --local heightmap = minetest.get_mapgen_object("heightmap")
local height_difference = settlements.evaluate_heightmap() local height_difference = settlements.evaluate_heightmap()
if height_difference > max_height_difference then return end if height_difference > max_height_difference then return end

View File

@ -6,10 +6,10 @@ function settlements.paths(settlement_info)
local end_point local end_point
local distance local distance
--for k,v in pairs(settlement_info) do --for k,v in pairs(settlement_info) do
starting_point = settlement_info[1]["pos"] starting_point = settlement_info[1]["pos"]
for o,p in pairs(settlement_info) do for o,p in pairs(settlement_info) do
end_point = settlement_info[o]["pos"] end_point = settlement_info[o]["pos"]
if starting_point ~= end_point if starting_point ~= end_point
then then
-- loop until end_point is reched (distance == 0) -- loop until end_point is reched (distance == 0)
@ -40,35 +40,35 @@ function settlements.paths(settlement_info)
-- evaluate which pos is closer to the end_point -- evaluate which pos is closer to the end_point
if dist_north_p_to_end <= dist_south_p_to_end and if dist_north_p_to_end <= dist_south_p_to_end and
dist_north_p_to_end <= dist_west_p_to_end and dist_north_p_to_end <= dist_west_p_to_end and
dist_north_p_to_end <= dist_east_p_to_end dist_north_p_to_end <= dist_east_p_to_end
then then
starting_point = north_p starting_point = north_p
distance = dist_north_p_to_end distance = dist_north_p_to_end
elseif dist_south_p_to_end <= dist_north_p_to_end and elseif dist_south_p_to_end <= dist_north_p_to_end and
dist_south_p_to_end <= dist_west_p_to_end and dist_south_p_to_end <= dist_west_p_to_end and
dist_south_p_to_end <= dist_east_p_to_end dist_south_p_to_end <= dist_east_p_to_end
then then
starting_point = south_p starting_point = south_p
distance = dist_south_p_to_end distance = dist_south_p_to_end
elseif dist_west_p_to_end <= dist_north_p_to_end and elseif dist_west_p_to_end <= dist_north_p_to_end and
dist_west_p_to_end <= dist_south_p_to_end and dist_west_p_to_end <= dist_south_p_to_end and
dist_west_p_to_end <= dist_east_p_to_end dist_west_p_to_end <= dist_east_p_to_end
then then
starting_point = west_p starting_point = west_p
distance = dist_west_p_to_end distance = dist_west_p_to_end
elseif dist_east_p_to_end <= dist_north_p_to_end and elseif dist_east_p_to_end <= dist_north_p_to_end and
dist_east_p_to_end <= dist_south_p_to_end and dist_east_p_to_end <= dist_south_p_to_end and
dist_east_p_to_end <= dist_west_p_to_end dist_east_p_to_end <= dist_west_p_to_end
then then
starting_point = east_p starting_point = east_p
distance = dist_east_p_to_end distance = dist_east_p_to_end
end end
-- find surface of new starting point -- find surface of new starting point
local surface_point, surface_mat = settlements.find_surface(starting_point) local surface_point, surface_mat = settlements.find_surface(starting_point)
-- replace surface node with mcl_core:grass_path -- replace surface node with mcl_core:grass_path
if surface_point if surface_point
then then
if surface_mat == "mcl_core:sand" or surface_mat == "mcl_core:redsand" then if surface_mat == "mcl_core:sand" or surface_mat == "mcl_core:redsand" then

View File

@ -126,7 +126,7 @@ function settlements.fill_chest(pos, pr)
-- fill chest -- fill chest
local inv = minetest.get_inventory( {type="node", pos=pos} ) local inv = minetest.get_inventory( {type="node", pos=pos} )
local function get_treasures(pr) local function get_treasures(prand)
local loottable = {{ local loottable = {{
stacks_min = 3, stacks_min = 3,
stacks_max = 8, stacks_max = 8,
@ -150,7 +150,7 @@ function settlements.fill_chest(pos, pr)
{ itemstring = "mobs_mc:diamond_horse_armor", weight = 1 }, { itemstring = "mobs_mc:diamond_horse_armor", weight = 1 },
} }
}} }}
local items = mcl_loot.get_multi_loot(loottable, pr) local items = mcl_loot.get_multi_loot(loottable, prand)
return items return items
end end
@ -163,14 +163,14 @@ end
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
function settlements.initialize_furnace(pos) function settlements.initialize_furnace(pos)
-- find chests within radius -- find chests within radius
local furnacepos = minetest.find_node_near(pos, local furnacepos = minetest.find_node_near(pos,
7, --radius 7, --radius
{"mcl_furnaces:furnace"}) {"mcl_furnaces:furnace"})
-- initialize furnacepos (mts furnacepos don't have meta) -- initialize furnacepos (mts furnacepos don't have meta)
if furnacepos if furnacepos
then then
local meta = minetest.get_meta(furnacepos) local meta = minetest.get_meta(furnacepos)
if meta:get_string("infotext") ~= "furnace" if meta:get_string("infotext") ~= "furnace"
then then
minetest.registered_nodes["mcl_furnaces:furnace"].on_construct(furnacepos) minetest.registered_nodes["mcl_furnaces:furnace"].on_construct(furnacepos)
end end
@ -181,14 +181,14 @@ end
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
function settlements.initialize_anvil(pos) function settlements.initialize_anvil(pos)
-- find chests within radius -- find chests within radius
local anvilpos = minetest.find_node_near(pos, local anvilpos = minetest.find_node_near(pos,
7, --radius 7, --radius
{"mcl_anvils:anvil"}) {"mcl_anvils:anvil"})
-- initialize anvilpos (mts anvilpos don't have meta) -- initialize anvilpos (mts anvilpos don't have meta)
if anvilpos if anvilpos
then then
local meta = minetest.get_meta(anvilpos) local meta = minetest.get_meta(anvilpos)
if meta:get_string("infotext") ~= "anvil" if meta:get_string("infotext") ~= "anvil"
then then
minetest.registered_nodes["mcl_anvils:anvil"].on_construct(anvilpos) minetest.registered_nodes["mcl_anvils:anvil"].on_construct(anvilpos)
end end