From b1f7294578ae2126f2acfdfda21d3d67db3da54d Mon Sep 17 00:00:00 2001 From: AFCMS Date: Thu, 15 Apr 2021 22:22:23 +0200 Subject: [PATCH 1/3] create python script --- tools/create_luacheck.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tools/create_luacheck.py diff --git a/tools/create_luacheck.py b/tools/create_luacheck.py new file mode 100644 index 000000000..e69de29bb From b4977781924ea48eab3f5c9c93678ea03ec0ea0c Mon Sep 17 00:00:00 2001 From: AFCMS Date: Thu, 15 Apr 2021 22:22:39 +0200 Subject: [PATCH 2/3] delete unused file --- mods/PLAYER/mcl_skins/intllib.lua | 45 ------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 mods/PLAYER/mcl_skins/intllib.lua diff --git a/mods/PLAYER/mcl_skins/intllib.lua b/mods/PLAYER/mcl_skins/intllib.lua deleted file mode 100644 index 6669d7202..000000000 --- a/mods/PLAYER/mcl_skins/intllib.lua +++ /dev/null @@ -1,45 +0,0 @@ - --- Fallback functions for when `intllib` is not installed. --- Code released under Unlicense . - --- Get the latest version of this file at: --- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua - -local function format(str, ...) - local args = { ... } - local function repl(escape, open, num, close) - if escape == "" then - local replacement = tostring(args[tonumber(num)]) - if open == "" then - replacement = replacement..close - end - return replacement - else - return "@"..open..num..close - end - end - return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl)) -end - -local gettext, ngettext -if minetest.get_modpath("intllib") then - if intllib.make_gettext_pair then - -- New method using gettext. - gettext, ngettext = intllib.make_gettext_pair() - else - -- Old method using text files. - gettext = intllib.Getter() - end -end - --- Fill in missing functions. - -gettext = gettext or function(msgid, ...) - return format(msgid, ...) -end - -ngettext = ngettext or function(msgid, msgid_plural, n, ...) - return format(n==1 and msgid or msgid_plural, ...) -end - -return gettext, ngettext From a602f64ea535f4040596ca409b68ff38478495da Mon Sep 17 00:00:00 2001 From: AFCMS Date: Thu, 15 Apr 2021 23:41:34 +0200 Subject: [PATCH 3/3] fix many warnings --- mods/ITEMS/mcl_farming/soil.lua | 2 +- mods/ITEMS/mcl_farming/wheat.lua | 25 +++++++++++----- mods/ITEMS/mcl_fences/init.lua | 2 +- mods/ITEMS/mcl_fire/fire_charge.lua | 2 +- mods/ITEMS/mcl_fire/flint_and_steel.lua | 2 +- mods/ITEMS/mcl_fishing/init.lua | 10 +------ mods/ITEMS/mcl_flowers/init.lua | 5 +--- mods/ITEMS/mcl_furnaces/init.lua | 10 +++++-- mods/ITEMS/mcl_heads/init.lua | 6 ++-- mods/ITEMS/mcl_hoppers/init.lua | 7 ++--- mods/ITEMS/mcl_monster_eggs/init.lua | 6 ++-- mods/ITEMS/mcl_mushrooms/small.lua | 1 - mods/ITEMS/mcl_ocean/corals.lua | 1 - mods/ITEMS/mcl_ocean/kelp.lua | 33 +++++++++------------- mods/ITEMS/mcl_throwing/init.lua | 6 ++-- mods/ITEMS/mcl_tnt/init.lua | 2 -- mods/MISC/mcl_commands/init.lua | 4 --- mods/MISC/mcl_commands/setblock.lua | 2 +- mods/MISC/mcl_commands/sound.lua | 9 ++---- mods/MISC/mcl_temp_helper_recipes/init.lua | 7 ++++- mods/PLAYER/mcl_death_drop/init.lua | 2 +- mods/PLAYER/mcl_hunger/api.lua | 5 ++-- mods/PLAYER/mcl_hunger/hunger.lua | 10 +++---- mods/PLAYER/mcl_hunger/init.lua | 4 +-- mods/PLAYER/mcl_meshhand/init.lua | 1 - mods/PLAYER/mcl_player/init.lua | 9 ++++-- mods/PLAYER/mcl_playerplus/init.lua | 22 ++++----------- mods/PLAYER/mcl_skins/init.lua | 1 - mods/PLAYER/mcl_sprint/init.lua | 13 +++++++-- mods/PLAYER/wieldview/init.lua | 11 ++++---- 30 files changed, 102 insertions(+), 118 deletions(-) diff --git a/mods/ITEMS/mcl_farming/soil.lua b/mods/ITEMS/mcl_farming/soil.lua index 0c0e3b832..f7a7bbbfb 100644 --- a/mods/ITEMS/mcl_farming/soil.lua +++ b/mods/ITEMS/mcl_farming/soil.lua @@ -99,7 +99,7 @@ minetest.register_abm({ -- No decay near unloaded areas since these might include water. if not check_surroundings(pos, "ignore") then if wet <= 0 then - local n_def = minetest.registered_nodes[node.name] or nil + --local n_def = minetest.registered_nodes[node.name] or nil local nn = minetest.get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z}) if not nn or not nn.name then return diff --git a/mods/ITEMS/mcl_farming/wheat.lua b/mods/ITEMS/mcl_farming/wheat.lua index e3ee79ead..d986e5be3 100644 --- a/mods/ITEMS/mcl_farming/wheat.lua +++ b/mods/ITEMS/mcl_farming/wheat.lua @@ -5,7 +5,10 @@ minetest.register_craftitem("mcl_farming:wheat_seeds", { description = S("Wheat Seeds"), _tt_help = S("Grows on farmland"), _doc_items_longdesc = S("Grows into a wheat plant. Chickens like wheat seeds."), - _doc_items_usagehelp = S("Place the wheat seeds on farmland (which can be created with a hoe) to plant a wheat plant. They grow in sunlight and grow faster on hydrated farmland. Rightclick an animal to feed it wheat seeds."), + _doc_items_usagehelp = S([[ + Place the wheat seeds on farmland (which can be created with a hoe) to plant a wheat plant. + They grow in sunlight and grow faster on hydrated farmland. Rightclick an animal to feed it wheat seeds. + ]]), groups = { craftitem=1 }, inventory_image = "mcl_farming_wheat_seeds.png", on_place = function(itemstack, placer, pointed_thing) @@ -28,7 +31,10 @@ for i=1,7 do if i == 1 then create = true name = S("Premature Wheat Plant") - longdesc = S("Premature wheat plants grow on farmland under sunlight in 8 stages. On hydrated farmland, they grow faster. They can be harvested at any time but will only yield a profit when mature.") + longdesc = S([[ + Premature wheat plants grow on farmland under sunlight in 8 stages. + On hydrated farmland, they grow faster. They can be harvested at any time but will only yield a profit when mature. + ]]) else create = false end @@ -54,7 +60,8 @@ for i=1,7 do {-0.5, -0.5, -0.5, 0.5, sel_heights[i], 0.5} }, }, - groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1}, + groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, + dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1}, sounds = mcl_sounds.node_sound_leaves_defaults(), _mcl_blast_resistance = 0, }) @@ -62,7 +69,10 @@ end minetest.register_node("mcl_farming:wheat", { description = S("Mature Wheat Plant"), - _doc_items_longdesc = S("Mature wheat plants are ready to be harvested for wheat and wheat seeds. They won't grow any further."), + _doc_items_longdesc = S([[ + Mature wheat plants are ready to be harvested for wheat and wheat seeds. + They won't grow any further. + ]]), sunlight_propagates = true, paramtype = "light", paramtype2 = "meshoptions", @@ -81,7 +91,8 @@ minetest.register_node("mcl_farming:wheat", { { items = {'mcl_farming:wheat_item'} } } }, - groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1}, + groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1, attached_node=1, + dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1}, sounds = mcl_sounds.node_sound_leaves_defaults(), _mcl_blast_resistance = 0, }) @@ -144,9 +155,9 @@ minetest.register_node("mcl_farming:hay_block", { is_ground_content = false, stack_max = 64, paramtype2 = "facedir", - is_ground_content = false, on_place = mcl_util.rotate_axis, - groups = {handy=1, hoey=1, flammable=2, fire_encouragement=60, fire_flammability=20, building_block=1, fall_damage_add_percent=-80}, + groups = {handy=1, hoey=1, flammable=2, fire_encouragement=60, + fire_flammability=20, building_block=1, fall_damage_add_percent=-80}, sounds = mcl_sounds.node_sound_leaves_defaults(), on_rotate = on_rotate, _mcl_blast_resistance = 0.5, diff --git a/mods/ITEMS/mcl_fences/init.lua b/mods/ITEMS/mcl_fences/init.lua index 650854f88..e60782215 100644 --- a/mods/ITEMS/mcl_fences/init.lua +++ b/mods/ITEMS/mcl_fences/init.lua @@ -76,7 +76,7 @@ mcl_fences.register_fence_gate = function(id, fence_gate_name, texture, groups, local meta2 local state2 = 0 - local function update_gate(pos, node) + local function update_gate(pos, node) minetest.set_node(pos, node) end diff --git a/mods/ITEMS/mcl_fire/fire_charge.lua b/mods/ITEMS/mcl_fire/fire_charge.lua index f4d2da321..69e536790 100644 --- a/mods/ITEMS/mcl_fire/fire_charge.lua +++ b/mods/ITEMS/mcl_fire/fire_charge.lua @@ -6,7 +6,7 @@ local add_entity = minetest.add_entity -- Fire Charge minetest.register_craftitem("mcl_fire:fire_charge", { description = S("Fire Charge"), - _tt_help = S("Dispenser projectile").."\n"..S("Starts fires and ignites blocks"), + _tt_help = S("Dispenser projectile").."\n"..S("Starts fires and ignites blocks"), _doc_items_longdesc = S("Fire charges are primarily projectiles which can be launched from dispensers, they will fly in a straight line and burst into a fire on impact. Alternatively, they can be used to ignite fires directly."), _doc_items_usagehelp = S("Put the fire charge into a dispenser and supply it with redstone power to launch it. To ignite a fire directly, simply place the fire charge on the ground, which uses it up."), inventory_image = "mcl_fire_fire_charge.png", diff --git a/mods/ITEMS/mcl_fire/flint_and_steel.lua b/mods/ITEMS/mcl_fire/flint_and_steel.lua index b0e711e0a..5aa02aec1 100644 --- a/mods/ITEMS/mcl_fire/flint_and_steel.lua +++ b/mods/ITEMS/mcl_fire/flint_and_steel.lua @@ -5,7 +5,7 @@ local add_node = minetest.add_node -- Flint and Steel minetest.register_tool("mcl_fire:flint_and_steel", { description = S("Flint and Steel"), - _tt_help = S("Starts fires and ignites blocks"), + _tt_help = S("Starts fires and ignites blocks"), _doc_items_longdesc = S("Flint and steel is a tool to start fires and ignite blocks."), _doc_items_usagehelp = S("Rightclick the surface of a block to attempt to light a fire in front of it or ignite the block. A few blocks have an unique reaction when ignited."), inventory_image = "mcl_fire_flint_and_steel.png", diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index 2bd0ed515..e5381f9bd 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -1,11 +1,6 @@ --Fishing Rod, Bobber, and Flying Bobber mechanics and Bobber artwork by Rootyjr. local S = minetest.get_translator("mcl_fishing") -local mod_throwing = minetest.get_modpath("mcl_throwing") - -local entity_mapping = { - ["mcl_fishing:bobber"] = "mcl_fishing:bobber_entity", -} local bobber_ENTITY={ physical = false, @@ -61,7 +56,6 @@ local fish = function(itemstack, player, pointed_thing) local itemname local items local itemcount = 1 - local itemwear = 0 local pr = PseudoRandom(os.time() * math.random(1, 100)) local r = pr:next(1, 100) local fish_values = {85, 84.8, 84.7, 84.5} @@ -173,7 +167,7 @@ local fish = function(itemstack, player, pointed_thing) if noent == true then local playerpos = player:get_pos() local dir = player:get_look_dir() - local obj = mcl_throwing.throw("mcl_fishing:flying_bobber", {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, 15, player:get_player_name()) + mcl_throwing.throw("mcl_fishing:flying_bobber", {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, 15, player:get_player_name()) end end @@ -344,10 +338,8 @@ mcl_throwing.register_throwable_object("mcl_fishing:flying_bobber", "mcl_fishing -- If player leaves area, remove bobber. minetest.register_on_leaveplayer(function(player) local objs = minetest.get_objects_inside_radius(player:get_pos(), 250) - local num = 0 local ent = nil local noent = true - for n = 1, #objs do ent = objs[n]:get_luaentity() if ent then diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index a155ebd0b..7a2501f25 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -180,7 +180,7 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im if not inv_img then inv_img = top_img end - local usagehelp, noncreative, create_entry, paramtype2, palette + local noncreative, create_entry, paramtype2, palette if is_flower == nil then is_flower = true end @@ -475,9 +475,6 @@ local fix_doubleplants = minetest.settings:get_bool("fix_doubleplants", true) if mod_mcimport and mg_name == "singlenode" and fix_doubleplants == true then local flowernames = { "peony", "rose_bush", "lilac", "sunflower", "double_fern", "double_grass" } - for c=1, 6 do - local flowername = flowernames[c] - end minetest.register_lbm({ label = "Add double plant tops.", diff --git a/mods/ITEMS/mcl_furnaces/init.lua b/mods/ITEMS/mcl_furnaces/init.lua index 1d1ecc031..02a104bc5 100644 --- a/mods/ITEMS/mcl_furnaces/init.lua +++ b/mods/ITEMS/mcl_furnaces/init.lua @@ -384,7 +384,6 @@ local function furnace_node_timer(pos, elapsed) -- Update formspec and node -- local formspec = inactive_formspec - local item_state local item_percent = 0 if cookable then item_percent = math.floor(src_time / cooked.time * 100) @@ -414,7 +413,7 @@ local function furnace_node_timer(pos, elapsed) meta:set_float("fuel_time", fuel_time) meta:set_float("src_time", src_time) if srclist then - meta:set_string("src_item", srclist[1]:get_name()) + meta:set_string("src_item", src_item) else meta:set_string("src_item", "") end @@ -441,7 +440,12 @@ minetest.register_node("mcl_furnaces:furnace", { _tt_help = S("Uses fuel to smelt or cook items"), _doc_items_longdesc = S("Furnaces cook or smelt several items, using a furnace fuel, into something else."), _doc_items_usagehelp = - S("Use the furnace to open the furnace menu. Place a furnace fuel in the lower slot and the source material in the upper slot. The furnace will slowly use its fuel to smelt the item. The result will be placed into the output slot at the right side.").."\n".. + S([[ + Use the furnace to open the furnace menu. + Place a furnace fuel in the lower slot and the source material in the upper slot. + The furnace will slowly use its fuel to smelt the item. + The result will be placed into the output slot at the right side. + ]]).."\n".. S("Use the recipe book to see what you can smelt, what you can use as fuel and how long it will burn."), _doc_items_hidden = false, tiles = { diff --git a/mods/ITEMS/mcl_heads/init.lua b/mods/ITEMS/mcl_heads/init.lua index 2000c7070..e7340242d 100644 --- a/mods/ITEMS/mcl_heads/init.lua +++ b/mods/ITEMS/mcl_heads/init.lua @@ -90,7 +90,7 @@ local function addhead(name, texture, desc, longdesc, rangemob, rangefactor) local wdir = minetest.dir_to_wallmounted(diff) local itemstring = itemstack:get_name() - local fakestack = ItemStack(itemstack) + --local fakestack = ItemStack(itemstack) local idef = fakestack:get_definition() local retval if wdir == 0 or wdir == 1 then @@ -101,9 +101,7 @@ local function addhead(name, texture, desc, longdesc, rangemob, rangefactor) if not retval then return itemstack end - - local success - itemstack, success = minetest.item_place(fakestack, placer, pointed_thing, wdir) + itemstack,_ = minetest.item_place(fakestack, placer, pointed_thing, wdir) itemstack:set_name(itemstring) return itemstack end, diff --git a/mods/ITEMS/mcl_hoppers/init.lua b/mods/ITEMS/mcl_hoppers/init.lua index e9b3f75e0..e9f6ddf92 100644 --- a/mods/ITEMS/mcl_hoppers/init.lua +++ b/mods/ITEMS/mcl_hoppers/init.lua @@ -152,7 +152,7 @@ def_hopper_enabled.on_place = function(itemstack, placer, pointed_thing) local z = upos.z - apos.z local fake_itemstack = ItemStack(itemstack) - local newnode, param2 + local param2 if x == -1 then fake_itemstack:set_name("mcl_hoppers:hopper_side") param2 = 0 @@ -166,7 +166,7 @@ def_hopper_enabled.on_place = function(itemstack, placer, pointed_thing) fake_itemstack:set_name("mcl_hoppers:hopper_side") param2 = 1 end - local itemstack, success = minetest.item_place_node(fake_itemstack, placer, pointed_thing, param2) + local itemstack,_ = minetest.item_place_node(fake_itemstack, placer, pointed_thing, param2) itemstack:set_name("mcl_hoppers:hopper") return itemstack end @@ -411,7 +411,6 @@ minetest.register_abm({ -- Move an item from the hopper into container below local downnode = minetest.get_node(downpos) if not minetest.registered_nodes[downnode.name] then return end - g = minetest.registered_nodes[downnode.name].groups.container mcl_util.move_item_container(pos, downpos) end, }) @@ -462,7 +461,7 @@ minetest.register_abm({ -- Put fuel into fuel slot local sinv = minetest.get_inventory({type="node", pos = pos}) local dinv = minetest.get_inventory({type="node", pos = front}) - local slot_id, stack = mcl_util.get_eligible_transfer_item_slot(sinv, "main", dinv, "fuel", is_transferrable_fuel) + local slot_id,_ = mcl_util.get_eligible_transfer_item_slot(sinv, "main", dinv, "fuel", is_transferrable_fuel) if slot_id then mcl_util.move_item_container(pos, front, nil, slot_id, "fuel") end diff --git a/mods/ITEMS/mcl_monster_eggs/init.lua b/mods/ITEMS/mcl_monster_eggs/init.lua index 55875159e..dd986d127 100644 --- a/mods/ITEMS/mcl_monster_eggs/init.lua +++ b/mods/ITEMS/mcl_monster_eggs/init.lua @@ -20,11 +20,13 @@ local register_block = function(subname, description, tiles, is_ground_content) is_ground_content = is_ground_content, groups = {dig_immediate = 3, spawns_silverfish = 1, deco_block = 1}, drop = '', - is_ground_content = false, sounds = mcl_sounds.node_sound_stone_defaults(), after_dig_node = spawn_silverfish, _tt_help = S("Hides a silverfish"), - _doc_items_longdesc = S("An infested block is a block from which a silverfish will pop out when it is broken. It looks identical to its normal counterpart."), + _doc_items_longdesc = S([[ + An infested block is a block from which a silverfish will pop out when it is broken. + It looks identical to its normal counterpart. + ]]), _mcl_hardness = 0, _mcl_blast_resistance = 0.5, }) diff --git a/mods/ITEMS/mcl_mushrooms/small.lua b/mods/ITEMS/mcl_mushrooms/small.lua index 8105386f4..52c64928f 100644 --- a/mods/ITEMS/mcl_mushrooms/small.lua +++ b/mods/ITEMS/mcl_mushrooms/small.lua @@ -4,7 +4,6 @@ local on_place = mcl_util.generate_on_place_plant_function(function(place_pos, p local soil_node = minetest.get_node_or_nil({x=place_pos.x, y=place_pos.y-1, z=place_pos.z}) if not soil_node then return false end local snn = soil_node.name -- soil node name - local sd = minetest.registered_nodes[snn] -- soil definition -- Placement rules: -- * Always allowed on podzol or mycelimu diff --git a/mods/ITEMS/mcl_ocean/corals.lua b/mods/ITEMS/mcl_ocean/corals.lua index f3de5968e..376b8a22f 100644 --- a/mods/ITEMS/mcl_ocean/corals.lua +++ b/mods/ITEMS/mcl_ocean/corals.lua @@ -265,7 +265,6 @@ minetest.register_abm({ if minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name ~= "mcl_core:water_source" then -- Find dead form (it's the same as the node's drop) local def = minetest.registered_nodes[node.name] - local dead if def then node.name = def.drop else diff --git a/mods/ITEMS/mcl_ocean/kelp.lua b/mods/ITEMS/mcl_ocean/kelp.lua index 9670943da..326b08a81 100644 --- a/mods/ITEMS/mcl_ocean/kelp.lua +++ b/mods/ITEMS/mcl_ocean/kelp.lua @@ -37,14 +37,9 @@ local mt_record_protection_violation = minetest.record_protection_violation local mt_is_creative_enabled = minetest.is_creative_enabled local mt_sound_play = minetest.sound_play -local math_min = math.min -local math_max = math.max -local math_ceil = math.ceil -local math_floor = math.floor -local math_random = math.random -local string_format = string.format -local table_copy = table.copy -local table_insert = table.insert +local math = math +local string = string +local table = table -- DEBUG: functions -- local log = minetest.log @@ -122,7 +117,7 @@ function kelp.is_downward_flowing(pos, node, pos_above, node_above, __is_above__ -- Function params: (pos[, node]) or (node, pos_above) or (node, node_above) local node = node or mt_get_node(pos) - local result = (math_floor(node.param2 / 8) % 2) == 1 + local result = (math.floor(node.param2 / 8) % 2) == 1 if not (result or __is_above__) then -- If not, also check node above. -- (this is needed due a weird quirk in the definition of "downwards flowing" @@ -182,14 +177,14 @@ end -- Roll whether to grow kelp or not. function kelp.roll_growth(numerator, denominator) -- Optional params: numerator, denominator - return math_random(denominator or kelp.ROLL_GROWTH_DENOMINATOR) <= (numerator or kelp.ROLL_GROWTH_NUMERATOR) + return math.random(denominator or kelp.ROLL_GROWTH_DENOMINATOR) <= (numerator or kelp.ROLL_GROWTH_NUMERATOR) end -- Roll initial age for kelp. function kelp.roll_init_age(min, max) -- Optional params - return math_random(min or kelp.MIN_AGE, (max or kelp.MAX_AGE)-1) + return math.random(min or kelp.MIN_AGE, (max or kelp.MAX_AGE)-1) end @@ -197,7 +192,7 @@ end -- For the special case where the max param2 is reached, interpret that as the -- 16th kelp stem. function kelp.get_height(param2) - return math_floor(param2 / 16) + math_floor(param2 % 16 / 8) + return math.floor(param2 / 16) + math.floor(param2 % 16 / 8) end @@ -232,7 +227,7 @@ end -- Obtain next param2. function kelp.next_param2(param2) -- param2 max value is 255, so adding to 256 causes overflow. - return math_min(param2+16 - param2 % 16, 255); + return math.min(param2+16 - param2 % 16, 255); end @@ -242,8 +237,8 @@ function kelp.store_meta() for _ in pairs(kelp.age_queue_pos) do count = count + 1 end - -- chatlog(string_format("Storing age metadata: %d in queue", #kelp.age_queue)) - -- chatlog(string_format("Storing age metadata: %d valid in queue", count)) + -- chatlog(string.format("Storing age metadata: %d in queue", #kelp.age_queue)) + -- chatlog(string.format("Storing age metadata: %d valid in queue", count)) for i=1,#kelp.age_queue do local pos_hash = kelp.age_queue[i] local pos = kelp.age_queue_pos[pos_hash] @@ -265,7 +260,7 @@ function kelp.store_age(age, pos, pos_hash) kelp.age_pool[pos_hash] = age if not kelp.age_queue_pos[pos_hash] then - table_insert(kelp.age_queue, pos_hash) + table.insert(kelp.age_queue, pos_hash) kelp.age_queue_pos[pos_hash] = pos return true, pos_hash end @@ -713,7 +708,7 @@ function kelp.register_kelp_surface(surface, surface_deftemplate, surface_docs) doc.add_entry_alias("nodes", surface_docs.entry_id_orig, "nodes", surfacename) end - local sounds = table_copy(def.sounds) + local sounds = table.copy(def.sounds) sounds.dig = kelp.leaf_sounds.dig sounds.dug = kelp.leaf_sounds.dug sounds.place = kelp.leaf_sounds.place @@ -732,9 +727,9 @@ end -- Kelp surfaces nodes --------------------------------------------------------- -- Dirt must be registered first, for the docs -kelp.register_kelp_surface(kelp.surfaces[1], table_copy(kelp.surface_deftemplate), kelp.surface_docs) +kelp.register_kelp_surface(kelp.surfaces[1], table.copy(kelp.surface_deftemplate), kelp.surface_docs) for i=2, #kelp.surfaces do - kelp.register_kelp_surface(kelp.surfaces[i], table_copy(kelp.surface_deftemplate), kelp.surface_docs) + kelp.register_kelp_surface(kelp.surfaces[i], table.copy(kelp.surface_deftemplate), kelp.surface_docs) end -- Kelp item ------------------------------------------------------------------- diff --git a/mods/ITEMS/mcl_throwing/init.lua b/mods/ITEMS/mcl_throwing/init.lua index 09a34c12f..2d57744d0 100644 --- a/mods/ITEMS/mcl_throwing/init.lua +++ b/mods/ITEMS/mcl_throwing/init.lua @@ -1,10 +1,8 @@ mcl_throwing = {} -local S = minetest.get_translator("mcl_throwing") -local mod_death_messages = minetest.get_modpath("mcl_death_messages") local modpath = minetest.get_modpath(minetest.get_current_modname()) --- +-- -- Snowballs and other throwable items -- @@ -42,7 +40,7 @@ function mcl_throwing.get_player_throw_function(entity_name, velocity) local func = function(item, player, pointed_thing) local playerpos = player:get_pos() local dir = player:get_look_dir() - local obj = mcl_throwing.throw(item, {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, velocity, player:get_player_name()) + mcl_throwing.throw(item, {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, velocity, player:get_player_name()) if not minetest.is_creative_enabled(player:get_player_name()) then item:take_item() end diff --git a/mods/ITEMS/mcl_tnt/init.lua b/mods/ITEMS/mcl_tnt/init.lua index 8001e5cf0..19bd04a18 100644 --- a/mods/ITEMS/mcl_tnt/init.lua +++ b/mods/ITEMS/mcl_tnt/init.lua @@ -1,8 +1,6 @@ local S = minetest.get_translator("mcl_tnt") local tnt_griefing = minetest.settings:get_bool("mcl_tnt_griefing", true) -local mod_death_messages = minetest.get_modpath("mcl_death_messages") - local function spawn_tnt(pos, entname) minetest.sound_play("tnt_ignite", {pos = pos,gain = 1.0,max_hear_distance = 15,}, true) local tnt = minetest.add_entity(pos, entname) diff --git a/mods/MISC/mcl_commands/init.lua b/mods/MISC/mcl_commands/init.lua index 7a9fe4868..a287c2926 100644 --- a/mods/MISC/mcl_commands/init.lua +++ b/mods/MISC/mcl_commands/init.lua @@ -1,7 +1,3 @@ -local S = minetest.get_translator("mcl_commands") - -local mod_death_messages = minetest.get_modpath("mcl_death_messages") - local modpath = minetest.get_modpath(minetest.get_current_modname()) dofile(modpath.."/kill.lua") diff --git a/mods/MISC/mcl_commands/setblock.lua b/mods/MISC/mcl_commands/setblock.lua index 30d68b74f..dc834e1e8 100644 --- a/mods/MISC/mcl_commands/setblock.lua +++ b/mods/MISC/mcl_commands/setblock.lua @@ -6,7 +6,7 @@ minetest.register_chatcommand("setblock", { privs = {give=true, interact=true}, func = function(name, param) local p = {} - local nodestring = nil + local nodestring p.x, p.y, p.z, nodestring = param:match("^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+) +(.+)$") p.x, p.y, p.z = tonumber(p.x), tonumber(p.y), tonumber(p.z) if p.x and p.y and p.z and nodestring then diff --git a/mods/MISC/mcl_commands/sound.lua b/mods/MISC/mcl_commands/sound.lua index 934abb80e..06225271d 100644 --- a/mods/MISC/mcl_commands/sound.lua +++ b/mods/MISC/mcl_commands/sound.lua @@ -4,39 +4,34 @@ minetest.register_chatcommand("playsound",{ params = S(" "), --TODO:add source description = S("Play a sound. Arguments: : name of the sound. : Target."), privs = {server = true}, - func = function(name, params) + func = function(name, rawparams) local P = {} local i = 0 - for str in string.gmatch(params, "([^ ]+)") do + for str in string.gmatch(rawparams, "([^ ]+)") do i = i + 1 P[i] = str end - local params = {} if P[1] == tostring(P[1]) then params.name = P[1] else return false, S("Sound name is invalid!") --TODO: add mc chat message end - if P[2] == tostring(P[2]) and minetest.player_exists(P[2]) then params.target = P[2] else return false, S("Target is invalid!!") end - -- if P[3] then -- params.pos = nil --TODO:position -- else -- params.pos = nil -- end - -- if P[4] == tonumber(P[4]) then -- params.gain = P[4] -- else -- params.gain = 1.0 -- end - -- if P[5] == tonumber(P[5]) then -- params.pitch = P[5] -- else diff --git a/mods/MISC/mcl_temp_helper_recipes/init.lua b/mods/MISC/mcl_temp_helper_recipes/init.lua index d1262cb2c..ff9f541f3 100644 --- a/mods/MISC/mcl_temp_helper_recipes/init.lua +++ b/mods/MISC/mcl_temp_helper_recipes/init.lua @@ -27,7 +27,12 @@ minetest.register_craft({ minetest.register_craft({ type = "shapeless", output = "mcl_ocean:prismarine_crystals", - recipe = { "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_core:gold_ingot" }, + recipe = { + "mcl_ocean:prismarine_shard", + "mcl_ocean:prismarine_shard", + "mcl_ocean:prismarine_shard", + "mcl_core:gold_ingot", + }, }) minetest.register_craft({ diff --git a/mods/PLAYER/mcl_death_drop/init.lua b/mods/PLAYER/mcl_death_drop/init.lua index 7c54334a9..90a2b0fbd 100644 --- a/mods/PLAYER/mcl_death_drop/init.lua +++ b/mods/PLAYER/mcl_death_drop/init.lua @@ -20,7 +20,7 @@ minetest.register_on_dieplayer(function(player) local playerinv = player:get_inventory() local pos = player:get_pos() -- No item drop if in deep void - local void, void_deadly = mcl_worlds.is_in_void(pos) + local _, void_deadly = mcl_worlds.is_in_void(pos) for l=1,#mcl_death_drop.registered_dropped_lists do local inv = mcl_death_drop.registered_dropped_lists[l].inv diff --git a/mods/PLAYER/mcl_hunger/api.lua b/mods/PLAYER/mcl_hunger/api.lua index 55153b9bf..4fea9b04e 100644 --- a/mods/PLAYER/mcl_hunger/api.lua +++ b/mods/PLAYER/mcl_hunger/api.lua @@ -86,7 +86,8 @@ if mcl_hunger.active then function mcl_hunger.saturate(playername, increase, update_hudbar) local player = minetest.get_player_by_name(playername) - local ok = mcl_hunger.set_saturation(player, math.min(mcl_hunger.get_saturation(player) + increase, mcl_hunger.get_hunger(player))) + local ok = mcl_hunger.set_saturation(player, + math.min(mcl_hunger.get_saturation(player) + increase, mcl_hunger.get_hunger(player))) if update_hudbar ~= false then mcl_hunger.update_saturation_hud(player, mcl_hunger.get_saturation(player), mcl_hunger.get_hunger(player)) end @@ -105,7 +106,7 @@ if mcl_hunger.active then -- otherwise the following poison/exhaust fields are ignored food[name].poison = poison -- poison damage per tick for poisonous food food[name].exhaust = exhaust -- exhaustion per tick for poisonous food - food[name].poisonchance = poisonchance -- chance percentage that this item poisons the player (default: 100% if poisoning is enabled) + food[name].poisonchance = poisonchance -- chance percentage that this item poisons the player (default: 100%) food[name].sound = sound -- special sound that is played when eating end diff --git a/mods/PLAYER/mcl_hunger/hunger.lua b/mods/PLAYER/mcl_hunger/hunger.lua index 393bdc9a9..30ad10ac2 100644 --- a/mods/PLAYER/mcl_hunger/hunger.lua +++ b/mods/PLAYER/mcl_hunger/hunger.lua @@ -2,7 +2,6 @@ local S = minetest.get_translator("mcl_hunger") local mod_death_messages = minetest.get_modpath("mcl_death_messages") -- wrapper for minetest.item_eat (this way we make sure other mods can't break this one) -local org_eat = minetest.do_item_eat minetest.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing) if not user or user:is_player() == false then @@ -38,7 +37,8 @@ minetest.do_item_eat = function(hp_change, replace_with_item, itemstack, user, p -- FIXME: In singleplayer, there's a cheat to circumvent this, simply by pausing the game between eats. -- This is because os.time() obviously does not care about the pause. A fix needs a different timer mechanism. if no_eat_delay or (mcl_hunger.last_eat[name] < 0) or (os.difftime(os.time(), mcl_hunger.last_eat[name]) >= 2) then - local can_eat_when_full = creative or (mcl_hunger.active == false) or minetest.get_item_group(itemstack:get_name(), "can_eat_when_full") == 1 + local can_eat_when_full = creative or (mcl_hunger.active == false) + or minetest.get_item_group(itemstack:get_name(), "can_eat_when_full") == 1 -- Don't allow eating when player has full hunger bar (some exceptional items apply) if can_eat_when_full or (mcl_hunger.get_hunger(user) < 20) then itemstack = mcl_hunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing) @@ -67,7 +67,8 @@ function mcl_hunger.eat(hp_change, replace_with_item, itemstack, user, pointed_t def.saturation = hp_change def.replace = replace_with_item end - local func = mcl_hunger.item_eat(def.saturation, def.replace, def.poisontime, def.poison, def.exhaust, def.poisonchance, def.sound) + local func = mcl_hunger.item_eat(def.saturation, def.replace, def.poisontime, + def.poison, def.exhaust, def.poisonchance, def.sound) return func(itemstack, user, pointed_thing) end @@ -90,7 +91,6 @@ local function poisonp(tick, time, time_left, damage, exhaustion, name) if not player then return end - local name = player:get_player_name() -- Abort if food poisonings have been stopped if mcl_hunger.poison_hunger[name] == 0 then return @@ -131,7 +131,7 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poiso itemstack:take_item() end local name = user:get_player_name() - local hp = user:get_hp() + --local hp = user:get_hp() local pos = user:get_pos() -- player height diff --git a/mods/PLAYER/mcl_hunger/init.lua b/mods/PLAYER/mcl_hunger/init.lua index b640dfdc9..c65206599 100644 --- a/mods/PLAYER/mcl_hunger/init.lua +++ b/mods/PLAYER/mcl_hunger/init.lua @@ -65,9 +65,7 @@ end -- Count number of poisonings a player has at once mcl_hunger.poison_hunger = {} -- food poisoning, increasing hunger --- HUD item ids -local hunger_hud = {} - +-- HUD local function init_hud(player) hb.init_hudbar(player, "hunger", mcl_hunger.get_hunger(player)) if mcl_hunger.debug then diff --git a/mods/PLAYER/mcl_meshhand/init.lua b/mods/PLAYER/mcl_meshhand/init.lua index cdd5da946..80bf36b7d 100644 --- a/mods/PLAYER/mcl_meshhand/init.lua +++ b/mods/PLAYER/mcl_meshhand/init.lua @@ -63,7 +63,6 @@ end if has_mcl_skins == true then --change the player's hand to their skin mcl_skins.register_on_set_skin(function(player, skin) - local name = player:get_player_name() local meta = mcl_skins.meta[skin] if meta.gender == "female" then player:get_inventory():set_stack("hand", 1, "mcl_meshhand:"..skin.."_female") diff --git a/mods/PLAYER/mcl_player/init.lua b/mods/PLAYER/mcl_player/init.lua index 210e2d19f..9df852502 100644 --- a/mods/PLAYER/mcl_player/init.lua +++ b/mods/PLAYER/mcl_player/init.lua @@ -9,7 +9,7 @@ local animation_blend = 0 local function get_mouse_button(player) local controls = player:get_player_control() local get_wielded_item_name = player:get_wielded_item():get_name() - if controls.RMB and not string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") or controls.LMB then + if controls.RMB and not string.find(get_wielded_item_name, "mcl_bows:bow") or controls.LMB then return true else return false @@ -110,7 +110,7 @@ function mcl_player.get_player_formspec_model(player, x, y, w, h, fsname) local name = player:get_player_name() local model = player_model[name] local anim = models[model].animations[player_anim[name]] - return "model[" .. x .. "," .. y .. ";" .. w .. "," .. h .. ";" .. fsname .. ";" .. model .. ";" .. table.concat(player_textures[name], ",") .. ";0," .. 180 .. ";false;false;" .. anim.x .. "," .. anim.y .. "]" + return "model["..x..","..y..";"..w..","..h..";"..fsname..";"..model..";"..table.concat(player_textures[name], ",")..";0,".. 180 ..";false;false;"..anim.x..","..anim.y.."]" end function mcl_player.player_set_animation(player, anim_name, speed) @@ -179,7 +179,10 @@ minetest.register_globalstep(function(dtime) -- Apply animations based on what the player is doing if player:get_hp() == 0 then player_set_animation(player, "die") - elseif walking and velocity.x > 0.35 or walking and velocity.x < -0.35 or walking and velocity.z > 0.35 or walking and velocity.z < -0.35 then + elseif walking and velocity.x > 0.35 + or walking and velocity.x < -0.35 + or walking and velocity.z > 0.35 + or walking and velocity.z < -0.35 then if player_sneak[name] ~= controls.sneak then player_anim[name] = nil player_sneak[name] = controls.sneak diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index f4dceb9b4..5cca23d32 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -29,7 +29,7 @@ local look_pitch = 0 local player_collision = function(player) local pos = player:get_pos() - local vel = player:get_velocity() + --local vel = player:get_velocity() local x = 0 local z = 0 local width = .75 @@ -58,18 +58,8 @@ local function degrees(rad) return rad * 180.0 / math.pi end -local pi = math.pi -local atann = math.atan -local atan = function(x) - if not x or x ~= x then - return 0 - else - return atann(x) - end -end - local dir_to_pitch = function(dir) - local dir2 = vector.normalize(dir) + --local dir2 = vector.normalize(dir) local xz = math.abs(dir.x) + math.abs(dir.z) return -math.atan2(-dir.y, xz) end @@ -121,7 +111,7 @@ function limit_vel_yaw(player_vel_yaw, yaw) return player_vel_yaw end -local pitch, name, node_stand, node_stand_below, node_head, node_feet, pos +local node_stand, node_stand_below, node_head, node_feet minetest.register_on_punchplayer(function(player, hitter, damage) @@ -178,7 +168,7 @@ minetest.register_globalstep(function(dtime) local control = player:get_player_control() local name = player:get_player_name() - local meta = player:get_meta() + --local meta = player:get_meta() local parent = player:get_attach() local wielded = player:get_wielded_item() local player_velocity = player:get_velocity() or player:get_player_velocity() @@ -217,7 +207,7 @@ minetest.register_globalstep(function(dtime) elytra[player] = true elseif key=="RMB" then if wielded:get_name() == "mcl_tools:rocket" then - local item = wielded:take_item() + wielded:take_item() player:set_wielded_item(wielded) end end @@ -314,7 +304,7 @@ minetest.register_globalstep(function(dtime) if control.jump and mcl_playerplus_internal[name].jump_cooldown <= 0 then - pos = player:get_pos() + --pos = player:get_pos() node_stand = mcl_playerinfo[name].node_stand node_stand_below = mcl_playerinfo[name].node_stand_below diff --git a/mods/PLAYER/mcl_skins/init.lua b/mods/PLAYER/mcl_skins/init.lua index 5956aab7c..297817fac 100644 --- a/mods/PLAYER/mcl_skins/init.lua +++ b/mods/PLAYER/mcl_skins/init.lua @@ -198,7 +198,6 @@ minetest.register_chatcommand("setskin", { end end - local skin local ok = mcl_skins.set_player_skin(player, skin_id) if not ok then return false, S("Invalid skin number! Valid numbers: 0 to @1", mcl_skins.skin_count) diff --git a/mods/PLAYER/mcl_sprint/init.lua b/mods/PLAYER/mcl_sprint/init.lua index 9dc678000..12d0394e5 100644 --- a/mods/PLAYER/mcl_sprint/init.lua +++ b/mods/PLAYER/mcl_sprint/init.lua @@ -53,7 +53,10 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player local controls = player:get_player_control() if players[playerName] then players[playerName].sprinting = sprinting - if sprinting == true or controls.RMB and string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") and player:get_wielded_item():get_name() ~= "mcl_bows:bow" then + if sprinting == true + or controls.RMB + and string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") + and player:get_wielded_item():get_name() ~= "mcl_bows:bow" then if sprinting == true then players[playerName].fov = math.min(players[playerName].fov + 0.05, 1.2) players[playerName].fade_time = .15 @@ -65,7 +68,10 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player if sprinting == true then playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED) end - elseif sprinting == false and player:get_wielded_item():get_name() ~= "mcl_bows:bow_0" and player:get_wielded_item():get_name() ~= "mcl_bows:bow_1" and player:get_wielded_item():get_name() ~= "mcl_bows:bow_2" then + elseif sprinting == false + and player:get_wielded_item():get_name() ~= "mcl_bows:bow_0" + and player:get_wielded_item():get_name() ~= "mcl_bows:bow_1" + and player:get_wielded_item():get_name() ~= "mcl_bows:bow_2" then players[playerName].fov = math.max(players[playerName].fov - 0.05, 1.0) player:set_fov(players[playerName].fov, true, 0.15) if sprinting == false then @@ -186,7 +192,8 @@ minetest.register_globalstep(function(dtime) if players[playerName]["shouldSprint"] == true then --Stopped local sprinting -- Prevent sprinting if hungry or sleeping - if (mcl_hunger.active and mcl_hunger.get_hunger(player) <= 6) or (player:get_meta():get_string("mcl_beds:sleeping") == "true") then + if (mcl_hunger.active and mcl_hunger.get_hunger(player) <= 6) + or (player:get_meta():get_string("mcl_beds:sleeping") == "true") then sprinting = false cancelClientSprinting(playerName) else diff --git a/mods/PLAYER/wieldview/init.lua b/mods/PLAYER/wieldview/init.lua index 7a349f2f3..91b2cd721 100644 --- a/mods/PLAYER/wieldview/init.lua +++ b/mods/PLAYER/wieldview/init.lua @@ -1,4 +1,3 @@ -local time = 0 local update_time = tonumber(minetest.settings:get("wieldview_update_time")) if not update_time then update_time = 2 @@ -69,14 +68,14 @@ end minetest.register_on_joinplayer(function(player) local name = player:get_player_name() wieldview.wielded_item[name] = "" - minetest.after(0, function(player) + minetest.after(0, function(target) -- if the player left :is_player() will return nil - if not player:is_player() then + if not target:is_player() then return end - wieldview:update_wielded_item(player) - local itementity = minetest.add_entity(player:get_pos(), "wieldview:wieldnode") - itementity:set_attach(player, "Hand_Right", vector.new(0, 1, 0), vector.new(90, 0, 45)) + wieldview:update_wielded_item(target) + local itementity = minetest.add_entity(target:get_pos(), "wieldview:wieldnode") + itementity:set_attach(target, "Hand_Right", vector.new(0, 1, 0), vector.new(90, 0, 45)) itementity:get_luaentity().wielder = name end, player) end)