From cd33d406b2658db0d3563b57892c2d923f22d24e Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 29 May 2021 16:12:33 +0200 Subject: [PATCH] fix many codestyle issues (functions, strings, modpaths) --- mods/CORE/_mcl_autogroup/init.lua | 2 +- mods/CORE/controls/init.lua | 58 +- mods/CORE/mcl_explosions/init.lua | 16 +- mods/CORE/mcl_worlds/init.lua | 20 +- mods/CORE/walkover/init.lua | 5 +- mods/ENTITIES/mcl_boats/init.lua | 4 +- mods/ENTITIES/mcl_burning/init.lua | 11 +- mods/ENTITIES/mcl_item_entity/init.lua | 10 +- mods/ENTITIES/mcl_minecarts/init.lua | 11 +- mods/ENTITIES/mcl_minecarts/rails.lua | 10 +- mods/ENTITIES/mcl_mobs/api/api.lua | 4 +- .../mcl_mobs/api/mob_functions/ai.lua | 2 +- .../attack_type_instructions.lua | 5 +- .../api/mob_functions/projectile_handling.lua | 3 +- mods/ENTITIES/mcl_mobs/api/spawning.lua | 14 +- mods/ENTITIES/mcl_mobs/crafts.lua | 2 +- mods/ENTITIES/mcl_paintings/init.lua | 5 +- mods/ENTITIES/mobs_mc/1_items_default.lua | 6 +- mods/ENTITIES/mobs_mc/2_throwing.lua | 20 +- mods/ENTITIES/mobs_mc/4_heads.lua | 2 +- mods/ENTITIES/mobs_mc/agent.lua | 2 +- mods/ENTITIES/mobs_mc/bat.lua | 2 +- mods/ENTITIES/mobs_mc/blaze.lua | 2 +- mods/ENTITIES/mobs_mc/chicken.lua | 2 +- mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 2 +- mods/ENTITIES/mobs_mc/creeper.lua | 10 +- mods/ENTITIES/mobs_mc/ender_dragon.lua | 2 +- mods/ENTITIES/mobs_mc/enderman.lua | 24 +- mods/ENTITIES/mobs_mc/endermite.lua | 2 +- mods/ENTITIES/mobs_mc/ghast.lua | 2 +- mods/ENTITIES/mobs_mc/guardian.lua | 2 +- mods/ENTITIES/mobs_mc/guardian_elder.lua | 2 +- mods/ENTITIES/mobs_mc/horse.lua | 2 +- mods/ENTITIES/mobs_mc/init.lua | 2 +- mods/ENTITIES/mobs_mc/iron_golem.lua | 2 +- mods/ENTITIES/mobs_mc/llama.lua | 2 +- mods/ENTITIES/mobs_mc/ocelot.lua | 2 +- mods/ENTITIES/mobs_mc/parrot.lua | 2 +- mods/ENTITIES/mobs_mc/pig.lua | 2 +- mods/ENTITIES/mobs_mc/polar_bear.lua | 2 +- mods/ENTITIES/mobs_mc/rabbit.lua | 2 +- mods/ENTITIES/mobs_mc/sheep.lua | 4 +- mods/ENTITIES/mobs_mc/shulker.lua | 2 +- mods/ENTITIES/mobs_mc/silverfish.lua | 12 +- mods/ENTITIES/mobs_mc/skeleton+stray.lua | 4 +- mods/ENTITIES/mobs_mc/skeleton_wither.lua | 2 +- mods/ENTITIES/mobs_mc/slime+magma_cube.lua | 6 +- mods/ENTITIES/mobs_mc/snowman.lua | 4 +- mods/ENTITIES/mobs_mc/spider.lua | 2 +- mods/ENTITIES/mobs_mc/squid.lua | 2 +- mods/ENTITIES/mobs_mc/vex.lua | 2 +- mods/ENTITIES/mobs_mc/villager.lua | 2 +- mods/ENTITIES/mobs_mc/villager_evoker.lua | 2 +- mods/ENTITIES/mobs_mc/villager_illusioner.lua | 4 +- mods/ENTITIES/mobs_mc/villager_vindicator.lua | 2 +- mods/ENTITIES/mobs_mc/villager_zombie.lua | 2 +- mods/ENTITIES/mobs_mc/witch.lua | 2 +- mods/ENTITIES/mobs_mc/wither.lua | 2 +- mods/ENTITIES/mobs_mc/wolf.lua | 2 +- mods/ENTITIES/mobs_mc/zombie.lua | 2 +- mods/ENTITIES/mobs_mc/zombiepig.lua | 2 +- mods/ENVIRONMENT/mcl_void_damage/init.lua | 2 +- mods/ENVIRONMENT/mcl_weather/init.lua | 4 +- mods/ENVIRONMENT/mcl_weather/rain.lua | 10 +- mods/ENVIRONMENT/mcl_weather/weather_core.lua | 10 +- mods/HELP/doc/doc/init.lua | 52 +- mods/HELP/doc/doc_identifier/init.lua | 22 +- mods/HELP/doc/doc_items/init.lua | 128 +- mods/HELP/mcl_doc/init.lua | 10 +- mods/HELP/mcl_doc_basics/init.lua | 2 +- mods/HELP/mcl_doc_basics/mcl_extension.lua | 2 +- mods/HELP/mcl_tt/init.lua | 6 +- mods/HELP/mcl_tt/snippets_base.lua | 2 +- mods/HELP/mcl_tt/snippets_mcl.lua | 2 +- mods/HELP/tt/init.lua | 2 +- mods/HUD/awards/api.lua | 13 +- mods/HUD/awards/chat_commands.lua | 2 +- mods/HUD/awards/init.lua | 12 +- mods/HUD/awards/sfinv.lua | 2 +- mods/HUD/awards/triggers.lua | 4 +- mods/HUD/hudbars/default_settings.lua | 2 +- mods/HUD/hudbars/init.lua | 34 +- mods/HUD/mcl_achievements/init.lua | 2 +- mods/HUD/mcl_death_messages/init.lua | 2 +- mods/HUD/mcl_experience/init.lua | 2 +- mods/HUD/mcl_hbarmor/init.lua | 2 +- mods/HUD/mcl_inventory/creative.lua | 304 +++-- mods/HUD/mcl_inventory/init.lua | 6 +- mods/HUD/show_wielded_item/init.lua | 8 +- mods/ITEMS/REDSTONE/mcl_comparators/init.lua | 30 +- mods/ITEMS/REDSTONE/mcl_dispensers/init.lua | 13 +- mods/ITEMS/REDSTONE/mcl_droppers/init.lua | 12 +- mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua | 20 +- mods/ITEMS/REDSTONE/mcl_observers/init.lua | 2 +- mods/ITEMS/REDSTONE/mesecons/actionqueue.lua | 6 +- mods/ITEMS/REDSTONE/mesecons/internal.lua | 6 +- mods/ITEMS/REDSTONE/mesecons_button/init.lua | 10 +- .../REDSTONE/mesecons_commandblock/init.lua | 26 +- .../REDSTONE/mesecons_commandblock/mod.conf | 2 +- mods/ITEMS/REDSTONE/mesecons_delayer/init.lua | 14 +- .../REDSTONE/mesecons_lightstone/init.lua | 12 +- .../REDSTONE/mesecons_noteblock/init.lua | 21 +- mods/ITEMS/REDSTONE/mesecons_pistons/init.lua | 4 +- .../REDSTONE/mesecons_pressureplates/init.lua | 2 +- .../REDSTONE/mesecons_solarpanel/init.lua | 10 +- mods/ITEMS/REDSTONE/mesecons_torch/init.lua | 26 +- .../REDSTONE/mesecons_walllever/init.lua | 16 +- mods/ITEMS/REDSTONE/mesecons_wires/init.lua | 12 +- mods/ITEMS/mcl_anvils/init.lua | 4 +- mods/ITEMS/mcl_armor/init.lua | 2 +- mods/ITEMS/mcl_armor/register.lua | 2 +- mods/ITEMS/mcl_armor_stand/init.lua | 2 +- mods/ITEMS/mcl_banners/init.lua | 19 +- mods/ITEMS/mcl_banners/patterncraft.lua | 2 +- mods/ITEMS/mcl_beds/api.lua | 2 +- mods/ITEMS/mcl_beds/beds.lua | 2 +- mods/ITEMS/mcl_beds/functions.lua | 23 +- mods/ITEMS/mcl_books/init.lua | 16 +- mods/ITEMS/mcl_bows/arrow.lua | 28 +- mods/ITEMS/mcl_bows/bow.lua | 20 +- mods/ITEMS/mcl_buckets/init.lua | 12 +- mods/ITEMS/mcl_buckets/register.lua | 4 +- mods/ITEMS/mcl_cake/init.lua | 12 +- mods/ITEMS/mcl_cauldrons/init.lua | 2 +- mods/ITEMS/mcl_chests/init.lua | 1110 ++++++++--------- mods/ITEMS/mcl_clock/init.lua | 10 +- mods/ITEMS/mcl_cocoas/init.lua | 2 +- mods/ITEMS/mcl_colorblocks/init.lua | 18 +- mods/ITEMS/mcl_compass/init.lua | 12 +- mods/ITEMS/mcl_core/crafting.lua | 210 ++-- mods/ITEMS/mcl_core/craftitems.lua | 2 +- mods/ITEMS/mcl_core/functions.lua | 43 +- mods/ITEMS/mcl_core/init.lua | 2 +- mods/ITEMS/mcl_core/nodes_base.lua | 44 +- mods/ITEMS/mcl_core/nodes_cactuscane.lua | 2 +- mods/ITEMS/mcl_core/nodes_climb.lua | 2 +- mods/ITEMS/mcl_core/nodes_glass.lua | 10 +- mods/ITEMS/mcl_core/nodes_liquid.lua | 12 +- mods/ITEMS/mcl_core/nodes_misc.lua | 10 +- mods/ITEMS/mcl_core/nodes_trees.lua | 7 +- mods/ITEMS/mcl_crafting_table/init.lua | 2 +- mods/ITEMS/mcl_doors/api_doors.lua | 2 +- mods/ITEMS/mcl_doors/api_trapdoors.lua | 2 +- mods/ITEMS/mcl_doors/register.lua | 8 +- mods/ITEMS/mcl_dye/init.lua | 28 +- mods/ITEMS/mcl_enchanting/enchantments.lua | 2 +- mods/ITEMS/mcl_enchanting/engine.lua | 2 +- mods/ITEMS/mcl_enchanting/init.lua | 7 +- mods/ITEMS/mcl_end/building.lua | 5 +- mods/ITEMS/mcl_end/chorus_plant.lua | 9 +- mods/ITEMS/mcl_end/end_crystal.lua | 2 +- mods/ITEMS/mcl_end/eye_of_ender.lua | 2 +- mods/ITEMS/mcl_farming/beetroot.lua | 2 +- mods/ITEMS/mcl_farming/carrots.lua | 18 +- mods/ITEMS/mcl_farming/hoes.lua | 2 +- mods/ITEMS/mcl_farming/melon.lua | 20 +- mods/ITEMS/mcl_farming/potatoes.lua | 14 +- mods/ITEMS/mcl_farming/pumpkin.lua | 5 +- mods/ITEMS/mcl_farming/shared_functions.lua | 14 +- mods/ITEMS/mcl_farming/soil.lua | 4 +- mods/ITEMS/mcl_farming/wheat.lua | 28 +- mods/ITEMS/mcl_fences/init.lua | 18 +- mods/ITEMS/mcl_fire/fire_charge.lua | 17 +- mods/ITEMS/mcl_fire/flint_and_steel.lua | 16 +- mods/ITEMS/mcl_fire/init.lua | 19 +- mods/ITEMS/mcl_fire/mod.conf | 2 +- mods/ITEMS/mcl_fireworks/register.lua | 2 +- mods/ITEMS/mcl_fishing/init.lua | 16 +- mods/ITEMS/mcl_flowerpots/init.lua | 10 +- mods/ITEMS/mcl_flowers/init.lua | 55 +- mods/ITEMS/mcl_flowers/register.lua | 2 +- mods/ITEMS/mcl_furnaces/init.lua | 14 +- mods/ITEMS/mcl_heads/init.lua | 2 +- mods/ITEMS/mcl_hoppers/init.lua | 2 +- mods/ITEMS/mcl_itemframes/init.lua | 26 +- mods/ITEMS/mcl_jukebox/init.lua | 35 +- mods/ITEMS/mcl_maps/init.lua | 35 +- mods/ITEMS/mcl_mobitems/init.lua | 6 +- mods/ITEMS/mcl_mobspawners/init.lua | 6 +- mods/ITEMS/mcl_monster_eggs/init.lua | 8 +- mods/ITEMS/mcl_mushrooms/huge.lua | 18 +- mods/ITEMS/mcl_mushrooms/small.lua | 4 +- mods/ITEMS/mcl_nether/init.lua | 55 +- mods/ITEMS/mcl_nether/nether_wart.lua | 6 +- mods/ITEMS/mcl_ocean/corals.lua | 4 +- mods/ITEMS/mcl_ocean/kelp.lua | 6 +- mods/ITEMS/mcl_ocean/prismarine.lua | 36 +- mods/ITEMS/mcl_ocean/sea_pickle.lua | 5 +- mods/ITEMS/mcl_ocean/seagrass.lua | 5 +- mods/ITEMS/mcl_portals/init.lua | 8 +- mods/ITEMS/mcl_portals/portal_end.lua | 4 +- mods/ITEMS/mcl_portals/portal_gateway.lua | 9 +- mods/ITEMS/mcl_portals/portal_nether.lua | 4 +- mods/ITEMS/mcl_potions/commands.lua | 2 +- mods/ITEMS/mcl_potions/init.lua | 26 +- mods/ITEMS/mcl_potions/lingering.lua | 7 +- mods/ITEMS/mcl_potions/potions.lua | 4 +- mods/ITEMS/mcl_potions/splash.lua | 5 +- mods/ITEMS/mcl_potions/tipped_arrow.lua | 33 +- mods/ITEMS/mcl_signs/init.lua | 41 +- mods/ITEMS/mcl_sponges/init.lua | 4 +- mods/ITEMS/mcl_stairs/api.lua | 8 +- mods/ITEMS/mcl_stairs/cornerstair.lua | 16 +- mods/ITEMS/mcl_stairs/crafting.lua | 30 +- mods/ITEMS/mcl_stairs/init.lua | 12 +- mods/ITEMS/mcl_stairs/register.lua | 2 +- mods/ITEMS/mcl_throwing/init.lua | 2 +- mods/ITEMS/mcl_throwing/register.lua | 28 +- mods/ITEMS/mcl_tnt/init.lua | 13 +- mods/ITEMS/mcl_tools/crafting.lua | 212 ++-- mods/ITEMS/mcl_tools/init.lua | 14 +- mods/ITEMS/mcl_torches/api.lua | 6 +- mods/ITEMS/mcl_torches/init.lua | 2 +- mods/ITEMS/mcl_torches/register.lua | 2 +- mods/ITEMS/mcl_walls/init.lua | 16 +- mods/ITEMS/mcl_walls/register.lua | 2 +- mods/ITEMS/mcl_wool/init.lua | 10 +- mods/ITEMS/mclx_core/init.lua | 2 +- mods/ITEMS/mclx_fences/init.lua | 10 +- mods/ITEMS/mclx_stairs/init.lua | 2 +- mods/ITEMS/screwdriver/init.lua | 19 +- mods/ITEMS/xpanes/init.lua | 2 +- mods/MAPGEN/mcl_biomes/init.lua | 84 +- mods/MAPGEN/mcl_mapgen_core/init.lua | 14 +- mods/MAPGEN/mcl_structures/init.lua | 28 +- mods/MAPGEN/mcl_villages/buildings.lua | 4 +- mods/MAPGEN/mcl_villages/init.lua | 4 +- mods/MAPGEN/tsm_railcorridors/init.lua | 13 +- mods/MISC/findbiome/init.lua | 4 +- mods/MISC/mcl_commands/alias.lua | 2 +- mods/MISC/mcl_commands/kill.lua | 2 +- mods/MISC/mcl_commands/list.lua | 2 +- mods/MISC/mcl_commands/say.lua | 2 +- mods/MISC/mcl_commands/seed.lua | 2 +- mods/MISC/mcl_commands/setblock.lua | 2 +- mods/MISC/mcl_commands/sound.lua | 2 +- mods/MISC/mcl_commands/summon.lua | 2 +- mods/MISC/mcl_privs/init.lua | 2 +- mods/MISC/mcl_temp_helper_recipes/init.lua | 2 +- mods/MISC/mcl_wip/init.lua | 4 +- mods/PLAYER/mcl_death_drop/init.lua | 6 +- mods/PLAYER/mcl_hunger/api.lua | 2 +- mods/PLAYER/mcl_hunger/hunger.lua | 7 +- mods/PLAYER/mcl_hunger/init.lua | 11 +- mods/PLAYER/mcl_skins/init.lua | 12 +- mods/PLAYER/mcl_spawn/init.lua | 14 +- mods/PLAYER/mcl_sprint/init.lua | 35 +- mods/PLAYER/mcl_wieldview/init.lua | 10 +- 248 files changed, 2223 insertions(+), 2099 deletions(-) diff --git a/mods/CORE/_mcl_autogroup/init.lua b/mods/CORE/_mcl_autogroup/init.lua index 76c68122b..ba8b659c0 100644 --- a/mods/CORE/_mcl_autogroup/init.lua +++ b/mods/CORE/_mcl_autogroup/init.lua @@ -83,7 +83,7 @@ local function get_hardness_values_for_groups() for _, ndef in pairs(minetest.registered_nodes) do for g, _ in pairs(mcl_autogroup.registered_diggroups) do - if ndef.groups[g] ~= nil then + if ndef.groups[g] then maps[g][ndef._mcl_hardness or 0] = true end end diff --git a/mods/CORE/controls/init.lua b/mods/CORE/controls/init.lua index 2ceb7e902..ef57281a4 100644 --- a/mods/CORE/controls/init.lua +++ b/mods/CORE/controls/init.lua @@ -1,6 +1,8 @@ local get_connected_players = minetest.get_connected_players local clock = os.clock +local pairs = pairs + controls = {} controls.players = {} @@ -20,15 +22,15 @@ function controls.register_on_hold(func) end local known_controls = { - jump=true, - right=true, - left=true, - LMB=true, - RMB=true, - sneak=true, - aux1=true, - down=true, - up=true, + jump = true, + right = true, + left = true, + LMB = true, + RMB = true, + sneak = true, + aux1 = true, + down = true, + up = true, } minetest.register_on_joinplayer(function(player) @@ -49,27 +51,27 @@ minetest.register_globalstep(function(dtime) local player_name = player:get_player_name() local player_controls = player:get_player_control() if controls.players[player_name] then - for cname, cbool in pairs(player_controls) do - if known_controls[cname] == true then - --Press a key - if cbool==true and controls.players[player_name][cname][1]==false then - for _, func in pairs(controls.registered_on_press) do - func(player, cname) + for cname, cbool in pairs(player_controls) do + if known_controls[cname] == true then + --Press a key + if cbool == true and controls.players[player_name][cname][1] == false then + for _, func in pairs(controls.registered_on_press) do + func(player, cname) + end + controls.players[player_name][cname] = {true, clock()} + elseif cbool == true and controls.players[player_name][cname][1] == true then + for _, func in pairs(controls.registered_on_hold) do + func(player, cname, clock()-controls.players[player_name][cname][2]) + end + --Release a key + elseif cbool == false and controls.players[player_name][cname][1] == true then + for _, func in pairs(controls.registered_on_release) do + func(player, cname, clock()-controls.players[player_name][cname][2]) + end + controls.players[player_name][cname] = {false} + end end - controls.players[player_name][cname] = {true, clock()} - elseif cbool==true and controls.players[player_name][cname][1]==true then - for _, func in pairs(controls.registered_on_hold) do - func(player, cname, clock()-controls.players[player_name][cname][2]) - end - --Release a key - elseif cbool==false and controls.players[player_name][cname][1]==true then - for _, func in pairs(controls.registered_on_release) do - func(player, cname, clock()-controls.players[player_name][cname][2]) - end - controls.players[player_name][cname] = {false} end end - end - end end end) diff --git a/mods/CORE/mcl_explosions/init.lua b/mods/CORE/mcl_explosions/init.lua index 3a60f2f37..0132d1669 100644 --- a/mods/CORE/mcl_explosions/init.lua +++ b/mods/CORE/mcl_explosions/init.lua @@ -12,9 +12,13 @@ under the LGPLv2.1 license. mcl_explosions = {} -local mod_fire = minetest.get_modpath("mcl_fire") ~= nil +local mod_fire = minetest.get_modpath("mcl_fire") --local CONTENT_FIRE = minetest.get_content_id("mcl_fire:fire") +local math = math +local vector = vector +local table = table + local hash_node_position = minetest.hash_node_position local get_objects_inside_radius = minetest.get_objects_inside_radius local get_position_from_hash = minetest.get_position_from_hash @@ -24,6 +28,7 @@ local get_voxel_manip = minetest.get_voxel_manip local bulk_set_node = minetest.bulk_set_node local check_for_falling = minetest.check_for_falling local add_item = minetest.add_item +local pos_to_string = minetest.pos_to_string -- Saved sphere explosion shapes for various radiuses local sphere_shapes = {} @@ -240,7 +245,7 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc local ent = obj:get_luaentity() -- Ignore items to lower lag - if (obj:is_player() or (ent and ent.name ~= '__builtin.item')) and obj:get_hp() > 0 then + if (obj:is_player() or (ent and ent.name ~= "__builtin.item")) and obj:get_hp() > 0 then local opos = obj:get_pos() local collisionbox = nil @@ -356,9 +361,9 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc local on_blast = node_on_blast[data[idx]] local remove = true - if do_drop or on_blast ~= nil then + if do_drop or on_blast then local npos = get_position_from_hash(hash) - if on_blast ~= nil then + if on_blast then on_blast(npos, 1.0, do_drop) remove = false else @@ -400,8 +405,7 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc end -- Log explosion - minetest.log('action', 'Explosion at ' .. minetest.pos_to_string(pos) .. - ' with strength ' .. strength .. ' and radius ' .. radius) + minetest.log("action", "Explosion at "..pos_to_string(pos).." with strength "..strength.." and radius "..radius) end -- Create an explosion with strength at pos. diff --git a/mods/CORE/mcl_worlds/init.lua b/mods/CORE/mcl_worlds/init.lua index ec8144794..203f69401 100644 --- a/mods/CORE/mcl_worlds/init.lua +++ b/mods/CORE/mcl_worlds/init.lua @@ -1,5 +1,7 @@ mcl_worlds = {} +local get_connected_players = minetest.get_connected_players + -- For a given position, returns a 2-tuple: -- 1st return value: true if pos is in void -- 2nd return value: true if it is in the deadly part of the void @@ -44,12 +46,16 @@ function mcl_worlds.y_to_layer(y) end end +local y_to_layer = mcl_worlds.y_to_layer + -- Takes a pos and returns the dimension it belongs to (same as above) function mcl_worlds.pos_to_dimension(pos) - local _, dim = mcl_worlds.y_to_layer(pos.y) + local _, dim = y_to_layer(pos.y) return dim end +local pos_to_dimension = mcl_worlds.pos_to_dimension + -- Takes a Minecraft layer and a “dimension” name -- and returns the corresponding Y coordinate for -- MineClone 2. @@ -119,6 +125,8 @@ function mcl_worlds.dimension_change(player, dimension) last_dimension[playername] = dimension end +local dimension_change = mcl_worlds.dimension_change + ----------------------- INTERNAL STUFF ---------------------- -- Update the dimension callbacks every DIM_UPDATE seconds @@ -126,19 +134,19 @@ local DIM_UPDATE = 1 local dimtimer = 0 minetest.register_on_joinplayer(function(player) - last_dimension[player:get_player_name()] = mcl_worlds.pos_to_dimension(player:get_pos()) + last_dimension[player:get_player_name()] = pos_to_dimension(player:get_pos()) end) minetest.register_globalstep(function(dtime) -- regular updates based on iterval dimtimer = dimtimer + dtime; if dimtimer >= DIM_UPDATE then - local players = minetest.get_connected_players() - for p=1, #players do - local dim = mcl_worlds.pos_to_dimension(players[p]:get_pos()) + local players = get_connected_players() + for p = 1, #players do + local dim = pos_to_dimension(players[p]:get_pos()) local name = players[p]:get_player_name() if dim ~= last_dimension[name] then - mcl_worlds.dimension_change(players[p], dim) + dimension_change(players[p], dim) end end dimtimer = 0 diff --git a/mods/CORE/walkover/init.lua b/mods/CORE/walkover/init.lua index 6260b43e0..4d712c308 100644 --- a/mods/CORE/walkover/init.lua +++ b/mods/CORE/walkover/init.lua @@ -4,6 +4,7 @@ local get_connected_players = minetest.get_connected_players local get_node = minetest.get_node local vector_add = vector.add local ceil = math.ceil +local pairs = pairs walkover = {} walkover.registered_globals = {} @@ -34,9 +35,9 @@ minetest.register_globalstep(function(dtime) local pp = player:get_pos() pp.y = ceil(pp.y) local loc = vector_add(pp, {x=0,y=-1,z=0}) - if loc ~= nil then + if loc then local nodeiamon = get_node(loc) - if nodeiamon ~= nil then + if nodeiamon then if on_walk[nodeiamon.name] then on_walk[nodeiamon.name](loc, nodeiamon, player) end diff --git a/mods/ENTITIES/mcl_boats/init.lua b/mods/ENTITIES/mcl_boats/init.lua index 8c187617c..76ace7a45 100644 --- a/mods/ENTITIES/mcl_boats/init.lua +++ b/mods/ENTITIES/mcl_boats/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_boats") +local S = minetest.get_translator(minetest.get_current_modname()) local boat_visual_size = {x = 1, y = 1, z = 1} local paddling_speed = 22 @@ -470,6 +470,6 @@ minetest.register_craft({ burntime = 20, }) -if minetest.get_modpath("doc_identifier") ~= nil then +if minetest.get_modpath("doc_identifier") then doc.sub.identifier.register_object("mcl_boats:boat", "craftitems", "mcl_boats:boat") end diff --git a/mods/ENTITIES/mcl_burning/init.lua b/mods/ENTITIES/mcl_burning/init.lua index 5cf0d85fe..34b7ca2d4 100644 --- a/mods/ENTITIES/mcl_burning/init.lua +++ b/mods/ENTITIES/mcl_burning/init.lua @@ -1,5 +1,10 @@ local modpath = minetest.get_modpath(minetest.get_current_modname()) +local pairs = pairs + +local get_connected_players = minetest.get_connected_players +local get_item_group = minetest.get_item_group + mcl_burning = { storage = {}, animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8 @@ -8,7 +13,7 @@ mcl_burning = { dofile(modpath .. "/api.lua") minetest.register_globalstep(function(dtime) - for _, player in pairs(minetest.get_connected_players()) do + for _, player in pairs(get_connected_players()) do local storage = mcl_burning.storage[player] if not mcl_burning.tick(player, dtime, storage) and not mcl_burning.is_affected_by_rain(player) then local nodes = mcl_burning.get_touching_nodes(player, {"group:puts_out_fire", "group:set_on_fire"}, storage) @@ -16,12 +21,12 @@ minetest.register_globalstep(function(dtime) for _, pos in pairs(nodes) do local node = minetest.get_node(pos) - if minetest.get_item_group(node.name, "puts_out_fire") > 0 then + if get_item_group(node.name, "puts_out_fire") > 0 then burn_time = 0 break end - local value = minetest.get_item_group(node.name, "set_on_fire") + local value = get_item_group(node.name, "set_on_fire") if value > burn_time then burn_time = value end diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 7886664f8..ab1ac5752 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -1,5 +1,5 @@ --these are lua locals, used for higher performance -local minetest, math, vector, ipairs = minetest, math, vector, ipairs +local minetest, math, vector, ipairs, pairs = minetest, math, vector, ipairs, pairs --this is used for the player pool in the sound buffer local pool = {} @@ -233,7 +233,7 @@ function minetest.handle_node_drops(pos, drops, digger) local dug_node = minetest.get_node(pos) local tooldef local tool - if digger ~= nil then + if digger then tool = digger:get_wielded_item() tooldef = minetest.registered_tools[tool:get_name()] @@ -314,7 +314,7 @@ function minetest.handle_node_drops(pos, drops, digger) end -- Spawn item and apply random speed local obj = minetest.add_item(dpos, drop_item) - if obj ~= nil then + if obj then local x = math.random(1, 5) if math.random(1,2) == 1 then x = -x @@ -394,7 +394,7 @@ minetest.register_entity(":__builtin:item", { -- The itemstring MUST be set immediately to a non-empty string after creating the entity. -- The hand is NOT permitted as dropped item. ;-) -- Item entities will be deleted if they still have an empty itemstring on their first on_step tick. - itemstring = '', + itemstring = "", -- If true, item will fall physical_state = true, @@ -585,7 +585,7 @@ minetest.register_entity(":__builtin:item", { return end self.age = self.age + dtime - if self._collector_timer ~= nil then + if self._collector_timer then self._collector_timer = self._collector_timer + dtime end if time_to_live > 0 and self.age > time_to_live then diff --git a/mods/ENTITIES/mcl_minecarts/init.lua b/mods/ENTITIES/mcl_minecarts/init.lua index 6fd98f550..e33e120a1 100644 --- a/mods/ENTITIES/mcl_minecarts/init.lua +++ b/mods/ENTITIES/mcl_minecarts/init.lua @@ -1,9 +1,10 @@ -local S = minetest.get_translator("mcl_minecarts") +local modname = minetest.get_current_modname() +local S = minetest.get_translator(modname) local has_mcl_wip = minetest.get_modpath("mcl_wip") mcl_minecarts = {} -mcl_minecarts.modpath = minetest.get_modpath("mcl_minecarts") +mcl_minecarts.modpath = minetest.get_modpath(modname) mcl_minecarts.speed_max = 10 mcl_minecarts.check_float_time = 15 @@ -204,7 +205,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o rou_pos = vector.round(pos) node = minetest.get_node(rou_pos) local g = minetest.get_item_group(node.name, "connect_to_raillike") - if g ~= self._railtype and self._railtype ~= nil then + if g ~= self._railtype and self._railtype then -- Detach driver if player then if self._old_pos then @@ -523,7 +524,7 @@ function mcl_minecarts.place_minecart(itemstack, pointed_thing, placer) local cart = minetest.add_entity(railpos, entity_id) local railtype = minetest.get_item_group(node.name, "connect_to_raillike") local le = cart:get_luaentity() - if le ~= nil then + if le then le._railtype = railtype end local cart_dir = mcl_minecarts:get_rail_direction(railpos, {x=1, y=0, z=0}, nil, nil, railtype) @@ -606,7 +607,7 @@ Register a minecart local function register_minecart(itemstring, entity_id, description, tt_help, longdesc, usagehelp, mesh, textures, icon, drop, on_rightclick, on_activate_by_rail, creative) register_entity(entity_id, mesh, textures, drop, on_rightclick, on_activate_by_rail) register_craftitem(itemstring, entity_id, description, tt_help, longdesc, usagehelp, icon, creative) - if minetest.get_modpath("doc_identifier") ~= nil then + if minetest.get_modpath("doc_identifier") then doc.sub.identifier.register_object(entity_id, "craftitems", itemstring) end end diff --git a/mods/ENTITIES/mcl_minecarts/rails.lua b/mods/ENTITIES/mcl_minecarts/rails.lua index 53ec86d94..91282f253 100644 --- a/mods/ENTITIES/mcl_minecarts/rails.lua +++ b/mods/ENTITIES/mcl_minecarts/rails.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_minecarts") +local S = minetest.get_translator(minetest.get_current_modname()) -- Template rail function local function register_rail(itemstring, tiles, def_extras, creative) @@ -206,11 +206,11 @@ register_rail("mcl_minecarts:detector_rail_on", -- Crafting minetest.register_craft({ - output = 'mcl_minecarts:rail 16', + output = "mcl_minecarts:rail 16", recipe = { - {'mcl_core:iron_ingot', '', 'mcl_core:iron_ingot'}, - {'mcl_core:iron_ingot', 'mcl_core:stick', 'mcl_core:iron_ingot'}, - {'mcl_core:iron_ingot', '', 'mcl_core:iron_ingot'}, + {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "mcl_core:stick", "mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"}, } }) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index 41b522fef..d1840f671 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -96,7 +96,7 @@ local mod_mobspawners = minetest_get_modpath("mcl_mobspawners") --local height_switcher = false -- Get translator -local S = minetest.get_translator("mcl_mobs") +local S = minetest.get_translator(minetest.get_current_modname()) -- CMI support check --local use_cmi = minetest.global_exists("cmi") @@ -429,7 +429,7 @@ function mobs:register_mob(name, def) --harmed_by_heal = def.harmed_by_heal, }) - if minetest_get_modpath("doc_identifier") ~= nil then + if minetest_get_modpath("doc_identifier") then doc.sub.identifier.register_object(name, "basics", "mobs") end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index 894a1f5e4..d16d24929 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -990,7 +990,7 @@ function mobs.mob_step(self, dtime) if self.memory <= 0 then --reset states when coming out of hostile state - if self.attacking ~= nil then + if self.attacking then self.state_timer = -1 end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua index f5d33def4..ac10194e5 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua @@ -41,7 +41,7 @@ mobs.explode_attack_walk = function(self,dtime) --make mob walk up to player within 2 nodes distance then start exploding if distance_from_attacking >= self.reach and --don't allow explosion to cancel unless out of the reach boundary - not (self.explosion_animation ~= nil and self.explosion_animation > 0 and distance_from_attacking <= self.defuse_reach) then + not (self.explosion_animation and self.explosion_animation > 0 and distance_from_attacking <= self.defuse_reach) then mobs.set_velocity(self, self.run_velocity) mobs.set_mob_animation(self,"run") @@ -85,9 +85,8 @@ end --this is a small helper function to make working with explosion animations easier mobs.reverse_explosion_animation = function(self,dtime) - --if explosion animation was greater than 0 then reverse it - if self.explosion_animation ~= nil and self.explosion_animation > 0 then + if self.explosion_animation and self.explosion_animation > 0 then self.explosion_animation = self.explosion_animation - dtime if self.explosion_animation < 0 then self.explosion_animation = 0 diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/projectile_handling.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/projectile_handling.lua index e7ae6ffbe..a4b4c075e 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/projectile_handling.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/projectile_handling.lua @@ -36,9 +36,8 @@ mobs.shoot_projectile_handling = function(arrow_item, pos, dir, yaw, shooter, po le._collectable = collectable --play custom shoot sound - if shooter ~= nil and shooter.shoot_sound then + if shooter and shooter.shoot_sound then minetest.sound_play(shooter.shoot_sound, {pos=pos, max_hear_distance=16}, true) end - return obj end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/spawning.lua b/mods/ENTITIES/mcl_mobs/api/spawning.lua index 70167b421..bf07ca94d 100644 --- a/mods/ENTITIES/mcl_mobs/api/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/api/spawning.lua @@ -5,6 +5,7 @@ local get_node_light = minetest.get_node_light local find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air local get_biome_name = minetest.get_biome_name local get_objects_inside_radius = minetest.get_objects_inside_radius +local get_connected_players = minetest.get_connected_players local math_random = math.random @@ -18,6 +19,7 @@ local vector_floor = vector.floor local table_copy = table.copy local table_remove = table.remove +local pairs = pairs -- range for mob count local aoc_range = 48 @@ -279,7 +281,7 @@ function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_ligh end -- if toggle set to nil then ignore day/night check - if day_toggle ~= nil then + if day_toggle then local tod = (minetest.get_timeofday() or 0) * 24000 @@ -369,7 +371,7 @@ function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_ligh if minetest.registered_nodes[node_ok(pos2).name].walkable == true then -- inside block minetest.log("info", "Mob spawn of "..name.." at "..minetest.pos_to_string(pos).." failed, too little space!") - if ent.spawn_small_alternative ~= nil and (not minetest.registered_nodes[node_ok(pos).name].walkable) then + if ent.spawn_small_alternative and (not minetest.registered_nodes[node_ok(pos).name].walkable) then minetest.log("info", "Trying to spawn smaller alternative mob: "..ent.spawn_small_alternative) spawn_action(orig_pos, node, active_object_count, active_object_count_wider, ent.spawn_small_alternative) end @@ -540,7 +542,7 @@ if mobs_spawn then timer = timer + dtime if timer >= 10 then timer = 0 - for _,player in pairs(minetest.get_connected_players()) do + for _,player in pairs(get_connected_players()) do -- after this line each "break" means "continue" local do_mob_spawning = true repeat @@ -548,15 +550,15 @@ if mobs_spawn then --they happen in a single server step local player_pos = player:get_pos() - local _,dimension = mcl_worlds.y_to_layer(player_pos.y) + local dimension = mcl_worlds.pos_to_dimension(player_pos) if dimension == "void" or dimension == "default" then break -- ignore void and unloaded area end - local min,max = decypher_limits(player_pos.y) + local min, max = decypher_limits(player_pos.y) - for i = 1,math_random(1,4) do + for i = 1, math_random(1,4) do -- after this line each "break" means "continue" local do_mob_algorithm = true repeat diff --git a/mods/ENTITIES/mcl_mobs/crafts.lua b/mods/ENTITIES/mcl_mobs/crafts.lua index e8a5b60fc..2b23c6f58 100644 --- a/mods/ENTITIES/mcl_mobs/crafts.lua +++ b/mods/ENTITIES/mcl_mobs/crafts.lua @@ -1,5 +1,5 @@ -local S = minetest.get_translator("mcl_mobs") +local S = minetest.get_translator(minetest.get_current_modname()) -- name tag minetest.register_craftitem("mcl_mobs:nametag", { diff --git a/mods/ENTITIES/mcl_paintings/init.lua b/mods/ENTITIES/mcl_paintings/init.lua index be210c74c..26bd2c61b 100644 --- a/mods/ENTITIES/mcl_paintings/init.lua +++ b/mods/ENTITIES/mcl_paintings/init.lua @@ -1,8 +1,9 @@ mcl_paintings = {} -dofile(minetest.get_modpath(minetest.get_current_modname()).."/paintings.lua") +local modname = minetest.get_current_modname() +dofile(minetest.get_modpath(modname).."/paintings.lua") -local S = minetest.get_translator("mcl_paintings") +local S = minetest.get_translator(modname) local math = math diff --git a/mods/ENTITIES/mobs_mc/1_items_default.lua b/mods/ENTITIES/mobs_mc/1_items_default.lua index bdadbfdc5..c8ac421cc 100644 --- a/mods/ENTITIES/mobs_mc/1_items_default.lua +++ b/mods/ENTITIES/mobs_mc/1_items_default.lua @@ -8,7 +8,7 @@ -- NOTE: Most strings intentionally not marked for translation, other mods already have these items. -- TODO: Remove this file eventually, most items are already outsourced in other mods. -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) local c = mobs_mc.is_item_variable_overridden @@ -234,8 +234,8 @@ end if c("ender_eye") and c("blaze_powder") and c("blaze_rod") then minetest.register_craft({ type = "shapeless", - output = 'mobs_mc:ender_eye', - recipe = { 'mobs_mc:blaze_powder', 'mobs_mc:blaze_rod'}, + output = "mobs_mc:ender_eye", + recipe = { "mobs_mc:blaze_powder", "mobs_mc:blaze_rod"}, }) end diff --git a/mods/ENTITIES/mobs_mc/2_throwing.lua b/mods/ENTITIES/mobs_mc/2_throwing.lua index 6f01ae6e6..d97351ac0 100644 --- a/mods/ENTITIES/mobs_mc/2_throwing.lua +++ b/mods/ENTITIES/mobs_mc/2_throwing.lua @@ -6,7 +6,7 @@ -- NOTE: Strings intentionally not marked for translation, other mods already have these items. -- TODO: Remove this file eventually, all items here are already outsourced in other mods. ---local S = minetest.get_translator("mobs_mc") +--local S = minetest.get_translator(minetest.get_current_modname()) --maikerumines throwing code --arrow (weapon) @@ -83,7 +83,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) if self.timer>0.2 then local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1.5) for k, obj in pairs(objs) do - if obj:get_luaentity() ~= nil then + if obj:get_luaentity() then if obj:get_luaentity().name ~= "mobs_mc:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then local damage = 3 minetest.sound_play("damage", {pos = pos}, true) @@ -108,7 +108,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) if self.lastpos.x~=nil then if node.name ~= "air" then minetest.sound_play("bowhit1", {pos = pos}, true) - minetest.add_item(self.lastpos, 'mobs_mc:arrow') + minetest.add_item(self.lastpos, "mobs_mc:arrow") self.object:remove() end end @@ -155,7 +155,7 @@ end if c("arrow") and c("flint") and c("feather") and c("stick") then minetest.register_craft({ - output = 'mobs_mc:arrow 4', + output = "mobs_mc:arrow 4", recipe = { {mobs_mc.items.flint}, {mobs_mc.items.stick}, @@ -181,11 +181,11 @@ if c("bow") then }) minetest.register_craft({ - output = 'mobs_mc:bow_wood', + output = "mobs_mc:bow_wood", recipe = { - {mobs_mc.items.string, mobs_mc.items.stick, ''}, - {mobs_mc.items.string, '', mobs_mc.items.stick}, - {mobs_mc.items.string, mobs_mc.items.stick, ''}, + {mobs_mc.items.string, mobs_mc.items.stick, ""}, + {mobs_mc.items.string, "", mobs_mc.items.stick}, + {mobs_mc.items.string, mobs_mc.items.stick, ""}, } }) end @@ -259,7 +259,7 @@ if c("egg") then }) -- shoot egg - local mobs_shoot_egg = function (item, player, pointed_thing) + local function mobs_shoot_egg(item, player, pointed_thing) local playerpos = player:get_pos() @@ -349,7 +349,7 @@ mobs:register_arrow("mobs_mc:snowball_entity", { if c("snowball") then -- shoot snowball - local mobs_shoot_snowball = function (item, player, pointed_thing) + local function mobs_shoot_snowball(item, player, pointed_thing) local playerpos = player:get_pos() diff --git a/mods/ENTITIES/mobs_mc/4_heads.lua b/mods/ENTITIES/mobs_mc/4_heads.lua index 2ba0d548b..ecd09ee02 100644 --- a/mods/ENTITIES/mobs_mc/4_heads.lua +++ b/mods/ENTITIES/mobs_mc/4_heads.lua @@ -5,7 +5,7 @@ -- TODO: Remove this file eventually, all items here are already outsourced in other mods. -- TODO: Add translation. ---local S = minetest.get_translator("mobs_mc") +--local S = local S = minetest.get_translator(minetest.get_current_modname()) -- Heads system diff --git a/mods/ENTITIES/mobs_mc/agent.lua b/mods/ENTITIES/mobs_mc/agent.lua index cc9910ee6..8475f92fc 100644 --- a/mods/ENTITIES/mobs_mc/agent.lua +++ b/mods/ENTITIES/mobs_mc/agent.lua @@ -2,7 +2,7 @@ --################### AGENT - seemingly unused --################### -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:agent", { type = "npc", diff --git a/mods/ENTITIES/mobs_mc/bat.lua b/mods/ENTITIES/mobs_mc/bat.lua index 70e084ee2..5492add74 100644 --- a/mods/ENTITIES/mobs_mc/bat.lua +++ b/mods/ENTITIES/mobs_mc/bat.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:bat", { description = S("Bat"), diff --git a/mods/ENTITIES/mobs_mc/blaze.lua b/mods/ENTITIES/mobs_mc/blaze.lua index a5e6f2bd3..0f62c5388 100644 --- a/mods/ENTITIES/mobs_mc/blaze.lua +++ b/mods/ENTITIES/mobs_mc/blaze.lua @@ -3,7 +3,7 @@ -- Model and mobs_blaze.png see https://github.com/22i/minecraft-voxel-blender-models -hi 22i ~jordan4ibanez -- blaze.lua partial copy of mobs_mc/ghast.lua -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### BLAZE diff --git a/mods/ENTITIES/mobs_mc/chicken.lua b/mods/ENTITIES/mobs_mc/chicken.lua index 9146a012f..ffaebca2b 100644 --- a/mods/ENTITIES/mobs_mc/chicken.lua +++ b/mods/ENTITIES/mobs_mc/chicken.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### CHICKEN diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index 6100e5899..17c4e1e62 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) local cow_def = { description = S("Cow"), diff --git a/mods/ENTITIES/mobs_mc/creeper.lua b/mods/ENTITIES/mobs_mc/creeper.lua index 4d0539996..999cc5f2d 100644 --- a/mods/ENTITIES/mobs_mc/creeper.lua +++ b/mods/ENTITIES/mobs_mc/creeper.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### CREEPER @@ -72,7 +72,7 @@ mobs:register_mob("mobs_mc:creeper", { -- TODO: Make creeper flash after doing this as well. -- TODO: Test and debug this code. on_rightclick = function(self, clicker) - if self._forced_explosion_countdown_timer ~= nil then + if self._forced_explosion_countdown_timer then return end local item = clicker:get_wielded_item() @@ -92,7 +92,7 @@ mobs:register_mob("mobs_mc:creeper", { end end, do_custom = function(self, dtime) - if self._forced_explosion_countdown_timer ~= nil then + if self._forced_explosion_countdown_timer then self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime if self._forced_explosion_countdown_timer <= 0 then mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength) @@ -196,7 +196,7 @@ mobs:register_mob("mobs_mc:creeper_charged", { -- TODO: Make creeper flash after doing this as well. -- TODO: Test and debug this code. on_rightclick = function(self, clicker) - if self._forced_explosion_countdown_timer ~= nil then + if self._forced_explosion_countdown_timer then return end local item = clicker:get_wielded_item() @@ -216,7 +216,7 @@ mobs:register_mob("mobs_mc:creeper_charged", { end end, do_custom = function(self, dtime) - if self._forced_explosion_countdown_timer ~= nil then + if self._forced_explosion_countdown_timer then self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime if self._forced_explosion_countdown_timer <= 0 then mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength) diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index d2d040ad2..bafb3f84a 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -2,7 +2,7 @@ --################### ENDERDRAGON --################### -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:enderdragon", { description = S("Ender Dragon"), diff --git a/mods/ENTITIES/mobs_mc/enderman.lua b/mods/ENTITIES/mobs_mc/enderman.lua index 0b6985711..a821bd769 100644 --- a/mods/ENTITIES/mobs_mc/enderman.lua +++ b/mods/ENTITIES/mobs_mc/enderman.lua @@ -24,9 +24,11 @@ -- added rain damage. -- fixed the grass_with_dirt issue. -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) -local telesound = function(pos, is_source) +local vector = vector + +local function telesound(pos, is_source) local snd if is_source then snd = "mobs_mc_enderman_teleport_src" @@ -302,7 +304,7 @@ mobs:register_mob("mobs_mc:enderman", { if self.attacking then local target = self.attacking local pos = target:get_pos() - if pos ~= nil then + if pos then if vector.distance(self.object:get_pos(), target:get_pos()) > 10 then self:teleport(target) end @@ -341,8 +343,8 @@ mobs:register_mob("mobs_mc:enderman", { -- self:teleport(nil) -- self.state = "" --else - if self.attack ~= nil and not minetest.settings:get_bool("creative_mode") then - self.state = 'attack' + if self.attack and not minetest.settings:get_bool("creative_mode") then + self.state = "attack" end --end end @@ -459,7 +461,7 @@ mobs:register_mob("mobs_mc:enderman", { end end end - elseif self._taken_node ~= nil and self._taken_node ~= "" and self._take_place_timer >= self._next_take_place_time then + elseif self._taken_node and self._taken_node ~= "" and self._take_place_timer >= self._next_take_place_time then -- Place taken node self._take_place_timer = 0 self._next_take_place_time = math.random(take_frequency_min, take_frequency_max) @@ -485,12 +487,12 @@ mobs:register_mob("mobs_mc:enderman", { end end, do_teleport = function(self, target) - if target ~= nil then + if target then local target_pos = target:get_pos() -- Find all solid nodes below air in a 10×10×10 cuboid centered on the target local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(target_pos, 5), vector.add(target_pos, 5), {"group:solid", "group:cracky", "group:crumbly"}) local telepos - if nodes ~= nil then + if nodes then if #nodes > 0 then -- Up to 64 attempts to teleport for n=1, math.min(64, #nodes) do @@ -525,7 +527,7 @@ mobs:register_mob("mobs_mc:enderman", { -- We need to add (or subtract) different random numbers to each vector component, so it couldn't be done with a nice single vector.add() or .subtract(): local randomCube = vector.new( pos.x + 8*(pr:next(0,16)-8), pos.y + 8*(pr:next(0,16)-8), pos.z + 8*(pr:next(0,16)-8) ) local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(randomCube, 4), vector.add(randomCube, 4), {"group:solid", "group:cracky", "group:crumbly"}) - if nodes ~= nil then + if nodes then if #nodes > 0 then -- Up to 8 low-level (in total up to 8*8 = 64) attempts to teleport for n=1, math.min(8, #nodes) do @@ -557,13 +559,13 @@ mobs:register_mob("mobs_mc:enderman", { end, on_die = function(self, pos) -- Drop carried node on death - if self._taken_node ~= nil and self._taken_node ~= "" then + if self._taken_node and self._taken_node ~= "" then minetest.add_item(pos, self._taken_node) end end, do_punch = function(self, hitter, tflp, tool_caps, dir) -- damage from rain caused by itself so we don't want it to attack itself. - if hitter ~= self.object and hitter ~= nil then + if hitter ~= self.object and hitter then --if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then -- self:teleport(nil) --else diff --git a/mods/ENTITIES/mobs_mc/endermite.lua b/mods/ENTITIES/mobs_mc/endermite.lua index 712086828..29a887c06 100644 --- a/mods/ENTITIES/mobs_mc/endermite.lua +++ b/mods/ENTITIES/mobs_mc/endermite.lua @@ -2,7 +2,7 @@ --################### ENDERMITE --################### -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:endermite", { description = S("Endermite"), diff --git a/mods/ENTITIES/mobs_mc/ghast.lua b/mods/ENTITIES/mobs_mc/ghast.lua index 609110bdb..dc47411fd 100644 --- a/mods/ENTITIES/mobs_mc/ghast.lua +++ b/mods/ENTITIES/mobs_mc/ghast.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### GHAST diff --git a/mods/ENTITIES/mobs_mc/guardian.lua b/mods/ENTITIES/mobs_mc/guardian.lua index 0916010d2..3e1a4f853 100644 --- a/mods/ENTITIES/mobs_mc/guardian.lua +++ b/mods/ENTITIES/mobs_mc/guardian.lua @@ -2,7 +2,7 @@ --################### GUARDIAN --################### -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:guardian", { description = S("Guardian"), diff --git a/mods/ENTITIES/mobs_mc/guardian_elder.lua b/mods/ENTITIES/mobs_mc/guardian_elder.lua index 0c871da7a..2bb0e984a 100644 --- a/mods/ENTITIES/mobs_mc/guardian_elder.lua +++ b/mods/ENTITIES/mobs_mc/guardian_elder.lua @@ -4,7 +4,7 @@ --################### GUARDIAN --################### -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:guardian_elder", { description = S("Elder Guardian"), diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index db23d410b..4b33515d5 100644 --- a/mods/ENTITIES/mobs_mc/horse.lua +++ b/mods/ENTITIES/mobs_mc/horse.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### HORSE diff --git a/mods/ENTITIES/mobs_mc/init.lua b/mods/ENTITIES/mobs_mc/init.lua index 58006fe90..d7600e927 100644 --- a/mods/ENTITIES/mobs_mc/init.lua +++ b/mods/ENTITIES/mobs_mc/init.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local path = minetest.get_modpath("mobs_mc") +local path = minetest.get_modpath(minetest.get_current_modname()) if not minetest.get_modpath("mobs_mc_gameconfig") then mobs_mc = {} diff --git a/mods/ENTITIES/mobs_mc/iron_golem.lua b/mods/ENTITIES/mobs_mc/iron_golem.lua index d68dc157b..946db312d 100644 --- a/mods/ENTITIES/mobs_mc/iron_golem.lua +++ b/mods/ENTITIES/mobs_mc/iron_golem.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### IRON GOLEM diff --git a/mods/ENTITIES/mobs_mc/llama.lua b/mods/ENTITIES/mobs_mc/llama.lua index 9803b582b..9c3f681b1 100644 --- a/mods/ENTITIES/mobs_mc/llama.lua +++ b/mods/ENTITIES/mobs_mc/llama.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### LLAMA diff --git a/mods/ENTITIES/mobs_mc/ocelot.lua b/mods/ENTITIES/mobs_mc/ocelot.lua index 933d7aad4..aea543895 100644 --- a/mods/ENTITIES/mobs_mc/ocelot.lua +++ b/mods/ENTITIES/mobs_mc/ocelot.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### OCELOT AND CAT diff --git a/mods/ENTITIES/mobs_mc/parrot.lua b/mods/ENTITIES/mobs_mc/parrot.lua index 88ab54ff5..affcac496 100644 --- a/mods/ENTITIES/mobs_mc/parrot.lua +++ b/mods/ENTITIES/mobs_mc/parrot.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### PARROT diff --git a/mods/ENTITIES/mobs_mc/pig.lua b/mods/ENTITIES/mobs_mc/pig.lua index 14c9595b6..84ff996f2 100644 --- a/mods/ENTITIES/mobs_mc/pig.lua +++ b/mods/ENTITIES/mobs_mc/pig.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:pig", { description = S("Pig"), diff --git a/mods/ENTITIES/mobs_mc/polar_bear.lua b/mods/ENTITIES/mobs_mc/polar_bear.lua index 0476229b5..0f5296d35 100644 --- a/mods/ENTITIES/mobs_mc/polar_bear.lua +++ b/mods/ENTITIES/mobs_mc/polar_bear.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### POLARBEAR diff --git a/mods/ENTITIES/mobs_mc/rabbit.lua b/mods/ENTITIES/mobs_mc/rabbit.lua index 3214925ac..8c2675954 100644 --- a/mods/ENTITIES/mobs_mc/rabbit.lua +++ b/mods/ENTITIES/mobs_mc/rabbit.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) local rabbit = { description = S("Rabbit"), diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index 7e01a1403..76f933a6b 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### SHEEP @@ -38,7 +38,7 @@ local rainbow_colors = { "unicolor_red_violet" } -if minetest.get_modpath("mcl_wool") ~= nil then +if minetest.get_modpath("mcl_wool") then colors["unicolor_light_blue"] = { mobs_mc.items.wool_light_blue, "#5050FFD0" } end diff --git a/mods/ENTITIES/mobs_mc/shulker.lua b/mods/ENTITIES/mobs_mc/shulker.lua index 9932c5add..1a5c4ec84 100644 --- a/mods/ENTITIES/mobs_mc/shulker.lua +++ b/mods/ENTITIES/mobs_mc/shulker.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### SHULKER diff --git a/mods/ENTITIES/mobs_mc/silverfish.lua b/mods/ENTITIES/mobs_mc/silverfish.lua index 05485bc51..ac3991ad1 100644 --- a/mods/ENTITIES/mobs_mc/silverfish.lua +++ b/mods/ENTITIES/mobs_mc/silverfish.lua @@ -2,7 +2,7 @@ --################### SILVERFISH --################### -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:silverfish", { description = S("Silverfish"), @@ -61,7 +61,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then description = "Stone Monster Egg", tiles = {"default_stone.png"}, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, - drop = '', + drop = "", is_ground_content = true, sounds = default.node_sound_stone_defaults(), after_dig_node = spawn_silverfish, @@ -72,7 +72,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then tiles = {"default_cobble.png"}, is_ground_content = false, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, - drop = '', + drop = "", sounds = default.node_sound_stone_defaults(), after_dig_node = spawn_silverfish, }) @@ -82,7 +82,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then tiles = {"default_mossycobble.png"}, is_ground_content = false, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, - drop = '', + drop = "", sounds = default.node_sound_stone_defaults(), after_dig_node = spawn_silverfish, }) @@ -94,7 +94,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then tiles = {"default_stone_brick.png"}, is_ground_content = false, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, - drop = '', + drop = "", sounds = default.node_sound_stone_defaults(), after_dig_node = spawn_silverfish, }) @@ -104,7 +104,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then tiles = {"default_stone_block.png"}, is_ground_content = false, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, - drop = '', + drop = "", sounds = default.node_sound_stone_defaults(), after_dig_node = spawn_silverfish, }) diff --git a/mods/ENTITIES/mobs_mc/skeleton+stray.lua b/mods/ENTITIES/mobs_mc/skeleton+stray.lua index e0aaef215..f0e728e08 100644 --- a/mods/ENTITIES/mobs_mc/skeleton+stray.lua +++ b/mods/ENTITIES/mobs_mc/skeleton+stray.lua @@ -3,8 +3,8 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") -local mod_bows = minetest.get_modpath("mcl_bows") ~= nil +local S = minetest.get_translator(minetest.get_current_modname()) +local mod_bows = minetest.get_modpath("mcl_bows") --################### --################### SKELETON diff --git a/mods/ENTITIES/mobs_mc/skeleton_wither.lua b/mods/ENTITIES/mobs_mc/skeleton_wither.lua index 279a1d8cb..a6b48d428 100644 --- a/mods/ENTITIES/mobs_mc/skeleton_wither.lua +++ b/mods/ENTITIES/mobs_mc/skeleton_wither.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### WITHER SKELETON diff --git a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua index 0cae6757d..48aacfcce 100644 --- a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua +++ b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) -- Returns a function that spawns children in a circle around pos. -- To be used as on_die callback. @@ -41,10 +41,10 @@ local spawn_children_on_die = function(child_mob, children_count, spawn_distance -- If mother was murdered, children attack the killer after 1 second if self.state == "attack" then minetest.after(1.0, function(children, enemy) - for c=1, #children do + for c = 1, #children do local child = children[c] local le = child:get_luaentity() - if le ~= nil then + if le then le.state = "attack" le.attack = enemy end diff --git a/mods/ENTITIES/mobs_mc/snowman.lua b/mods/ENTITIES/mobs_mc/snowman.lua index 93f91c330..9e2fae4d4 100644 --- a/mods/ENTITIES/mobs_mc/snowman.lua +++ b/mods/ENTITIES/mobs_mc/snowman.lua @@ -3,12 +3,12 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) local snow_trail_frequency = 0.5 -- Time in seconds for checking to add a new snow trail local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false -local mod_throwing = minetest.get_modpath("mcl_throwing") ~= nil +local mod_throwing = minetest.get_modpath("mcl_throwing") local gotten_texture = { "mobs_mc_snowman.png", diff --git a/mods/ENTITIES/mobs_mc/spider.lua b/mods/ENTITIES/mobs_mc/spider.lua index 6ade915ab..e1be9c3ed 100644 --- a/mods/ENTITIES/mobs_mc/spider.lua +++ b/mods/ENTITIES/mobs_mc/spider.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### SPIDER diff --git a/mods/ENTITIES/mobs_mc/squid.lua b/mods/ENTITIES/mobs_mc/squid.lua index 55d4b05c3..ccd73296a 100644 --- a/mods/ENTITIES/mobs_mc/squid.lua +++ b/mods/ENTITIES/mobs_mc/squid.lua @@ -4,7 +4,7 @@ --################### SQUID --################### -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) mobs:register_mob("mobs_mc:squid", { description = S("Squid"), diff --git a/mods/ENTITIES/mobs_mc/vex.lua b/mods/ENTITIES/mobs_mc/vex.lua index da162e5bf..22f1e70d2 100644 --- a/mods/ENTITIES/mobs_mc/vex.lua +++ b/mods/ENTITIES/mobs_mc/vex.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### VEX diff --git a/mods/ENTITIES/mobs_mc/villager.lua b/mods/ENTITIES/mobs_mc/villager.lua index 4e4b40553..06cec9ed6 100644 --- a/mods/ENTITIES/mobs_mc/villager.lua +++ b/mods/ENTITIES/mobs_mc/villager.lua @@ -19,7 +19,7 @@ -- TODO: Internal inventory, pick up items, trade with other villagers -- TODO: Farm stuff -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) local N = function(s) return s end local F = minetest.formspec_escape diff --git a/mods/ENTITIES/mobs_mc/villager_evoker.lua b/mods/ENTITIES/mobs_mc/villager_evoker.lua index f87483e2b..030da5470 100644 --- a/mods/ENTITIES/mobs_mc/villager_evoker.lua +++ b/mods/ENTITIES/mobs_mc/villager_evoker.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### EVOKER diff --git a/mods/ENTITIES/mobs_mc/villager_illusioner.lua b/mods/ENTITIES/mobs_mc/villager_illusioner.lua index 46b8760a1..bec5762e5 100644 --- a/mods/ENTITIES/mobs_mc/villager_illusioner.lua +++ b/mods/ENTITIES/mobs_mc/villager_illusioner.lua @@ -3,8 +3,8 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") -local mod_bows = minetest.get_modpath("mcl_bows") ~= nil +local S = minetest.get_translator(minetest.get_current_modname()) +local mod_bows = minetest.get_modpath("mcl_bows") mobs:register_mob("mobs_mc:illusioner", { description = S("Illusioner"), diff --git a/mods/ENTITIES/mobs_mc/villager_vindicator.lua b/mods/ENTITIES/mobs_mc/villager_vindicator.lua index 7df54ef58..6a6999b96 100644 --- a/mods/ENTITIES/mobs_mc/villager_vindicator.lua +++ b/mods/ENTITIES/mobs_mc/villager_vindicator.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### VINDICATOR diff --git a/mods/ENTITIES/mobs_mc/villager_zombie.lua b/mods/ENTITIES/mobs_mc/villager_zombie.lua index 450710c49..088839b65 100644 --- a/mods/ENTITIES/mobs_mc/villager_zombie.lua +++ b/mods/ENTITIES/mobs_mc/villager_zombie.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### ZOMBIE VILLAGER diff --git a/mods/ENTITIES/mobs_mc/witch.lua b/mods/ENTITIES/mobs_mc/witch.lua index 0c72d0018..34492a1b7 100644 --- a/mods/ENTITIES/mobs_mc/witch.lua +++ b/mods/ENTITIES/mobs_mc/witch.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### WITCH diff --git a/mods/ENTITIES/mobs_mc/wither.lua b/mods/ENTITIES/mobs_mc/wither.lua index 8bd8f5341..22e095d98 100644 --- a/mods/ENTITIES/mobs_mc/wither.lua +++ b/mods/ENTITIES/mobs_mc/wither.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### WITHER diff --git a/mods/ENTITIES/mobs_mc/wolf.lua b/mods/ENTITIES/mobs_mc/wolf.lua index 2ce142c33..0b685d40f 100644 --- a/mods/ENTITIES/mobs_mc/wolf.lua +++ b/mods/ENTITIES/mobs_mc/wolf.lua @@ -1,6 +1,6 @@ --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) local default_walk_chance = 50 diff --git a/mods/ENTITIES/mobs_mc/zombie.lua b/mods/ENTITIES/mobs_mc/zombie.lua index 7d0fb1491..e1247d8bd 100644 --- a/mods/ENTITIES/mobs_mc/zombie.lua +++ b/mods/ENTITIES/mobs_mc/zombie.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### ZOMBIE diff --git a/mods/ENTITIES/mobs_mc/zombiepig.lua b/mods/ENTITIES/mobs_mc/zombiepig.lua index 72a19f413..b4088deef 100644 --- a/mods/ENTITIES/mobs_mc/zombiepig.lua +++ b/mods/ENTITIES/mobs_mc/zombiepig.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator(minetest.get_current_modname()) --################### --################### ZOMBIE PIGMAN diff --git a/mods/ENVIRONMENT/mcl_void_damage/init.lua b/mods/ENVIRONMENT/mcl_void_damage/init.lua index c3819c1da..084028dd1 100644 --- a/mods/ENVIRONMENT/mcl_void_damage/init.lua +++ b/mods/ENVIRONMENT/mcl_void_damage/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_void_damage") +local S = minetest.get_translator(minetest.get_current_modname()) --local enable_damage = minetest.settings:get_bool("enable_damage") local pos_to_dim = mcl_worlds.pos_to_dimension diff --git a/mods/ENVIRONMENT/mcl_weather/init.lua b/mods/ENVIRONMENT/mcl_weather/init.lua index e4ebfb2dc..e13242996 100644 --- a/mods/ENVIRONMENT/mcl_weather/init.lua +++ b/mods/ENVIRONMENT/mcl_weather/init.lua @@ -1,4 +1,4 @@ -local modpath = minetest.get_modpath("mcl_weather") +local modpath = minetest.get_modpath(minetest.get_current_modname()) mcl_weather = {} @@ -12,6 +12,6 @@ dofile(modpath.."/snow.lua") dofile(modpath.."/rain.lua") dofile(modpath.."/nether_dust.lua") -if minetest.get_modpath("lightning") ~= nil then +if minetest.get_modpath("lightning") then dofile(modpath.."/thunder.lua") end diff --git a/mods/ENVIRONMENT/mcl_weather/rain.lua b/mods/ENVIRONMENT/mcl_weather/rain.lua index c128da942..220b61006 100644 --- a/mods/ENVIRONMENT/mcl_weather/rain.lua +++ b/mods/ENVIRONMENT/mcl_weather/rain.lua @@ -96,7 +96,7 @@ end -- be sure to remove sound before removing player otherwise soundhandler reference will be lost. function mcl_weather.rain.remove_player(player) local player_meta = mcl_weather.players[player:get_player_name()] - if player_meta ~= nil and player_meta.origin_sky ~= nil then + if player_meta and player_meta.origin_sky then player:set_clouds({color="#FFF0F0E5"}) mcl_weather.players[player:get_player_name()] = nil end @@ -120,12 +120,12 @@ end) -- when player stay on 'edge' where sound should play and stop depending from random raindrop appearance. function mcl_weather.rain.update_sound(player) local player_meta = mcl_weather.players[player:get_player_name()] - if player_meta ~= nil then - if player_meta.sound_updated ~= nil and player_meta.sound_updated + 5 > minetest.get_gametime() then + if player_meta then + if player_meta.sound_updated and player_meta.sound_updated + 5 > minetest.get_gametime() then return false end - if player_meta.sound_handler ~= nil then + if player_meta.sound_handler then if mcl_weather.rain.last_rp_count == 0 then minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0) player_meta.sound_handler = nil @@ -141,7 +141,7 @@ end -- rain sound removed from player. function mcl_weather.rain.remove_sound(player) local player_meta = mcl_weather.players[player:get_player_name()] - if player_meta ~= nil and player_meta.sound_handler ~= nil then + if player_meta and player_meta.sound_handler then minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0) player_meta.sound_handler = nil player_meta.sound_updated = nil diff --git a/mods/ENVIRONMENT/mcl_weather/weather_core.lua b/mods/ENVIRONMENT/mcl_weather/weather_core.lua index b41887208..34f69406d 100644 --- a/mods/ENVIRONMENT/mcl_weather/weather_core.lua +++ b/mods/ENVIRONMENT/mcl_weather/weather_core.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_weather") +local S = minetest.get_translator(minetest.get_current_modname()) local math = math @@ -49,7 +49,7 @@ minetest.register_on_shutdown(save_weather) function mcl_weather.get_rand_end_time(min_duration, max_duration) local r - if min_duration ~= nil and max_duration ~= nil then + if min_duration and max_duration then r = math.random(min_duration, max_duration) else r = math.random(mcl_weather.min_duration, mcl_weather.max_duration) @@ -170,8 +170,8 @@ end function mcl_weather.change_weather(new_weather, explicit_end_time, changer_name) local changer_name = changer_name or debug.getinfo(2).name.."()" - if (mcl_weather.reg_weathers ~= nil and mcl_weather.reg_weathers[new_weather] ~= nil) then - if (mcl_weather.state ~= nil and mcl_weather.reg_weathers[mcl_weather.state] ~= nil) then + if (mcl_weather.reg_weathers and mcl_weather.reg_weathers[new_weather]) then + if (mcl_weather.state and mcl_weather.reg_weathers[mcl_weather.state]) then mcl_weather.reg_weathers[mcl_weather.state].clear() end @@ -269,7 +269,7 @@ minetest.register_chatcommand("toggledownfall", { -- Configuration setting which allows user to disable ABM for weathers (if they use it). -- Weather mods expected to be use this flag before registering ABM. local weather_allow_abm = minetest.settings:get_bool("weather_allow_abm") -if weather_allow_abm ~= nil and weather_allow_abm == false then +if weather_allow_abm == false then mcl_weather.allow_abm = false end diff --git a/mods/HELP/doc/doc/init.lua b/mods/HELP/doc/doc/init.lua index cadfff442..304900753 100644 --- a/mods/HELP/doc/doc/init.lua +++ b/mods/HELP/doc/doc/init.lua @@ -1,6 +1,10 @@ -local S = minetest.get_translator("doc") +local S = minetest.get_translator(minetest.get_current_modname()) local F = function(f) return minetest.formspec_escape(S(f)) end +local mod_central_messages = minetest.get_modpath("central_message") +local mod_inventory_plus = minetest.get_modpath("inventory_plus") + +local math = math local colorize = minetest.colorize doc = {} @@ -63,7 +67,7 @@ local set_category_order_was_called = false local function get_entry(category_id, entry_id) local category = doc.data.categories[category_id] local entry - if category ~= nil then + if category then entry = category.entries[entry_id] end if category == nil or entry == nil then @@ -93,7 +97,7 @@ end -- Add a new category function doc.add_category(id, def) - if doc.data.categories[id] == nil and id ~= nil then + if doc.data.categories[id] == nil and id then doc.data.categories[id] = {} doc.data.categories[id].entries = {} doc.data.categories[id].entry_count = 0 @@ -123,7 +127,7 @@ end -- Add a new entry function doc.add_entry(category_id, entry_id, def) local cat = doc.data.categories[category_id] - if cat ~= nil then + if cat then local hidden = def.hidden or (def.hidden == nil and cat.def.hide_entries_by_default) if hidden then cat.hidden_count = cat.hidden_count + 1 @@ -177,7 +181,7 @@ function doc.mark_entry_as_revealed(playername, category_id, entry_id) doc.data.players[playername].entry_textlist_needs_updating = true -- Notify player of entry revelation if doc.data.players[playername].stored_data.notify_on_reveal == true then - if minetest.get_modpath("central_message") ~= nil then + if mod_central_messages then local cat = doc.data.categories[category_id] cmsg.push_message_player(minetest.get_player_by_name(playername), S("New help entry unlocked: @1 > @2", cat.def.name, entry.name)) end @@ -224,7 +228,7 @@ function doc.mark_all_entries_as_revealed(playername) msg = S("All help entries are already revealed.") end -- Notify - if minetest.get_modpath("central_message") ~= nil then + if mod_central_messages then cmsg.push_message_player(minetest.get_player_by_name(playername), msg) else minetest.chat_send_player(playername, msg) @@ -427,7 +431,7 @@ end -- Returns the currently viewed entry and/or category of the player function doc.get_selection(playername) local playerdata = doc.data.players[playername] - if playerdata ~= nil then + if playerdata then local cat = playerdata.category if cat then local entry = playerdata.entry @@ -459,7 +463,7 @@ function doc.entry_builders.text_and_gallery(data, playername) local stolen_height = 0 local formstring = "" -- Only add the gallery if images are in the data, otherwise, the text widget gets all of the space - if data.images ~= nil then + if data.images then local gallery gallery, stolen_height = doc.widgets.gallery(data.images, playername, nil, doc.FORMSPEC.ENTRY_END_Y + 0.2, nil, nil, nil, nil, false) formstring = formstring .. gallery @@ -605,7 +609,7 @@ do minetest.log("action", "[doc] doc.mt opened.") local string = file:read() io.close(file) - if(string ~= nil) then + if string then local savetable = minetest.deserialize(string) for name, players_stored_data in pairs(savetable.players_stored_data) do doc.data.players[name] = {} @@ -672,13 +676,13 @@ function doc.formspec_main(playername) local data = doc.data.categories[id] local bw = doc.FORMSPEC.WIDTH / math.floor(((doc.data.category_count-1) / CATEGORYFIELDSIZE.HEIGHT)+1) -- Skip categories which do not exist - if data ~= nil then + if data then -- Category buton local button = "button["..((x-1)*bw)..","..y..";"..bw..",1;doc_button_category_"..id..";"..minetest.formspec_escape(data.def.name).."]" local tooltip = "" -- Optional description - if data.def.description ~= nil then - tooltip = "tooltip[doc_button_category_"..id..";"..minetest.formspec_escape(data.def.description).."]" + if data.def.description then + tooltip = "tooltip[doc_button_category_"..id..";"..minetest.formspec_escape(data.def.description).."]" end formstring = formstring .. button .. tooltip y = y + 1 @@ -701,7 +705,7 @@ function doc.formspec_main(playername) end end local sel = doc.data.categories[doc.data.players[playername].category] - if sel ~= nil then + if sel then formstring = formstring .. ";" formstring = formstring .. doc.data.categories[doc.data.players[playername].category].order_position end @@ -711,7 +715,7 @@ function doc.formspec_main(playername) notify_checkbox_y = doc.FORMSPEC.HEIGHT-1 end local text - if minetest.get_modpath("central_message") then + if mod_central_messages then text = F("Notify me when new help is available") else text = F("Play notification sound when new help is available") @@ -944,7 +948,7 @@ function doc.process_form(player,formname,fields) local playername = player:get_player_name() --[[ process clicks on the tab header ]] if(formname == "doc:main" or formname == "doc:category" or formname == "doc:entry") then - if fields.doc_header ~= nil then + if fields.doc_header then local tab = tonumber(fields.doc_header) local formspec, subformname, contents local cid, eid @@ -959,7 +963,7 @@ function doc.process_form(player,formname,fields) elseif(tab==3) then doc.data.players[playername].galidx = 1 contents = doc.formspec_entry(cid, eid, playername) - if cid ~= nil and eid ~= nil then + if cid and eid then doc.mark_entry_as_viewed(playername, cid, eid) end subformname = "entry" @@ -984,7 +988,7 @@ function doc.process_form(player,formname,fields) if fields["doc_mainlist"] then local event = minetest.explode_textlist_event(fields["doc_mainlist"]) local cid = doc.data.category_order[event.index] - if cid ~= nil then + if cid then if event.type == "CHG" then doc.data.players[playername].catsel = nil doc.data.players[playername].category = cid @@ -1014,10 +1018,10 @@ function doc.process_form(player,formname,fields) elseif(formname == "doc:category") then if fields["doc_button_goto_entry"] then local cid = doc.data.players[playername].category - if cid ~= nil then + if cid then local eid = nil local eids, catsel = doc.data.players[playername].entry_ids, doc.data.players[playername].catsel - if eids ~= nil and catsel ~= nil then + if eids and catsel then eid = eids[catsel] end doc.data.players[playername].galidx = 1 @@ -1040,7 +1044,7 @@ function doc.process_form(player,formname,fields) local cid = doc.data.players[playername].category local eid = nil local eids, catsel = doc.data.players[playername].entry_ids, event.index - if eids ~= nil and catsel ~= nil then + if eids and catsel then eid = eids[catsel] end doc.mark_entry_as_viewed(playername, cid, eid) @@ -1101,7 +1105,7 @@ function doc.process_form(player,formname,fields) minetest.show_formspec(playername, "doc:entry", formspec) end else - if fields["doc_inventory_plus"] and minetest.get_modpath("inventory_plus") then + if fields["doc_inventory_plus"] and mod_inventory_plus then doc.show_doc(playername) return end @@ -1169,7 +1173,7 @@ minetest.register_on_joinplayer(function(player) end -- Add button for Inventory++ - if minetest.get_modpath("inventory_plus") ~= nil then + if mod_inventory_plus then inventory_plus.register_button(player, "doc_inventory_plus", S("Help")) end end) @@ -1180,7 +1184,7 @@ local function button_action(player) end -- Unified Inventory -if minetest.get_modpath("unified_inventory") ~= nil then +if minetest.get_modpath("unified_inventory") then unified_inventory.register_button("doc", { type = "image", image = "doc_button_icon_hires.png", @@ -1190,7 +1194,7 @@ if minetest.get_modpath("unified_inventory") ~= nil then end -- sfinv_buttons -if minetest.get_modpath("sfinv_buttons") ~= nil then +if minetest.get_modpath("sfinv_buttons") then sfinv_buttons.register_button("doc", { image = "doc_button_icon_lores.png", tooltip = S("Collection of help texts"), diff --git a/mods/HELP/doc/doc_identifier/init.lua b/mods/HELP/doc/doc_identifier/init.lua index a74eb16a3..c1c2043d3 100644 --- a/mods/HELP/doc/doc_identifier/init.lua +++ b/mods/HELP/doc/doc_identifier/init.lua @@ -1,5 +1,7 @@ local S = minetest.get_translator(minetest.get_current_modname()) +local mod_doc_basics = minetest.get_modpath("doc_basics") + local doc_identifier = {} doc_identifier.registered_objects = {} @@ -25,9 +27,9 @@ function doc_identifier.identify(itemstack, user, pointed_thing) elseif itype == "error_unknown" then vsize = vsize + 2 local mod - if param ~= nil then + if param then local colon = string.find(param, ":") - if colon ~= nil and colon > 1 then + if colon and colon > 1 then mod = string.sub(param,1,colon-1) end end @@ -37,8 +39,8 @@ function doc_identifier.identify(itemstack, user, pointed_thing) S("• The author of the game or a mod has made a mistake") message = message .. "\n\n" - if mod ~= nil then - if minetest.get_modpath(mod) ~= nil then + if mod then + if minetest.get_modpath(mod) then message = message .. S("It appears to originate from the mod “@1”, which is enabled.", mod) message = message .. "\n" else @@ -46,7 +48,7 @@ function doc_identifier.identify(itemstack, user, pointed_thing) message = message .. "\n" end end - if param ~= nil then + if param then message = message .. S("Its identifier is “@1”.", param) end elseif itype == "error_ignore" then @@ -67,7 +69,7 @@ function doc_identifier.identify(itemstack, user, pointed_thing) if pointed_thing.type == "node" then local pos = pointed_thing.under local node = minetest.get_node(pos) - if minetest.registered_nodes[node.name] ~= nil then + if minetest.registered_nodes[node.name] then --local nodedef = minetest.registered_nodes[node.name] if(node.name == "ignore") then show_message(username, "error_ignore") @@ -83,14 +85,14 @@ function doc_identifier.identify(itemstack, user, pointed_thing) local object = pointed_thing.ref local le = object:get_luaentity() if object:is_player() then - if minetest.get_modpath("doc_basics") ~= nil and doc.entry_exists("basics", "players") then + if mod_doc_basics and doc.entry_exists("basics", "players") then doc.show_entry(username, "basics", "players", true) else -- Fallback message show_message(username, "player") end -- luaentity exists - elseif le ~= nil then + elseif le then local ro = doc_identifier.registered_objects[le.name] -- Dropped items if le.name == "__builtin:item" then @@ -113,7 +115,7 @@ function doc_identifier.identify(itemstack, user, pointed_thing) doc.show_entry(username, "nodes", itemstring, true) end -- A known registered object - elseif ro ~= nil then + elseif ro then doc.show_entry(username, ro.category, ro.entry, true) -- Undefined object (error) elseif minetest.registered_entities[le.name] == nil then @@ -196,7 +198,7 @@ minetest.register_craft({ {"group:stick", ""} } }) -if minetest.get_modpath("mcl_core") ~= nil then +if minetest.get_modpath("mcl_core") then minetest.register_craft({ output = "doc_identifier:identifier_solid", recipe = { { "mcl_core:glass" }, diff --git a/mods/HELP/doc/doc_items/init.lua b/mods/HELP/doc/doc_items/init.lua index d492e6cf4..325ad9abb 100644 --- a/mods/HELP/doc/doc_items/init.lua +++ b/mods/HELP/doc/doc_items/init.lua @@ -42,12 +42,12 @@ local forbidden_core_factoids = {} -- Helper functions local function yesno(bool) if bool == true then - return S("Yes") + return S("Yes") elseif bool == false then - return S("No") + return S("No") else - return "N/A" - end + return "N/A" + end end local function groups_to_string(grouptable, filter) @@ -60,7 +60,7 @@ local function groups_to_string(grouptable, filter) -- List seperator gstring = gstring .. S(", ") end - if groupdefs[id] ~= nil and doc.sub.items.settings.friendly_group_names == true then + if groupdefs[id] and doc.sub.items.settings.friendly_group_names == true then gstring = gstring .. groupdefs[id] else gstring = gstring .. id @@ -123,9 +123,9 @@ end local function get_entry_name(itemstring) local def = minetest.registered_items[itemstring] - if def._doc_items_entry_name ~= nil then + if def._doc_items_entry_name then return def._doc_items_entry_name - elseif item_name_overrides[itemstring] ~= nil then + elseif item_name_overrides[itemstring] then return item_name_overrides[itemstring] else return def.description @@ -133,7 +133,7 @@ local function get_entry_name(itemstring) end function doc.sub.items.get_group_name(groupname) - if groupdefs[groupname] ~= nil and doc.sub.items.settings.friendly_group_names == true then + if groupdefs[groupname] and doc.sub.items.settings.friendly_group_names == true then return groupdefs[groupname] else return groupname @@ -163,9 +163,9 @@ local function factoid_toolcaps(tool_capabilities, check_uses) local formstring = "" if check_uses == nil then check_uses = false end - if tool_capabilities ~= nil and tool_capabilities ~= {} then + if tool_capabilities and tool_capabilities ~= {} then local groupcaps = tool_capabilities.groupcaps - if groupcaps ~= nil then + if groupcaps then local miningcapstr = "" local miningtimesstr = "" local miningusesstr = "" @@ -198,7 +198,7 @@ local function factoid_toolcaps(tool_capabilities, check_uses) caplines = caplines + 1 for rating=3, 1, -1 do - if v.times ~= nil and v.times[rating] ~= nil then + if v.times and v.times[rating] then local maxtime = v.times[rating] local mintime local mintimestr, maxtimestr @@ -265,7 +265,7 @@ local function factoid_toolcaps(tool_capabilities, check_uses) -- Weapon data local damage_groups = tool_capabilities.damage_groups - if damage_groups ~= nil then + if damage_groups then formstring = formstring .. S("This is a melee weapon which deals damage by punching.") .. "\n" -- Damage groups formstring = formstring .. S("Maximum damage per hit:") .. "\n" @@ -276,7 +276,7 @@ local function factoid_toolcaps(tool_capabilities, check_uses) -- Full punch interval local punch = 1.0 - if tool_capabilities.full_punch_interval ~= nil then + if tool_capabilities.full_punch_interval then punch = tool_capabilities.full_punch_interval end formstring = formstring .. S("Full punch interval: @1 s", string.format("%.1f", punch)) @@ -302,7 +302,7 @@ local function factoid_mining_node(data) -- Check if there are no mining groups at all local nogroups = true for groupname,_ in pairs(mininggroups) do - if data.def.groups[groupname] ~= nil or groupname == "dig_immediate" then + if data.def.groups[groupname] or groupname == "dig_immediate" then nogroups = false break end @@ -334,7 +334,7 @@ local function factoid_mining_node(data) local minegroupcount = 0 for group,_ in pairs(mininggroups) do local rating = data.def.groups[group] - if rating ~= nil then + if rating then mstring = mstring .. S("• @1: @2", doc.sub.items.get_group_name(group), rating).."\n" minegroupcount = minegroupcount + 1 end @@ -358,14 +358,14 @@ local function range_factoid(itemstring, def) local handrange = minetest.registered_items[""].range local itemrange = def.range if itemstring == "" then - if handrange ~= nil then + if handrange then return S("Range: @1", itemrange) else return S("Range: 4") end else if handrange == nil then handrange = 4 end - if itemrange ~= nil then + if itemrange then return S("Range: @1", itemrange) else return S("Range: @1 (@2)", get_entry_name(""), handrange) @@ -381,7 +381,7 @@ local function factoid_fuel(itemstring, ctype) local formstring = "" local result, decremented = minetest.get_craft_result({method = "fuel", items = {itemstring}}) - if result ~= nil and result.time > 0 then + if result and result.time > 0 then local base local burntext = burntime_to_text(result.time) if ctype == "tools" then @@ -424,7 +424,7 @@ local function entry_image(data) formstring = formstring .. "image["..(doc.FORMSPEC.ENTRY_END_X-1)..","..doc.FORMSPEC.ENTRY_START_Y..";1,1;".. minetest.registered_items[""].wield_image.."]" -- Other items - elseif data.image ~= nil then + elseif data.image then formstring = formstring .. "image["..(doc.FORMSPEC.ENTRY_END_X-1)..","..doc.FORMSPEC.ENTRY_START_Y..";1,1;"..data.image.."]" else formstring = formstring .. "item_image["..(doc.FORMSPEC.ENTRY_END_X-1)..","..doc.FORMSPEC.ENTRY_START_Y..";1,1;"..data.itemstring.."]" @@ -442,7 +442,7 @@ factoid_generators.craftitems = {} --[[ Returns a list of all registered factoids for the specified category and type * category_id: Identifier of the Documentation System category in which the factoid appears * factoid_type: If set, oly returns factoid with a matching factoid_type. - If nil, all factoids for this category will be generated + If nil, all factoids for this category will be generated * data: Entry data to parse ]] local function factoid_custom(category_id, factoid_type, data) local ftable = factoid_generators[category_id] @@ -466,11 +466,11 @@ local function factoids_header(data, ctype) local longdesc = data.longdesc local usagehelp = data.usagehelp - if longdesc ~= nil then + if longdesc then datastring = datastring .. S("Description: @1", longdesc) datastring = newline2(datastring) end - if usagehelp ~= nil then + if usagehelp then datastring = datastring .. S("Usage help: @1", usagehelp) datastring = newline2(datastring) end @@ -494,7 +494,7 @@ local function factoids_header(data, ctype) datastring = datastring .. S("This item points to liquids.").."\n" end end - if data.def.on_use ~= nil then + if data.def.on_use then if ctype == "nodes" then datastring = datastring .. S("Punches with this block don't work as usual; melee combat and mining are either not possible or work differently.").."\n" elseif ctype == "tools" then @@ -528,7 +528,7 @@ local function factoids_footer(data, playername, ctype) -- Show other “exposable” groups if not forbidden_core_factoids.groups then local gstring, gcount = groups_to_string(data.def.groups, miscgroups) - if gstring ~= nil then + if gstring then if gcount == 1 then if ctype == "nodes" then datastring = datastring .. S("This block belongs to the @1 group.", gstring) .. "\n" @@ -607,7 +607,7 @@ doc.add_category("nodes", { datastring = datastring .. S("This block is a liquid with these properties:") .. "\n" local range, renew, viscos if data.def.liquid_range then range = data.def.liquid_range else range = 8 end - if data.def.liquid_renewable ~= nil then renew = data.def.liquid_renewable else renew = true end + if data.def.liquid_renewable then renew = data.def.liquid_renewable else renew = true end if data.def.liquid_viscosity then viscos = data.def.liquid_viscosity else viscos = 0 end if renew then datastring = datastring .. S("• Renewable") .. "\n" @@ -627,7 +627,7 @@ doc.add_category("nodes", { --- Direct interaction with the player ---- Damage (very important) if not forbidden_core_factoids.node_damage then - if data.def.damage_per_second ~= nil and data.def.damage_per_second > 1 then + if data.def.damage_per_second and data.def.damage_per_second > 1 then datastring = datastring .. S("This block causes a damage of @1 hit points per second.", data.def.damage_per_second) .. "\n" elseif data.def.damage_per_second == 1 then datastring = datastring .. S("This block causes a damage of @1 hit point per second.", data.def.damage_per_second) .. "\n" @@ -640,7 +640,7 @@ doc.add_category("nodes", { end end local fdap = data.def.groups.fall_damage_add_percent - if fdap ~= nil and fdap ~= 0 then + if fdap and fdap ~= 0 then if fdap > 0 then datastring = datastring .. S("The fall damage on this block is increased by @1%.", fdap) .. "\n" elseif fdap <= -100 then @@ -662,11 +662,11 @@ doc.add_category("nodes", { datastring = datastring .. S("This block can be climbed.").."\n" end local bouncy = data.def.groups.bouncy - if bouncy ~= nil and bouncy ~= 0 then + if bouncy and bouncy ~= 0 then datastring = datastring .. S("This block will make you bounce off with an elasticity of @1%.", bouncy).."\n" end local slippery = data.def.groups.slippery - if slippery ~= nil and slippery ~= 0 then + if slippery and slippery ~= 0 then datastring = datastring .. S("This block is slippery.") .. "\n" end datastring = datastring .. factoid_custom("nodes", "movement", data) @@ -766,7 +766,7 @@ doc.add_category("nodes", { datastring = newline2(datastring) --- List nodes/groups to which this node connects to - if not forbidden_core_factoids.connects_to and data.def.connects_to ~= nil then + if not forbidden_core_factoids.connects_to and data.def.connects_to then local nodes = {} local groups = {} for c=1,#data.def.connects_to do @@ -781,7 +781,7 @@ doc.add_category("nodes", { local nstring = "" for n=1,#nodes do local name - if item_name_overrides[nodes[n]] ~= nil then + if item_name_overrides[nodes[n]] then name = item_name_overrides[nodes[n]] else name = description_for_formspec(nodes[n]) @@ -789,7 +789,7 @@ doc.add_category("nodes", { if n > 1 then nstring = nstring .. S(", ") end - if name ~= nil then + if name then nstring = nstring .. name else nstring = nstring .. S("Unknown Node") @@ -820,7 +820,7 @@ doc.add_category("nodes", { datastring = newline2(datastring) -- Non-default drops - if not forbidden_core_factoids.drops and data.def.drop ~= nil and data.def.drop ~= data.itemstring and data.itemstring ~= "air" then + if not forbidden_core_factoids.drops and data.def.drop and data.def.drop ~= data.itemstring and data.itemstring ~= "air" then -- TODO: Calculate drop probabilities of max > 1 like for max == 1 local function get_desc(stack) return description_for_formspec(stack:get_name()) @@ -838,7 +838,7 @@ doc.add_category("nodes", { datastring = datastring .. S("This block will drop the following when mined: @1.", desc).."\n" end end - elseif type(data.def.drop) == "table" and data.def.drop.items ~= nil then + elseif type(data.def.drop) == "table" and data.def.drop.items then local max = data.def.drop.max_items local dropstring = "" local dropstring_base @@ -892,7 +892,7 @@ doc.add_category("nodes", { if chance > 0 then probtable = {} probtable.items = {} - for j=1,#data.def.drop.items[i].items do + for j = 1, #data.def.drop.items[i].items do local dropstack = ItemStack(data.def.drop.items[i].items[j]) local itemstring = dropstack:get_name() local desc = get_desc(dropstack) @@ -963,7 +963,7 @@ doc.add_category("nodes", { dropstring = dropstring .. dropstring_this pcount = pcount + 1 end - if max ~= nil and max > 1 then + if max and max > 1 then datastring = datastring .. S(dropstring_base, max, dropstring) else datastring = datastring .. S(dropstring_base, dropstring) @@ -998,15 +998,15 @@ doc.add_category("tools", { if entries[2].eid == "" then return false end local comp = {} - for e=1, 2 do + for e = 1, 2 do comp[e] = {} end -- No tool capabilities: Instant loser - if entries[1].data.def.tool_capabilities == nil and entries[2].data.def.tool_capabilities ~= nil then return false end - if entries[2].data.def.tool_capabilities == nil and entries[1].data.def.tool_capabilities ~= nil then return true end + if entries[1].data.def.tool_capabilities == nil and entries[2].data.def.tool_capabilities then return false end + if entries[2].data.def.tool_capabilities == nil and entries[1].data.def.tool_capabilities then return true end -- No tool capabilities for both: Compare by uses if entries[1].data.def.tool_capabilities == nil and entries[2].data.def.tool_capabilities == nil then - for e=1, 2 do + for e = 1, 2 do if type(entries[e].data.def._doc_items_durability) == "number" then comp[e].uses = entries[e].data.def._doc_items_durability else @@ -1061,7 +1061,7 @@ doc.add_category("tools", { comp[e].count = groupcount comp[e].group = group comp[e].mintime = mintime - if realuses ~= nil then + if realuses then comp[e].uses = realuses elseif type(entries[e].data.def._doc_items_durability) == "number" then comp[e].uses = entries[e].data.def._doc_items_durability @@ -1166,9 +1166,9 @@ local function gather_descs() -- 1st pass: Gather groups of interest for id, def in pairs(minetest.registered_items) do -- Gather all groups used for mining - if def.tool_capabilities ~= nil then + if def.tool_capabilities then local groupcaps = def.tool_capabilities.groupcaps - if groupcaps ~= nil then + if groupcaps then for k,v in pairs(groupcaps) do if mininggroups[k] ~= true then mininggroups[k] = true @@ -1179,7 +1179,7 @@ local function gather_descs() -- ... and gather all groups which appear in crafting recipes local crafts = minetest.get_all_craft_recipes(id) - if crafts ~= nil then + if crafts then for c=1,#crafts do for k,v in pairs(crafts[c].items) do if string.sub(v,1,6) == "group:" then @@ -1194,7 +1194,7 @@ local function gather_descs() end -- ... and gather all groups used in connects_to - if def.connects_to ~= nil then + if def.connects_to then for c=1, #def.connects_to do if string.sub(def.connects_to[c],1,6) == "group:" then local group = string.sub(def.connects_to[c],7,-1) @@ -1213,7 +1213,7 @@ local function gather_descs() else help.longdesc["air"] = S("A transparent block, basically empty space. It is usually left behind after digging something.") end - if minetest.registered_items["ignore"]._doc_items_create_entry ~= nil then + if minetest.registered_items["ignore"]._doc_items_create_entry then suppressed["ignore"] = minetest.registered_items["ignore"]._doc_items_create_entry == true end @@ -1246,19 +1246,19 @@ local function gather_descs() for id, def in pairs(deftable) do local name, ld, uh, im local forced = false - if def._doc_items_create_entry == true and def ~= nil then forced = true end + if def._doc_items_create_entry == true and def then forced = true end name = get_entry_name(id) if not (((def.description == nil or def.description == "") and def._doc_items_entry_name == nil) or (def._doc_items_create_entry == false) or (suppressed[id] == true)) or forced then if def._doc_items_longdesc then ld = def._doc_items_longdesc end - if help.longdesc[id] ~= nil then + if help.longdesc[id] then ld = help.longdesc[id] end if def._doc_items_usagehelp then uh = def._doc_items_usagehelp end - if help.usagehelp[id] ~= nil then + if help.usagehelp[id] then uh = help.usagehelp[id] end if def._doc_items_image then @@ -1307,13 +1307,13 @@ local function reveal_item(playername, itemstring) if itemstring == nil or itemstring == "" or playername == nil or playername == "" then return false end - if minetest.registered_nodes[itemstring] ~= nil then + if minetest.registered_nodes[itemstring] then category_id = "nodes" - elseif minetest.registered_tools[itemstring] ~= nil then + elseif minetest.registered_tools[itemstring] then category_id = "tools" - elseif minetest.registered_craftitems[itemstring] ~= nil then + elseif minetest.registered_craftitems[itemstring] then category_id = "craftitems" - elseif minetest.registered_items[itemstring] ~= nil then + elseif minetest.registered_items[itemstring] then category_id = "craftitems" else return false @@ -1333,7 +1333,7 @@ end minetest.register_on_dignode(function(pos, oldnode, digger) if digger == nil then return end local playername = digger:get_player_name() - if playername ~= nil and playername ~= "" and oldnode ~= nil then + if playername and playername ~= "" and oldnode then reveal_item(playername, oldnode.name) reveal_items_in_inventory(digger) end @@ -1342,7 +1342,7 @@ end) minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing) if puncher == nil then return end local playername = puncher:get_player_name() - if playername ~= nil and playername ~= "" and node ~= nil then + if playername and playername ~= "" and node then reveal_item(playername, node.name) end end) @@ -1350,7 +1350,7 @@ end) minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing) if placer == nil then return end local playername = placer:get_player_name() - if playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then + if playername and playername ~= "" and itemstack and not itemstack:is_empty() then reveal_item(playername, itemstack:get_name()) end end) @@ -1358,7 +1358,7 @@ end) minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) if player == nil then return end local playername = player:get_player_name() - if playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then + if playername and playername ~= "" and itemstack and not itemstack:is_empty() then reveal_item(playername, itemstack:get_name()) end end) @@ -1370,7 +1370,7 @@ minetest.register_on_player_inventory_action(function(player, action, inventory, if action == "take" or action == "put" then itemstack = inventory_info.stack end - if itemstack ~= nil and playername ~= nil and playername ~= "" and (not itemstack:is_empty()) then + if itemstack and playername and playername ~= "" and (not itemstack:is_empty()) then reveal_item(playername, itemstack:get_name()) end end) @@ -1378,9 +1378,9 @@ end) minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing) if user == nil then return end local playername = user:get_player_name() - if playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then + if playername and playername ~= "" and itemstack and not itemstack:is_empty() then reveal_item(playername, itemstack:get_name()) - if replace_with_item ~= nil then + if replace_with_item then reveal_item(playername, replace_with_item) end end @@ -1390,10 +1390,12 @@ minetest.register_on_joinplayer(function(player) reveal_items_in_inventory(player) end) ---[[ Periodically check all items in player inventory and reveal them all. +--[[ +Periodically check all items in player inventory and reveal them all. TODO: Check whether there's a serious performance impact on servers with many players. -TODO: If possible, try to replace this functionality by updating the revealed items as - soon the player obtained a new item (probably needs new Minetest callbacks). ]] +TODO: If possible, try to replace this functionality by updating the revealed items as soon the player obtained a new item (probably needs new Minetest callbacks). +]] + local checktime = 8 local timer = 0 minetest.register_globalstep(function(dtime) diff --git a/mods/HELP/mcl_doc/init.lua b/mods/HELP/mcl_doc/init.lua index fa6ae6c05..9be688ec2 100644 --- a/mods/HELP/mcl_doc/init.lua +++ b/mods/HELP/mcl_doc/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_doc") +local S = minetest.get_translator(minetest.get_current_modname()) -- Disable built-in factoids; it is planned to add custom ones as replacements doc.sub.items.disable_core_factoid("node_mining") @@ -50,8 +50,8 @@ end) doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def) local formstring = "" - if def.groups.leafdecay ~= nil then - if def.drop ~= "" and def.drop ~= nil and def.drop ~= itemstring then + if def.groups.leafdecay then + if def.drop ~= "" and def.drop and def.drop ~= itemstring then formstring = S("This block quickly decays when there is no wood block of any species within a distance of @1. When decaying, it disappears and may drop one of its regular drops. The block does not decay when the block has been placed by a player.", def.groups.leafdecay) else formstring = S("This block quickly decays and disappears when there is no wood block of any species within a distance of @1. The block does not decay when the block has been placed by a player.", def.groups.leafdecay) @@ -399,7 +399,7 @@ doc.sub.items.register_factoid("tools", "misc", function(itemstring, def) local formstring = "" -- Weapon data local damage_groups = tool_capabilities.damage_groups - if damage_groups ~= nil and damage_groups.fleshy ~= nil then + if damage_groups and damage_groups.fleshy then formstring = formstring .. S("This is a melee weapon which deals damage by punching.") .. "\n" -- Damage groups @@ -408,7 +408,7 @@ doc.sub.items.register_factoid("tools", "misc", function(itemstring, def) -- Full punch interval local punch = 1.0 - if tool_capabilities.full_punch_interval ~= nil then + if tool_capabilities.full_punch_interval then punch = tool_capabilities.full_punch_interval end formstring = formstring .. S("Full punch interval: @1 s", string.format("%.1f", punch)) diff --git a/mods/HELP/mcl_doc_basics/init.lua b/mods/HELP/mcl_doc_basics/init.lua index e700e82bd..45ce75877 100644 --- a/mods/HELP/mcl_doc_basics/init.lua +++ b/mods/HELP/mcl_doc_basics/init.lua @@ -2,7 +2,7 @@ Basic help for MCL2. Fork of doc_basics ]] -local S = minetest.get_translator("mcl_doc_basics") +local S = minetest.get_translator(minetest.get_current_modname()) doc.add_category("basics", { diff --git a/mods/HELP/mcl_doc_basics/mcl_extension.lua b/mods/HELP/mcl_doc_basics/mcl_extension.lua index c6f9f0aa9..a0f31a2c8 100644 --- a/mods/HELP/mcl_doc_basics/mcl_extension.lua +++ b/mods/HELP/mcl_doc_basics/mcl_extension.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_doc_basics") +local S = minetest.get_translator(minetest.get_current_modname()) doc.add_entry("advanced", "creative", { name = S("Creative Mode"), diff --git a/mods/HELP/mcl_tt/init.lua b/mods/HELP/mcl_tt/init.lua index 9d0113040..3451e76da 100644 --- a/mods/HELP/mcl_tt/init.lua +++ b/mods/HELP/mcl_tt/init.lua @@ -1,2 +1,4 @@ -dofile(minetest.get_modpath("mcl_tt").."/snippets_base.lua") -dofile(minetest.get_modpath("mcl_tt").."/snippets_mcl.lua") +local modpath = minetest.get_modpath(minetest.get_current_modname()) + +dofile(modpath.."/snippets_base.lua") +dofile(modpath.."/snippets_mcl.lua") \ No newline at end of file diff --git a/mods/HELP/mcl_tt/snippets_base.lua b/mods/HELP/mcl_tt/snippets_base.lua index bd5495721..4e200d539 100644 --- a/mods/HELP/mcl_tt/snippets_base.lua +++ b/mods/HELP/mcl_tt/snippets_base.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_tt") +local S = minetest.get_translator(minetest.get_current_modname()) --[[local function get_min_digtime(caps) local mintime diff --git a/mods/HELP/mcl_tt/snippets_mcl.lua b/mods/HELP/mcl_tt/snippets_mcl.lua index b10021640..3c79f52e8 100644 --- a/mods/HELP/mcl_tt/snippets_mcl.lua +++ b/mods/HELP/mcl_tt/snippets_mcl.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_tt") +local S = minetest.get_translator(minetest.get_current_modname()) -- Armor tt.register_snippet(function(itemstring) diff --git a/mods/HELP/tt/init.lua b/mods/HELP/tt/init.lua index 838aa3fa5..819bf7b81 100644 --- a/mods/HELP/tt/init.lua +++ b/mods/HELP/tt/init.lua @@ -43,7 +43,7 @@ local function apply_snippets(desc, itemstring, toolcaps, itemstack) end local function should_change(itemstring, def) - return itemstring ~= "" and itemstring ~= "air" and itemstring ~= "ignore" and itemstring ~= "unknown" and def ~= nil and def.description ~= nil and def.description ~= "" and def._tt_ignore ~= true + return itemstring ~= "" and itemstring ~= "air" and itemstring ~= "ignore" and itemstring ~= "unknown" and def and def.description and def.description ~= "" and def._tt_ignore ~= true end local function append_snippets() diff --git a/mods/HUD/awards/api.lua b/mods/HUD/awards/api.lua index d795f0dca..49b11a6cf 100644 --- a/mods/HUD/awards/api.lua +++ b/mods/HUD/awards/api.lua @@ -14,11 +14,16 @@ -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) + -- The global award namespace awards = { - show_mode = "hud" + show_mode = "hud", } -dofile(minetest.get_modpath("awards").."/api_helpers.lua") + +dofile(modpath.."/api_helpers.lua") -- Table Save Load Functions function awards.save() @@ -29,8 +34,6 @@ function awards.save() end end -local S = minetest.get_translator("awards") - function awards.init() awards.players = awards.load() awards.def = {} @@ -53,7 +56,7 @@ end function awards.register_trigger(name, func) awards.trigger_types[name] = func awards.on[name] = {} - awards['register_on_'..name] = function(func) + awards["register_on_"..name] = function(func) table.insert(awards.on[name], func) end end diff --git a/mods/HUD/awards/chat_commands.lua b/mods/HUD/awards/chat_commands.lua index 88e799dfe..88bed0afe 100644 --- a/mods/HUD/awards/chat_commands.lua +++ b/mods/HUD/awards/chat_commands.lua @@ -14,7 +14,7 @@ -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- -local S = minetest.get_translator("awards") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_chatcommand("awards", { params = S("[c|clear|disable|enable]"), diff --git a/mods/HUD/awards/init.lua b/mods/HUD/awards/init.lua index 63c9303c1..9b46fd066 100644 --- a/mods/HUD/awards/init.lua +++ b/mods/HUD/awards/init.lua @@ -14,9 +14,11 @@ -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- -dofile(minetest.get_modpath("awards").."/api.lua") -dofile(minetest.get_modpath("awards").."/chat_commands.lua") -dofile(minetest.get_modpath("awards").."/sfinv.lua") -dofile(minetest.get_modpath("awards").."/unified_inventory.lua") -dofile(minetest.get_modpath("awards").."/triggers.lua") +local modpath = minetest.get_modpath(minetest.get_current_modname()) + +dofile(modpath.."/api.lua") +dofile(modpath.."/chat_commands.lua") +dofile(modpath.."/sfinv.lua") +dofile(modpath.."/unified_inventory.lua") +dofile(modpath.."/triggers.lua") diff --git a/mods/HUD/awards/sfinv.lua b/mods/HUD/awards/sfinv.lua index 5d02cbb58..3b41d29ab 100644 --- a/mods/HUD/awards/sfinv.lua +++ b/mods/HUD/awards/sfinv.lua @@ -1,5 +1,5 @@ if minetest.get_modpath("sfinv") then - local S = minetest.get_translator("awards") + local S = minetest.get_translator(minetest.get_current_modname()) sfinv.register_page("awards:awards", { title = S("Awards"), diff --git a/mods/HUD/awards/triggers.lua b/mods/HUD/awards/triggers.lua index 995dd005c..c7194d2c9 100644 --- a/mods/HUD/awards/triggers.lua +++ b/mods/HUD/awards/triggers.lua @@ -14,7 +14,7 @@ -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- -local S = minetest.get_translator("awards") +local S = minetest.get_translator(minetest.get_current_modname()) awards.register_trigger("dig", function(def) local tmp = { @@ -382,7 +382,7 @@ end) minetest.register_on_chat_message(function(name, message) -- Run checks local idx = string.find(message,"/") - if not name or (idx ~= nil and idx <= 1) then + if not name or (idx and idx <= 1) then return end diff --git a/mods/HUD/hudbars/default_settings.lua b/mods/HUD/hudbars/default_settings.lua index ce43cc8be..865a7cb6a 100644 --- a/mods/HUD/hudbars/default_settings.lua +++ b/mods/HUD/hudbars/default_settings.lua @@ -37,7 +37,7 @@ hb.settings.alignment_pattern = hb.load_setting("hudbars_alignment_pattern", "st hb.settings.autohide_breath = hb.load_setting("hudbars_autohide_breath", "bool", true) local sorting = minetest.settings:get("hudbars_sorting") -if sorting ~= nil then +if sorting then hb.settings.sorting = {} hb.settings.sorting_reverse = {} for k,v in string.gmatch(sorting, "(%w+)=(%w+)") do diff --git a/mods/HUD/hudbars/init.lua b/mods/HUD/hudbars/init.lua index 8a1e97c9c..08f1914ca 100644 --- a/mods/HUD/hudbars/init.lua +++ b/mods/HUD/hudbars/init.lua @@ -27,10 +27,10 @@ function hb.load_setting(sname, stype, defaultval, valid_values) elseif stype == "number" then sval = tonumber(minetest.settings:get(sname)) end - if sval ~= nil then - if valid_values ~= nil then + if sval then + if valid_values then local valid = false - for i=1,#valid_values do + for i = 1, #valid_values do if sval == valid_values[i] then valid = true end @@ -114,7 +114,7 @@ function hb.get_hudtable(identifier) end function hb.get_hudbar_position_index(identifier) - if hb.settings.sorting[identifier] ~= nil then + if hb.settings.sorting[identifier] then return hb.settings.sorting[identifier] else local i = 0 @@ -215,7 +215,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, direction, offset = { x = offset.x - 1, y = offset.y - 1 }, z_index = 0, }) - if textures.icon ~= nil then + if textures.icon then ids.icon = player:hud_add({ hud_elem_type = "image", position = pos, @@ -335,7 +335,7 @@ function hb.change_hudbar(player, identifier, new_value, new_max_value, new_icon end local value_changed, max_changed = false, false - if new_value ~= nil then + if new_value then if new_value ~= hudtable.hudstate[name].value then hudtable.hudstate[name].value = new_value value_changed = true @@ -343,7 +343,7 @@ function hb.change_hudbar(player, identifier, new_value, new_max_value, new_icon else new_value = hudtable.hudstate[name].value end - if new_max_value ~= nil then + if new_max_value then if new_max_value ~= hudtable.hudstate[name].max then hudtable.hudstate[name].max = new_max_value max_changed = true @@ -353,29 +353,29 @@ function hb.change_hudbar(player, identifier, new_value, new_max_value, new_icon end if hb.settings.bar_type == "progress_bar" then - if new_icon ~= nil and hudtable.hudids[name].icon ~= nil then + if new_icon and hudtable.hudids[name].icon then player:hud_change(hudtable.hudids[name].icon, "text", new_icon) end - if new_bgicon ~= nil and hudtable.hudids[name].bgicon ~= nil then + if new_bgicon and hudtable.hudids[name].bgicon then player:hud_change(hudtable.hudids[name].bgicon, "text", new_bgicon) end - if new_bar ~= nil then + if new_bar then player:hud_change(hudtable.hudids[name].bar , "text", new_bar) end - if new_label ~= nil then + if new_label then hudtable.label = new_label local new_text = make_label(hudtable.format_string, hudtable.format_string_config, new_label, hudtable.hudstate[name].value, hudtable.hudstate[name].max) player:hud_change(hudtable.hudids[name].text, "text", new_text) end - if new_text_color ~= nil then + if new_text_color then player:hud_change(hudtable.hudids[name].text, "number", new_text_color) end else - if new_icon ~= nil and hudtable.hudids[name].bar ~= nil then + if new_icon and hudtable.hudids[name].bar then player:hud_change(hudtable.hudids[name].bar, "text", new_icon) end - if new_bgicon ~= nil and hudtable.hudids[name].bg ~= nil then + if new_bgicon and hudtable.hudids[name].bg then player:hud_change(hudtable.hudids[name].bg, "text", new_bgicon) end end @@ -426,7 +426,7 @@ function hb.hide_hudbar(player, identifier) local hudtable = hb.get_hudtable(identifier) if hudtable == nil then return false end if hb.settings.bar_type == "progress_bar" then - if hudtable.hudids[name].icon ~= nil then + if hudtable.hudids[name].icon then player:hud_change(hudtable.hudids[name].icon, "scale", {x=0,y=0}) end player:hud_change(hudtable.hudids[name].bg, "scale", {x=0,y=0}) @@ -446,7 +446,7 @@ function hb.unhide_hudbar(player, identifier) local value = hudtable.hudstate[name].value local max = hudtable.hudstate[name].max if hb.settings.bar_type == "progress_bar" then - if hudtable.hudids[name].icon ~= nil then + if hudtable.hudids[name].icon then player:hud_change(hudtable.hudids[name].icon, "scale", {x=1,y=1}) end if hudtable.hudstate[name].max ~= 0 then @@ -548,7 +548,7 @@ local function update_hud(player, has_damage) end minetest.register_on_player_hpchange(function(player) - if hb.players[player:get_player_name()] ~= nil then + if hb.players[player:get_player_name()] then update_health(player) end end) diff --git a/mods/HUD/mcl_achievements/init.lua b/mods/HUD/mcl_achievements/init.lua index 2f1db1fe6..c963773d1 100644 --- a/mods/HUD/mcl_achievements/init.lua +++ b/mods/HUD/mcl_achievements/init.lua @@ -3,7 +3,7 @@ -- If true, activates achievements from other Minecraft editions (XBox, PS, etc.) local non_pc_achievements = false -local S = minetest.get_translator("mcl_achievements") +local S = minetest.get_translator(minetest.get_current_modname()) -- Achievements from PC Edition diff --git a/mods/HUD/mcl_death_messages/init.lua b/mods/HUD/mcl_death_messages/init.lua index 107daa2a3..91e13995b 100644 --- a/mods/HUD/mcl_death_messages/init.lua +++ b/mods/HUD/mcl_death_messages/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_death_messages") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_death_messages = { assist = {}, diff --git a/mods/HUD/mcl_experience/init.lua b/mods/HUD/mcl_experience/init.lua index 0343efa24..e514ffc19 100644 --- a/mods/HUD/mcl_experience/init.lua +++ b/mods/HUD/mcl_experience/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_experience") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_experience = {} diff --git a/mods/HUD/mcl_hbarmor/init.lua b/mods/HUD/mcl_hbarmor/init.lua index 422a409fb..34ac205ac 100644 --- a/mods/HUD/mcl_hbarmor/init.lua +++ b/mods/HUD/mcl_hbarmor/init.lua @@ -19,7 +19,7 @@ local mcl_hbarmor = { local tick_config = minetest.settings:get("mcl_hbarmor_tick") -if tonumber(tick_config) ~= nil then +if tonumber(tick_config) then mcl_hbarmor.tick = tonumber(tick_config) end diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index 972456c3f..6eac1c329 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_inventory") +local S = minetest.get_translator(minetest.get_current_modname()) local F = minetest.formspec_escape -- Prepare player info table @@ -7,7 +7,7 @@ local players = {} -- Containing all the items for each Creative Mode tab local inventory_lists = {} ---local mod_player = minetest.get_modpath("mcl_player") ~= nil +--local mod_player = minetest.get_modpath("mcl_player") -- Create tables local builtin_filter_ids = {"blocks","deco","redstone","rail","food","tools","combat","mobs","brew","matr","misc","all"} @@ -37,7 +37,7 @@ do return def.mesecons or def.groups.mesecon or def.groups.mesecon_conductor_craftable or def.groups.mesecon_effecor_off end local function is_tool(def) - return def.groups.tool or (def.tool_capabilities ~= nil and def.tool_capabilities.damage_groups == nil) + return def.groups.tool or (def.tool_capabilities and def.tool_capabilities.damage_groups == nil) end local function is_weapon_or_armor(def) return def.groups.weapon or def.groups.weapon_ranged or def.groups.ammo or def.groups.combat_item or ((def.groups.armor_head or def.groups.armor_torso or def.groups.armor_legs or def.groups.armor_feet or def.groups.horse_armor) and def.groups.non_combat_armor ~= 1) @@ -301,7 +301,7 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size, if page == "nix" then local inv = minetest.get_inventory({type="detached", name="creative_"..playername}) inv_size = inv:get_size("main") - elseif page ~= nil and page ~= "inv" then + elseif page and page ~= "inv" then inv_size = #(inventory_lists[page]) else inv_size = 0 @@ -314,7 +314,7 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size, "listring[current_player;main]".. "listring[detached:trash;main]" - if page ~= nil then + if page then name = page if players[playername] then players[playername].page = page @@ -322,160 +322,158 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size, end --bg[name] = "crafting_creative_bg.png" - local inv_bg = "crafting_inventory_creative.png" - if name == "inv" then - inv_bg = "crafting_inventory_creative_survival.png" + local inv_bg = "crafting_inventory_creative.png" + if name == "inv" then + inv_bg = "crafting_inventory_creative_survival.png" - -- Show armor and player image - local player_preview - if minetest.settings:get_bool("3d_player_preview", true) then - player_preview = mcl_player.get_player_formspec_model(player, 3.9, 1.4, 1.2333, 2.4666, "") - else - player_preview = "image[3.9,1.4;1.2333,2.4666;"..mcl_player.player_get_preview(player).."]" - end - - -- Background images for armor slots (hide if occupied) - local armor_slot_imgs = "" - local inv = player:get_inventory() - if inv:get_stack("armor", 2):is_empty() then - armor_slot_imgs = armor_slot_imgs .. "image[2.5,1.3;1,1;mcl_inventory_empty_armor_slot_helmet.png]" - end - if inv:get_stack("armor", 3):is_empty() then - armor_slot_imgs = armor_slot_imgs .. "image[2.5,2.75;1,1;mcl_inventory_empty_armor_slot_chestplate.png]" - end - if inv:get_stack("armor", 4):is_empty() then - armor_slot_imgs = armor_slot_imgs .. "image[5.5,1.3;1,1;mcl_inventory_empty_armor_slot_leggings.png]" - end - if inv:get_stack("armor", 5):is_empty() then - armor_slot_imgs = armor_slot_imgs .. "image[5.5,2.75;1,1;mcl_inventory_empty_armor_slot_boots.png]" - end - - -- Survival inventory slots - main_list = "list[current_player;main;0,3.75;9,3;9]".. - mcl_formspec.get_itemslot_bg(0,3.75,9,3).. - -- armor - "list[current_player;armor;2.5,1.3;1,1;1]".. - "list[current_player;armor;2.5,2.75;1,1;2]".. - "list[current_player;armor;5.5,1.3;1,1;3]".. - "list[current_player;armor;5.5,2.75;1,1;4]".. - mcl_formspec.get_itemslot_bg(2.5,1.3,1,1).. - mcl_formspec.get_itemslot_bg(2.5,2.75,1,1).. - mcl_formspec.get_itemslot_bg(5.5,1.3,1,1).. - mcl_formspec.get_itemslot_bg(5.5,2.75,1,1).. - armor_slot_imgs.. - -- player preview - player_preview.. - -- crafting guide button - "image_button[9,1;1,1;craftguide_book.png;__mcl_craftguide;]".. - "tooltip[__mcl_craftguide;"..F(S("Recipe book")).."]".. - -- help button - "image_button[9,2;1,1;doc_button_icon_lores.png;__mcl_doc;]".. - "tooltip[__mcl_doc;"..F(S("Help")).."]".. - -- skins button - "image_button[9,3;1,1;mcl_skins_button.png;__mcl_skins;]".. - "tooltip[__mcl_skins;"..F(S("Select player skin")).."]".. - -- achievements button - "image_button[9,4;1,1;mcl_achievements_button.png;__mcl_achievements;]".. - --"style_type[image_button;border=;bgimg=;bgimg_pressed=]".. - "tooltip[__mcl_achievements;"..F(S("Achievements")).."]" - - -- For shortcuts - listrings = listrings .. - "listring[detached:"..playername.."_armor;armor]".. - "listring[current_player;main]" + -- Show armor and player image + local player_preview + if minetest.settings:get_bool("3d_player_preview", true) then + player_preview = mcl_player.get_player_formspec_model(player, 3.9, 1.4, 1.2333, 2.4666, "") else - -- Creative inventory slots - main_list = "list[detached:creative_"..playername..";main;0,1.75;9,5;"..tostring(start_i).."]".. - mcl_formspec.get_itemslot_bg(0,1.75,9,5).. - -- Page buttons - "label[9.0,5.5;"..F(S("@1/@2", pagenum, pagemax)).."]".. - "image_button[9.0,6.0;0.7,0.7;crafting_creative_prev.png;creative_prev;]".. - "image_button[9.5,6.0;0.7,0.7;crafting_creative_next.png;creative_next;]" + player_preview = "image[3.9,1.4;1.2333,2.4666;"..mcl_player.player_get_preview(player).."]" end - local tab_icon = { - blocks = "mcl_core:brick_block", - deco = "mcl_flowers:peony", - redstone = "mesecons:redstone", - rail = "mcl_minecarts:golden_rail", - misc = "mcl_buckets:bucket_lava", - nix = "mcl_compass:compass", - food = "mcl_core:apple", - tools = "mcl_core:axe_iron", - combat = "mcl_core:sword_gold", - mobs = "mobs_mc:cow", - brew = "mcl_potions:dragon_breath", - matr = "mcl_core:stick", - inv = "mcl_chests:chest", - } - local function tab(current_tab, this_tab) - local bg_img - if current_tab == this_tab then - bg_img = "crafting_creative_active"..hoch[this_tab]..".png" - else - bg_img = "crafting_creative_inactive"..hoch[this_tab]..".png" - end - return - "style["..this_tab..";border=false;bgimg=;bgimg_pressed=]".. - "item_image_button[" .. boffset[this_tab] ..";1,1;"..tab_icon[this_tab]..";"..this_tab..";]".. - "image[" .. offset[this_tab] .. ";1.5,1.44;" .. bg_img .. "]" .. - "image[" .. boffset[this_tab] .. ";1,1;crafting_creative_marker.png]" + -- Background images for armor slots (hide if occupied) + local armor_slot_imgs = "" + local inv = player:get_inventory() + if inv:get_stack("armor", 2):is_empty() then + armor_slot_imgs = armor_slot_imgs .. "image[2.5,1.3;1,1;mcl_inventory_empty_armor_slot_helmet.png]" end - local caption = "" - if name ~= "inv" and filtername[name] then - caption = "label[0,1.2;"..F(minetest.colorize("#313131", filtername[name])).."]" + if inv:get_stack("armor", 3):is_empty() then + armor_slot_imgs = armor_slot_imgs .. "image[2.5,2.75;1,1;mcl_inventory_empty_armor_slot_chestplate.png]" + end + if inv:get_stack("armor", 4):is_empty() then + armor_slot_imgs = armor_slot_imgs .. "image[5.5,1.3;1,1;mcl_inventory_empty_armor_slot_leggings.png]" + end + if inv:get_stack("armor", 5):is_empty() then + armor_slot_imgs = armor_slot_imgs .. "image[5.5,2.75;1,1;mcl_inventory_empty_armor_slot_boots.png]" end - local formspec = "size[10,9.3]".. - "no_prepend[]".. - mcl_vars.gui_nonbg..mcl_vars.gui_bg_color.. - "background[-0.19,-0.25;10.5,9.87;"..inv_bg.."]".. - "label[-5,-5;"..name.."]".. - tab(name, "blocks") .. - "tooltip[blocks;"..F(filtername["blocks"]).."]".. - tab(name, "deco") .. - "tooltip[deco;"..F(filtername["deco"]).."]".. - tab(name, "redstone") .. - "tooltip[redstone;"..F(filtername["redstone"]).."]".. - tab(name, "rail") .. - "tooltip[rail;"..F(filtername["rail"]).."]".. - tab(name, "misc") .. - "tooltip[misc;"..F(filtername["misc"]).."]".. - tab(name, "nix") .. - "tooltip[nix;"..F(filtername["nix"]).."]".. - caption.. - "list[current_player;main;0,7;9,1;]".. - mcl_formspec.get_itemslot_bg(0,7,9,1).. - main_list.. - tab(name, "food") .. - "tooltip[food;"..F(filtername["food"]).."]".. - tab(name, "tools") .. - "tooltip[tools;"..F(filtername["tools"]).."]".. - tab(name, "combat") .. - "tooltip[combat;"..F(filtername["combat"]).."]".. - tab(name, "mobs") .. - "tooltip[mobs;"..F(filtername["mobs"]).."]".. - tab(name, "brew") .. - "tooltip[brew;"..F(filtername["brew"]).."]".. - tab(name, "matr") .. - "tooltip[matr;"..F(filtername["matr"]).."]".. - tab(name, "inv") .. - "tooltip[inv;"..F(filtername["inv"]).."]".. - "list[detached:trash;main;9,7;1,1;]".. - mcl_formspec.get_itemslot_bg(9,7,1,1).. - "image[9,7;1,1;crafting_creative_trash.png]".. - listrings + -- Survival inventory slots + main_list = "list[current_player;main;0,3.75;9,3;9]".. + mcl_formspec.get_itemslot_bg(0,3.75,9,3).. + -- armor + "list[current_player;armor;2.5,1.3;1,1;1]".. + "list[current_player;armor;2.5,2.75;1,1;2]".. + "list[current_player;armor;5.5,1.3;1,1;3]".. + "list[current_player;armor;5.5,2.75;1,1;4]".. + mcl_formspec.get_itemslot_bg(2.5,1.3,1,1).. + mcl_formspec.get_itemslot_bg(2.5,2.75,1,1).. + mcl_formspec.get_itemslot_bg(5.5,1.3,1,1).. + mcl_formspec.get_itemslot_bg(5.5,2.75,1,1).. + armor_slot_imgs.. + -- player preview + player_preview.. + -- crafting guide button + "image_button[9,1;1,1;craftguide_book.png;__mcl_craftguide;]".. + "tooltip[__mcl_craftguide;"..F(S("Recipe book")).."]".. + -- help button + "image_button[9,2;1,1;doc_button_icon_lores.png;__mcl_doc;]".. + "tooltip[__mcl_doc;"..F(S("Help")).."]".. + -- skins button + "image_button[9,3;1,1;mcl_skins_button.png;__mcl_skins;]".. + "tooltip[__mcl_skins;"..F(S("Select player skin")).."]".. + -- achievements button + "image_button[9,4;1,1;mcl_achievements_button.png;__mcl_achievements;]".. + --"style_type[image_button;border=;bgimg=;bgimg_pressed=]".. + "tooltip[__mcl_achievements;"..F(S("Achievements")).."]" - if name == "nix" then - if filter == nil then - filter = "" - end - formspec = formspec .. "field[5.3,1.34;4,0.75;search;;"..minetest.formspec_escape(filter).."]" - formspec = formspec .. "field_close_on_enter[search;false]" - end - if pagenum ~= nil then formspec = formspec .. "p"..tostring(pagenum) end + -- For shortcuts + listrings = listrings .. + "listring[detached:"..playername.."_armor;armor]".. + "listring[current_player;main]" + else + -- Creative inventory slots + main_list = "list[detached:creative_"..playername..";main;0,1.75;9,5;"..tostring(start_i).."]".. + mcl_formspec.get_itemslot_bg(0,1.75,9,5).. + -- Page buttons + "label[9.0,5.5;"..F(S("@1/@2", pagenum, pagemax)).."]".. + "image_button[9.0,6.0;0.7,0.7;crafting_creative_prev.png;creative_prev;]".. + "image_button[9.5,6.0;0.7,0.7;crafting_creative_next.png;creative_next;]" + end + local tab_icon = { + blocks = "mcl_core:brick_block", + deco = "mcl_flowers:peony", + redstone = "mesecons:redstone", + rail = "mcl_minecarts:golden_rail", + misc = "mcl_buckets:bucket_lava", + nix = "mcl_compass:compass", + food = "mcl_core:apple", + tools = "mcl_core:axe_iron", + combat = "mcl_core:sword_gold", + mobs = "mobs_mc:cow", + brew = "mcl_potions:dragon_breath", + matr = "mcl_core:stick", + inv = "mcl_chests:chest", + } + local function tab(current_tab, this_tab) + local bg_img + if current_tab == this_tab then + bg_img = "crafting_creative_active"..hoch[this_tab]..".png" + else + bg_img = "crafting_creative_inactive"..hoch[this_tab]..".png" + end + return + "style["..this_tab..";border=false;bgimg=;bgimg_pressed=]".. + "item_image_button[" .. boffset[this_tab] ..";1,1;"..tab_icon[this_tab]..";"..this_tab..";]".. + "image[" .. offset[this_tab] .. ";1.5,1.44;" .. bg_img .. "]" .. + "image[" .. boffset[this_tab] .. ";1,1;crafting_creative_marker.png]" + end + local caption = "" + if name ~= "inv" and filtername[name] then + caption = "label[0,1.2;"..F(minetest.colorize("#313131", filtername[name])).."]" + end + local formspec = "size[10,9.3]".. + "no_prepend[]".. + mcl_vars.gui_nonbg..mcl_vars.gui_bg_color.. + "background[-0.19,-0.25;10.5,9.87;"..inv_bg.."]".. + "label[-5,-5;"..name.."]".. + tab(name, "blocks") .. + "tooltip[blocks;"..F(filtername["blocks"]).."]".. + tab(name, "deco") .. + "tooltip[deco;"..F(filtername["deco"]).."]".. + tab(name, "redstone") .. + "tooltip[redstone;"..F(filtername["redstone"]).."]".. + tab(name, "rail") .. + "tooltip[rail;"..F(filtername["rail"]).."]".. + tab(name, "misc") .. + "tooltip[misc;"..F(filtername["misc"]).."]".. + tab(name, "nix") .. + "tooltip[nix;"..F(filtername["nix"]).."]".. + caption.. + "list[current_player;main;0,7;9,1;]".. + mcl_formspec.get_itemslot_bg(0,7,9,1).. + main_list.. + tab(name, "food") .. + "tooltip[food;"..F(filtername["food"]).."]".. + tab(name, "tools") .. + "tooltip[tools;"..F(filtername["tools"]).."]".. + tab(name, "combat") .. + "tooltip[combat;"..F(filtername["combat"]).."]".. + tab(name, "mobs") .. + "tooltip[mobs;"..F(filtername["mobs"]).."]".. + tab(name, "brew") .. + "tooltip[brew;"..F(filtername["brew"]).."]".. + tab(name, "matr") .. + "tooltip[matr;"..F(filtername["matr"]).."]".. + tab(name, "inv") .. + "tooltip[inv;"..F(filtername["inv"]).."]".. + "list[detached:trash;main;9,7;1,1;]".. + mcl_formspec.get_itemslot_bg(9,7,1,1).. + "image[9,7;1,1;crafting_creative_trash.png]".. + listrings + + if name == "nix" then + if filter == nil then + filter = "" + end + formspec = formspec .. "field[5.3,1.34;4,0.75;search;;"..minetest.formspec_escape(filter).."]" + formspec = formspec .. "field_close_on_enter[search;false]" + end + if pagenum then formspec = formspec .. "p"..tostring(pagenum) end player:set_inventory_formspec(formspec) end @@ -545,7 +543,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) elseif fields.search == "" and not fields.creative_next and not fields.creative_prev then set_inv_page("all", player) page = "nix" - elseif fields.search ~= nil and not fields.creative_next and not fields.creative_prev then + elseif fields.search and not fields.creative_next and not fields.creative_prev then set_inv_search(string.lower(fields.search),player) page = "nix" end @@ -578,7 +576,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if page == "nix" then local inv = minetest.get_inventory({type="detached", name="creative_"..name}) inv_size = inv:get_size("main") - elseif page ~= nil and page ~= "inv" then + elseif page and page ~= "inv" then inv_size = #(inventory_lists[page]) else inv_size = 0 @@ -593,7 +591,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) players[name].start_i = start_i local filter = "" - if not fields.nix and fields.search ~= nil and fields.search ~= "" then + if not fields.nix and fields.search and fields.search ~= "" then filter = fields.search players[name].filter = filter end @@ -644,7 +642,7 @@ if minetest.is_creative_enabled("") then if page == "nix" then local inv = minetest.get_inventory({type="detached", name="creative_"..name}) inv_size = inv:get_size("main") - elseif page ~= nil and page ~= "inv" then + elseif page and page ~= "inv" then inv_size = #(inventory_lists[page]) else inv_size = 0 diff --git a/mods/HUD/mcl_inventory/init.lua b/mods/HUD/mcl_inventory/init.lua index a0be9b02e..c197bfdd9 100644 --- a/mods/HUD/mcl_inventory/init.lua +++ b/mods/HUD/mcl_inventory/init.lua @@ -1,10 +1,10 @@ -local S = minetest.get_translator("mcl_inventory") +local S = minetest.get_translator(minetest.get_current_modname()) local F = minetest.formspec_escape mcl_inventory = {} ---local mod_player = minetest.get_modpath("mcl_player") ~= nil ---local mod_craftguide = minetest.get_modpath("mcl_craftguide") ~= nil +--local mod_player = minetest.get_modpath("mcl_player") +--local mod_craftguide = minetest.get_modpath("mcl_craftguide") -- Returns a single itemstack in the given inventory to the main inventory, or drop it when there's no space left function return_item(itemstack, dropper, pos, inv) diff --git a/mods/HUD/show_wielded_item/init.lua b/mods/HUD/show_wielded_item/init.lua index 456dc23e0..dfa87a85c 100644 --- a/mods/HUD/show_wielded_item/init.lua +++ b/mods/HUD/show_wielded_item/init.lua @@ -6,6 +6,10 @@ local huds = {} local dtimes = {} local dlimit = 3 -- HUD element will be hidden after this many seconds +local math = math +local string = string +local tonumber = tonumber + local hudbars_mod = minetest.get_modpath("hudbars") local xp_mod = minetest.get_modpath("mcl_experience") @@ -74,7 +78,7 @@ minetest.register_globalstep(function(dtime) if dtimes[player_name] and dtimes[player_name] < dlimit then dtimes[player_name] = dtimes[player_name] + dtime if dtimes[player_name] > dlimit and huds[player_name] then - player:hud_change(huds[player_name], 'text', "") + player:hud_change(huds[player_name], "text", "") end end @@ -105,7 +109,7 @@ minetest.register_globalstep(function(dtime) if firstnewline then desc = string.sub(desc, 1, firstnewline-1) end - player:hud_change(huds[player_name], 'text', desc) + player:hud_change(huds[player_name], "text", desc) end end end diff --git a/mods/ITEMS/REDSTONE/mcl_comparators/init.lua b/mods/ITEMS/REDSTONE/mcl_comparators/init.lua index a76821543..3517e09cb 100644 --- a/mods/ITEMS/REDSTONE/mcl_comparators/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_comparators/init.lua @@ -1,8 +1,8 @@ -local S = minetest.get_translator("mcl_comparators") +local S = minetest.get_translator(minetest.get_current_modname()) -- Functions that get the input/output rules of the comparator -local comparator_get_output_rules = function(node) +local function comparator_get_output_rules(node) local rules = {{x = -1, y = 0, z = 0, spread=true}} for i = 0, node.param2 do rules = mesecon.rotate_rules_left(rules) @@ -11,7 +11,7 @@ local comparator_get_output_rules = function(node) end -local comparator_get_input_rules = function(node) +local function comparator_get_input_rules(node) local rules = { -- we rely on this order in update_self below {x = 1, y = 0, z = 0}, -- back @@ -27,13 +27,13 @@ end -- Functions that are called after the delay time -local comparator_turnon = function(params) +local function comparator_turnon(params) local rules = comparator_get_output_rules(params.node) mesecon.receptor_on(params.pos, rules) end -local comparator_turnoff = function(params) +local function comparator_turnoff(params) local rules = comparator_get_output_rules(params.node) mesecon.receptor_off(params.pos, rules) end @@ -41,14 +41,14 @@ end -- Functions that set the correct node type an schedule a turnon/off -local comparator_activate = function(pos, node) +local function comparator_activate(pos, node) local def = minetest.registered_nodes[node.name] minetest.swap_node(pos, { name = def.comparator_onstate, param2 = node.param2 }) minetest.after(0.1, comparator_turnon , {pos = pos, node = node}) end -local comparator_deactivate = function(pos, node) +local function comparator_deactivate(pos, node) local def = minetest.registered_nodes[node.name] minetest.swap_node(pos, { name = def.comparator_offstate, param2 = node.param2 }) minetest.after(0.1, comparator_turnoff, {pos = pos, node = node}) @@ -56,7 +56,7 @@ end -- weather pos has an inventory that contains at least one item -local container_inventory_nonempty = function(pos) +local function container_inventory_nonempty(pos) local invnode = minetest.get_node(pos) local invnodedef = minetest.registered_nodes[invnode.name] -- Ignore stale nodes @@ -78,14 +78,14 @@ local container_inventory_nonempty = function(pos) end -- weather pos has an constant signal output for the comparator -local static_signal_output = function(pos) +local function static_signal_output(pos) local node = minetest.get_node(pos) local g = minetest.get_item_group(node.name, "comparator_signal") return g > 0 end -- whether the comparator should be on according to its inputs -local comparator_desired_on = function(pos, node) +local function comparator_desired_on(pos, node) local my_input_rules = comparator_get_input_rules(node); local back_rule = my_input_rules[1] local state @@ -116,7 +116,7 @@ end -- update comparator state, if needed -local update_self = function(pos, node) +local function update_self(pos, node) node = node or minetest.get_node(pos) local old_state = mesecon.is_receptor_on(node.name) local new_state = comparator_desired_on(pos, node) @@ -131,7 +131,7 @@ end -- compute tile depending on state and mode -local get_tiles = function(state, mode) +local function get_tiles(state, mode) local top = "mcl_comparators_"..state..".png^".. "mcl_comparators_"..mode..".png" local sides = "mcl_comparators_sides_"..state..".png^".. @@ -146,13 +146,13 @@ local get_tiles = function(state, mode) end -- Given one mode, get the other mode -local flipmode = function(mode) +local function flipmode(mode) if mode == "comp" then return "sub" elseif mode == "sub" then return "comp" end end -local make_rightclick_handler = function(state, mode) +local function make_rightclick_handler(state, mode) local newnodename = "mcl_comparators:comparator_"..state.."_"..flipmode(mode) return function (pos, node, clicker) @@ -260,7 +260,7 @@ for _, mode in pairs{"comp", "sub"} do paramtype2 = "facedir", sunlight_propagates = false, is_ground_content = false, - drop = 'mcl_comparators:comparator_off_comp', + drop = "mcl_comparators:comparator_off_comp", on_construct = update_self, on_rightclick = make_rightclick_handler(state_str, mode), diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua index 73bc1f0da..8cbf74b84 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua @@ -7,10 +7,10 @@ All node definitions share a lot of code, so this is the reason why there are so many weird tables below. ]] -local S = minetest.get_translator("mcl_dispensers") +local S = minetest.get_translator(minetest.get_current_modname()) -- For after_place_node -local setup_dispenser = function(pos) +local function setup_dispenser(pos) -- Set formspec and inventory local form = "size[9,8.75]".. "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. @@ -29,7 +29,7 @@ local setup_dispenser = function(pos) inv:set_size("main", 9) end -local orientate_dispenser = function(pos, placer) +local function orientate_dispenser(pos, placer) -- Not placed by player if not placer then return end @@ -99,7 +99,7 @@ local dispenserdef = { mesecons = { effector = { -- Dispense random item when triggered - action_on = function (pos, node) + action_on = function(pos, node) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local droppos, dropdir @@ -246,10 +246,11 @@ S("• Flint and steel: Is used to ignite a fire in air and to ignite TNT").."\n S("• Spawn eggs: Will summon the mob they contain").."\n".. S("• Other items: Are simply dropped") -horizontal_def.after_place_node = function(pos, placer, itemstack, pointed_thing) +function horizontal_def.after_place_node(pos, placer, itemstack, pointed_thing) setup_dispenser(pos) orientate_dispenser(pos, placer) end + horizontal_def.tiles = { "default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png", "default_furnace_side.png", @@ -287,7 +288,7 @@ minetest.register_node("mcl_dispensers:dispenser_up", up_def) minetest.register_craft({ - output = 'mcl_dispensers:dispenser', + output = "mcl_dispensers:dispenser", recipe = { {"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",}, {"mcl_core:cobble", "mcl_bows:bow", "mcl_core:cobble",}, diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua index 715a85f3d..4bfdbab4b 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua @@ -8,10 +8,10 @@ All node definitions share a lot of code, so this is the reason why there are so many weird tables below. ]] -local S = minetest.get_translator("mcl_droppers") +local S = minetest.get_translator(minetest.get_current_modname()) -- For after_place_node -local setup_dropper = function(pos) +local function setup_dropper(pos) -- Set formspec and inventory local form = "size[9,8.75]".. "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. @@ -30,7 +30,7 @@ local setup_dropper = function(pos) inv:set_size("main", 9) end -local orientate_dropper = function(pos, placer) +local function orientate_dropper(pos, placer) -- Not placed by player if not placer then return end @@ -98,7 +98,7 @@ local dropperdef = { _mcl_hardness = 3.5, mesecons = {effector = { -- Drop random item when triggered - action_on = function (pos, node) + action_on = function(pos, node) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local droppos @@ -152,7 +152,7 @@ horizontal_def.description = S("Dropper") horizontal_def._tt_help = S("9 inventory slots").."\n"..S("Drops item when powered by redstone power") horizontal_def._doc_items_longdesc = S("A dropper is a redstone component and a container with 9 inventory slots which, when supplied with redstone power, drops an item or puts it into a container in front of it.") horizontal_def._doc_items_usagehelp = S("Droppers can be placed in 6 possible directions, items will be dropped out of the hole. Use the dropper to access its inventory. Supply it with redstone energy once to make the dropper drop or transfer a random item.") -horizontal_def.after_place_node = function(pos, placer, itemstack, pointed_thing) +function horizontal_def.after_place_node(pos, placer, itemstack, pointed_thing) setup_dropper(pos) orientate_dropper(pos, placer) end @@ -195,7 +195,7 @@ minetest.register_node("mcl_droppers:dropper_up", up_def) -- Ladies and gentlemen, I present to you: the crafting recipe! minetest.register_craft({ - output = 'mcl_droppers:dropper', + output = "mcl_droppers:dropper", recipe = { {"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",}, {"mcl_core:cobble", "", "mcl_core:cobble",}, diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua b/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua index 1bf968a82..f140a9586 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua +++ b/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua @@ -8,10 +8,10 @@ All node definitions share a lot of code, so this is the reason why there are so many weird tables below. ]] -local S = minetest.get_translator("mcl_droppers") +local S = minetest.get_translator(minetest.get_current_modname()) -- For after_place_node -local setup_dropper = function(pos) +local function setup_dropper(pos) -- Set formspec and inventory local form = "size[9,8.75]".. "background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]".. @@ -28,7 +28,7 @@ local setup_dropper = function(pos) inv:set_size("main", 9) end -local orientate_dropper = function(pos, placer) +local function orientate_dropper(pos, placer) -- Not placed by player if not placer then return end @@ -96,7 +96,7 @@ local dropperdef = { _mcl_hardness = 3.5, mesecons = {effector = { -- Drop random item when triggered - action_on = function (pos, node) + action_on = function(pos, node) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local droppos @@ -149,14 +149,16 @@ local horizontal_def = table.copy(dropperdef) horizontal_def.description = S("Dropper") horizontal_def._doc_items_longdesc = S("A dropper is a redstone component and a container with 9 inventory slots which, when supplied with redstone power, drops an item or puts it into a container in front of it.") horizontal_def._doc_items_usagehelp = S("Droppers can be placed in 6 possible directions, items will be dropped out of the hole. Use the dropper to access its inventory. Supply it with redstone energy once to make the dropper drop or transfer a random item.") -horizontal_def.after_place_node = function(pos, placer, itemstack, pointed_thing) + +function horizontal_def.after_place_node(pos, placer, itemstack, pointed_thing) setup_dropper(pos) orientate_dropper(pos, placer) end + horizontal_def.tiles = { "default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png", "default_furnace_side.png", - "default_furnace_side.png", "mcl_droppers_dropper_front_horizontal.png" + "default_furnace_side.png", "mcl_droppers_dropper_front_horizontal.png", } horizontal_def.paramtype2 = "facedir" horizontal_def.groups = {pickaxey=1, container=2, material_stone=1} @@ -170,7 +172,7 @@ down_def.after_place_node = setup_dropper down_def.tiles = { "default_furnace_top.png", "mcl_droppers_dropper_front_vertical.png", "default_furnace_side.png", "default_furnace_side.png", - "default_furnace_side.png", "default_furnace_side.png" + "default_furnace_side.png", "default_furnace_side.png", } down_def.groups = {pickaxey=1, container=2,not_in_creative_inventory=1, material_stone=1} down_def._doc_items_create_entry = false @@ -184,7 +186,7 @@ up_def.description = S("Upwards-Facing Dropper") up_def.tiles = { "mcl_droppers_dropper_front_vertical.png", "default_furnace_bottom.png", "default_furnace_side.png", "default_furnace_side.png", - "default_furnace_side.png", "default_furnace_side.png" + "default_furnace_side.png", "default_furnace_side.png", } minetest.register_node("mcl_droppers:dropper_up", up_def) @@ -192,7 +194,7 @@ minetest.register_node("mcl_droppers:dropper_up", up_def) -- Ladies and gentlemen, I present to you: the crafting recipe! minetest.register_craft({ - output = 'mcl_droppers:dropper', + output = "mcl_droppers:dropper", recipe = { {"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",}, {"mcl_core:cobble", "", "mcl_core:cobble",}, diff --git a/mods/ITEMS/REDSTONE/mcl_observers/init.lua b/mods/ITEMS/REDSTONE/mcl_observers/init.lua index 81c018016..6045b5677 100644 --- a/mods/ITEMS/REDSTONE/mcl_observers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_observers/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_observers") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_observers = {} diff --git a/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua b/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua index eabe73d1a..489a81b4a 100644 --- a/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua +++ b/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua @@ -1,3 +1,5 @@ +local table = table + mesecon.queue.actions={} -- contains all ActionQueue actions function mesecon.queue:add_function(name, func) @@ -31,7 +33,7 @@ function mesecon.queue:add_action(pos, func, params, time, overwritecheck, prior end end - if (toremove ~= nil) then + if toremove then table.remove(mesecon.queue.actions, toremove) end @@ -43,7 +45,7 @@ end -- this makes sure that resuming mesecons circuits when restarting minetest works fine -- However, even that does not work in some cases, that's why we delay the time the globalsteps -- start to be execute by 5 seconds -local get_highest_priority = function (actions) +local function get_highest_priority(actions) local highestp = -1 local highesti for i, ac in ipairs(actions) do diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index a5bcb80e8..dbe3ebe12 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -138,7 +138,7 @@ local function receptor_get_rules(node) local receptor = mesecon.get_receptor(node.name) if receptor then local rules = receptor.rules - if type(rules) == 'function' then + if type(rules) == "function" then return rules(node) elseif rules then return rules @@ -179,7 +179,7 @@ function mesecon.effector_get_rules(node) local effector = mesecon.get_effector(node.name) if effector then local rules = effector.rules - if type(rules) == 'function' then + if type(rules) == "function" then return rules(node) elseif rules then return rules @@ -352,7 +352,7 @@ function mesecon.conductor_get_rules(node) local conductor = mesecon.get_conductor(node.name) if conductor then local rules = conductor.rules - if type(rules) == 'function' then + if type(rules) == "function" then return rules(node) elseif rules then return rules diff --git a/mods/ITEMS/REDSTONE/mesecons_button/init.lua b/mods/ITEMS/REDSTONE/mesecons_button/init.lua index a8c671004..2812b2758 100644 --- a/mods/ITEMS/REDSTONE/mesecons_button/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_button/init.lua @@ -1,7 +1,7 @@ -- WALL BUTTON -- A button that when pressed emits power for a short moment and then turns off again -local S = minetest.get_translator("mesecons_button") +local S = minetest.get_translator(minetest.get_current_modname()) local button_sounds = {} -- remember button push sounds @@ -37,7 +37,7 @@ function mesecon.push_button(pos, node) timer:start(def._mcl_button_timer) end -local on_button_place = function(itemstack, placer, pointed_thing) +local function on_button_place(itemstack, placer, pointed_thing) if pointed_thing.type ~= "node" then -- no interaction possible with entities return itemstack @@ -86,7 +86,7 @@ end local buttonuse = S("Use the button to push it.") -mesecon.register_button = function(basename, description, texture, recipeitem, sounds, plusgroups, button_timer, push_by_arrow, longdesc, button_sound) +function mesecon.register_button(basename, description, texture, recipeitem, sounds, plusgroups, button_timer, push_by_arrow, longdesc, button_sound) local groups_off = table.copy(plusgroups) groups_off.attached_node=1 groups_off.dig_by_water=1 @@ -132,7 +132,7 @@ mesecon.register_button = function(basename, description, texture, recipeitem, s _doc_items_usagehelp = buttonuse, on_place = on_button_place, node_placement_prediction = "", - on_rightclick = function (pos, node) + on_rightclick = function(pos, node) mesecon.push_button(pos, node) end, sounds = sounds, @@ -159,7 +159,7 @@ mesecon.register_button = function(basename, description, texture, recipeitem, s sunlight_propagates = true, node_box = boxes_on, groups = groups_on, - drop = 'mesecons_button:button_'..basename..'_off', + drop = "mesecons_button:button_"..basename.."_off", _doc_items_create_entry = false, node_placement_prediction = "", sounds = sounds, diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua index 9c0914efb..3902c3c18 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua @@ -1,6 +1,8 @@ -local S = minetest.get_translator("mesecons_commandblock") +local S = minetest.get_translator(minetest.get_current_modname()) local F = minetest.formspec_escape +local tonumber = tonumber + local color_red = mcl_colors.RED local command_blocks_activated = minetest.settings:get_bool("mcl_enable_commandblocks", true) @@ -27,7 +29,7 @@ local function resolve_commands(commands, pos) local commander = meta:get_string("commander") -- A non-printable character used while replacing “@@”. - local SUBSTITUTE_CHARACTER = '\26' -- ASCII SUB + local SUBSTITUTE_CHARACTER = "\26" -- ASCII SUB -- No players online: remove all commands containing -- problematic placeholders. @@ -137,7 +139,7 @@ local function commandblock_action_off(pos, node) end end -local on_rightclick = function(pos, node, player, itemstack, pointed_thing) +local function on_rightclick(pos, node, player, itemstack, pointed_thing) if not command_blocks_activated then minetest.chat_send_player(player:get_player_name(), msg_not_activated) return @@ -192,18 +194,18 @@ local on_rightclick = function(pos, node, player, itemstack, pointed_thing) minetest.show_formspec(pname, "commandblock_"..pos.x.."_"..pos.y.."_"..pos.z, formspec) end -local on_place = function(itemstack, placer, pointed_thing) +local function on_place(itemstack, placer, pointed_thing) if pointed_thing.type ~= "node" then return itemstack end -- Use pointed node's on_rightclick function first, if present - local node = minetest.get_node(pointed_thing.under) - if placer and not placer:get_player_control().sneak then - if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then - return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack - end - end + local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing) + if new_stack then + return new_stack + end + + --local node = minetest.get_node(pointed_thing.under) local privs = minetest.get_player_privs(placer:get_player_name()) if not privs.maphack then @@ -295,8 +297,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end local index, _, x, y, z = string.find(formname, "commandblock_(-?%d+)_(-?%d+)_(-?%d+)") - if index ~= nil and x ~= nil and y ~= nil and z ~= nil then - local pos = {x=tonumber(x), y=tonumber(y), z=tonumber(z)} + if index and x and y and z then + local pos = {x = tonumber(x), y = tonumber(y), z = tonumber(z)} local meta = minetest.get_meta(pos) if not minetest.is_creative_enabled(player:get_player_name()) then minetest.chat_send_player(player:get_player_name(), S("Editing the command block has failed! You can only change the command block in Creative Mode!")) diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/mod.conf b/mods/ITEMS/REDSTONE/mesecons_commandblock/mod.conf index a35c425f5..26059530a 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/mod.conf +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/mod.conf @@ -1,3 +1,3 @@ name = mesecons_commandblock -depends = mesecons, mcl_colors +depends = mesecons, mcl_colors, mcl_util optional_depends = doc, doc_items diff --git a/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua b/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua index 0a330ef2c..fc12c0a36 100644 --- a/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mesecons_delayer") +local S = minetest.get_translator(minetest.get_current_modname()) local DELAYS = { 0.1, 0.2, 0.3, 0.4 } local DEFAULT_DELAY = DELAYS[1] @@ -264,8 +264,8 @@ for i = 1, 4 do paramtype2 = "facedir", sunlight_propagates = false, is_ground_content = false, - drop = 'mesecons_delayer:delayer_off_1', - on_rightclick = function (pos, node, clicker) + drop = "mesecons_delayer:delayer_off_1", + on_rightclick = function(pos, node, clicker) local protname = clicker:get_player_name() if minetest.is_protected(pos, protname) then minetest.record_protection_violation(pos, protname) @@ -330,8 +330,8 @@ for i = 1, 4 do paramtype2 = "facedir", sunlight_propagates = false, is_ground_content = false, - drop = 'mesecons_delayer:delayer_off_1', - on_rightclick = function (pos, node, clicker) + drop = "mesecons_delayer:delayer_off_1", + on_rightclick = function(pos, node, clicker) local protname = clicker:get_player_name() if minetest.is_protected(pos, protname) then minetest.record_protection_violation(pos, protname) @@ -410,7 +410,7 @@ minetest.register_node("mesecons_delayer:delayer_off_locked", { paramtype2 = "facedir", sunlight_propagates = false, is_ground_content = false, - drop = 'mesecons_delayer:delayer_off_1', + drop = "mesecons_delayer:delayer_off_1", delayer_time = DEFAULT_DELAY, sounds = mcl_sounds.node_sound_stone_defaults(), mesecons = { @@ -465,7 +465,7 @@ minetest.register_node("mesecons_delayer:delayer_on_locked", { paramtype2 = "facedir", sunlight_propagates = false, is_ground_content = false, - drop = 'mesecons_delayer:delayer_off_1', + drop = "mesecons_delayer:delayer_off_1", delayer_time = DEFAULT_DELAY, sounds = mcl_sounds.node_sound_stone_defaults(), mesecons = { diff --git a/mods/ITEMS/REDSTONE/mesecons_lightstone/init.lua b/mods/ITEMS/REDSTONE/mesecons_lightstone/init.lua index c09bcf592..0e517e4dc 100644 --- a/mods/ITEMS/REDSTONE/mesecons_lightstone/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_lightstone/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mesecons_lightstone") +local S = minetest.get_translator(minetest.get_current_modname()) local light = minetest.LIGHT_MAX @@ -11,7 +11,7 @@ minetest.register_node("mesecons_lightstone:lightstone_off", { _doc_items_longdesc = S("Redstone lamps are simple redstone components which glow brightly (light level @1) when they receive redstone power.", light), sounds = mcl_sounds.node_sound_glass_defaults(), mesecons = {effector = { - action_on = function (pos, node) + action_on = function(pos, node) minetest.swap_node(pos, {name="mesecons_lightstone:lightstone_on", param2 = node.param2}) end, rules = mesecon.rules.alldirs, @@ -29,7 +29,7 @@ minetest.register_node("mesecons_lightstone:lightstone_on", { light_source = light, sounds = mcl_sounds.node_sound_glass_defaults(), mesecons = {effector = { - action_off = function (pos, node) + action_off = function(pos, node) minetest.swap_node(pos, {name="mesecons_lightstone:lightstone_off", param2 = node.param2}) end, rules = mesecon.rules.alldirs, @@ -41,9 +41,9 @@ minetest.register_node("mesecons_lightstone:lightstone_on", { minetest.register_craft({ output = "mesecons_lightstone:lightstone_off", recipe = { - {'',"mesecons:redstone",''}, - {"mesecons:redstone",'mcl_nether:glowstone',"mesecons:redstone"}, - {'','mesecons:redstone',''}, + {"","mesecons:redstone",""}, + {"mesecons:redstone","mcl_nether:glowstone","mesecons:redstone"}, + {"","mesecons:redstone",""}, } }) diff --git a/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua index 279e98ba6..ac56d8bc5 100644 --- a/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua @@ -1,4 +1,6 @@ -local S = minetest.get_translator("mesecons_noteblock") +local S = minetest.get_translator(minetest.get_current_modname()) + +local math = math minetest.register_node("mesecons_noteblock:noteblock", { description = S("Note Block"), @@ -28,7 +30,7 @@ S("The note block will only play a note when it is below air, otherwise, it stay groups = {handy=1,axey=1, material_wood=1, flammable=-1}, is_ground_content = false, place_param2 = 0, - on_rightclick = function (pos, node, clicker) -- change sound when rightclicked + on_rightclick = function(pos, node, clicker) -- change sound when rightclicked local protname = clicker:get_player_name() if minetest.is_protected(pos, protname) then minetest.record_protection_violation(pos, protname) @@ -38,12 +40,12 @@ S("The note block will only play a note when it is below air, otherwise, it stay mesecon.noteblock_play(pos, node.param2) minetest.set_node(pos, node) end, - on_punch = function (pos, node) -- play current sound when punched + on_punch = function(pos, node) -- play current sound when punched mesecon.noteblock_play(pos, node.param2) end, sounds = mcl_sounds.node_sound_wood_defaults(), mesecons = {effector = { -- play sound when activated - action_on = function (pos, node) + action_on = function(pos, node) mesecon.noteblock_play(pos, node.param2) end, rules = mesecon.rules.alldirs, @@ -53,7 +55,7 @@ S("The note block will only play a note when it is below air, otherwise, it stay }) minetest.register_craft({ - output = '"mesecons_noteblock:noteblock" 1', + output = "mesecons_noteblock:noteblock", recipe = { {"group:wood", "group:wood", "group:wood"}, {"group:wood", "mesecons:redstone", "group:wood"}, @@ -124,7 +126,11 @@ local function param2_to_note_color(param2) return string.format("#%06X", color) end -mesecon.noteblock_play = function (pos, param2) +local function param2_to_pitch(param2) + return 2^((param2-12)/12) +end + +function mesecon.noteblock_play(pos, param2) local block_above_name = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name if block_above_name ~= "air" then -- Don't play sound if no air is above @@ -132,9 +138,6 @@ mesecon.noteblock_play = function (pos, param2) end local block_below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name - local param2_to_pitch = function(param2) - return 2^((param2-12)/12) - end local pitched = false local soundname, pitch if block_below_name == "mcl_core:goldblock" then diff --git a/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua b/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua index 0073aeb48..7d5f49048 100644 --- a/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mesecons_pistons") +local S = minetest.get_translator(minetest.get_current_modname()) local PISTON_MAXIMUM_PUSH = 12 @@ -865,7 +865,7 @@ mesecon.register_mvps_stopper("mesecons_pistons:piston_down_sticky_on") --craft recipes minetest.register_craft({ - output = 'mesecons_pistons:piston_normal_off', + output = "mesecons_pistons:piston_normal_off", recipe = { {"group:wood", "group:wood", "group:wood"}, {"mcl_core:cobble", "mcl_core:iron_ingot", "mcl_core:cobble"}, diff --git a/mods/ITEMS/REDSTONE/mesecons_pressureplates/init.lua b/mods/ITEMS/REDSTONE/mesecons_pressureplates/init.lua index 34730760d..c0894224c 100644 --- a/mods/ITEMS/REDSTONE/mesecons_pressureplates/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_pressureplates/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mesecons_pressureplates") +local S = minetest.get_translator(minetest.get_current_modname()) local PRESSURE_PLATE_INTERVAL = 0.04 diff --git a/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua b/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua index b256d87e2..ed0e4c608 100644 --- a/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mesecons_solarpanel") +local S = minetest.get_translator(minetest.get_current_modname()) local boxes = { -8/16, -8/16, -8/16, 8/16, -2/16, 8/16 } @@ -81,11 +81,11 @@ minetest.register_node("mesecons_solarpanel:solar_panel_off", { }) minetest.register_craft({ - output = 'mesecons_solarpanel:solar_panel_off', + output = "mesecons_solarpanel:solar_panel_off", recipe = { - {'mcl_core:glass', 'mcl_core:glass', 'mcl_core:glass'}, - {'mcl_nether:quartz', 'mcl_nether:quartz', 'mcl_nether:quartz'}, - {'group:wood_slab', 'group:wood_slab', 'group:wood_slab'}, + {"mcl_core:glass", "mcl_core:glass", "mcl_core:glass"}, + {"mcl_nether:quartz", "mcl_nether:quartz", "mcl_nether:quartz"}, + {"group:wood_slab", "group:wood_slab", "group:wood_slab"}, } }) diff --git a/mods/ITEMS/REDSTONE/mesecons_torch/init.lua b/mods/ITEMS/REDSTONE/mesecons_torch/init.lua index 9aefae96c..e49b843cc 100644 --- a/mods/ITEMS/REDSTONE/mesecons_torch/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_torch/init.lua @@ -1,10 +1,10 @@ -- REDSTONE TORCH AND BLOCK OF REDSTONE -local S = minetest.get_translator("mesecons_torch") +local S = minetest.get_translator(minetest.get_current_modname()) local TORCH_COOLOFF = 120 -- Number of seconds it takes for a burned-out torch to reactivate -local rotate_torch_rules = function (rules, param2) +local function rotate_torch_rules(rules, param2) if param2 == 1 then return rules elseif param2 == 5 then @@ -20,7 +20,7 @@ local rotate_torch_rules = function (rules, param2) end end -local torch_get_output_rules = function(node) +local function torch_get_output_rules(node) if node.param2 == 1 then return { { x = -1, y = 0, z = 0 }, @@ -41,7 +41,7 @@ local torch_get_output_rules = function(node) end end -local torch_get_input_rules = function(node) +local function torch_get_input_rules(node) if node.param2 == 1 then return {{x = 0, y = -1, z = 0 }} else @@ -49,7 +49,7 @@ local torch_get_input_rules = function(node) end end -local torch_overheated = function(pos) +local function torch_overheated(pos) minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.02, max_hear_distance = 6}, true) minetest.add_particle({ pos = {x=pos.x, y=pos.y+0.2, z=pos.z}, @@ -62,7 +62,7 @@ local torch_overheated = function(pos) timer:start(TORCH_COOLOFF) end -local torch_action_on = function(pos, node) +local function torch_action_on(pos, node) local overheat if node.name == "mesecons_torch:mesecon_torch_on" then overheat = mesecon.do_overheat(pos) @@ -86,7 +86,7 @@ local torch_action_on = function(pos, node) end end -local torch_action_off = function(pos, node) +local function torch_action_off(pos, node) local overheat if node.name == "mesecons_torch:mesecon_torch_off" or node.name == "mesecons_torch:mesecon_torch_overheated" then overheat = mesecon.do_overheat(pos) @@ -111,7 +111,7 @@ local torch_action_off = function(pos, node) end minetest.register_craft({ - output = 'mesecons_torch:mesecon_torch_on', + output = "mesecons_torch:mesecon_torch_on", recipe = { {"mesecons:redstone"}, {"mcl_core:stick"},} @@ -222,16 +222,16 @@ minetest.register_node("mesecons_torch:redstoneblock", { minetest.register_craft({ output = "mesecons_torch:redstoneblock", recipe = { - {'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'}, - {'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'}, - {'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'}, + {"mesecons:wire_00000000_off","mesecons:wire_00000000_off","mesecons:wire_00000000_off"}, + {"mesecons:wire_00000000_off","mesecons:wire_00000000_off","mesecons:wire_00000000_off"}, + {"mesecons:wire_00000000_off","mesecons:wire_00000000_off","mesecons:wire_00000000_off"}, } }) minetest.register_craft({ - output = 'mesecons:wire_00000000_off 9', + output = "mesecons:wire_00000000_off 9", recipe = { - {'mesecons_torch:redstoneblock'}, + {"mesecons_torch:redstoneblock"}, } }) diff --git a/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua b/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua index 92c809785..c251587d5 100644 --- a/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua @@ -1,8 +1,8 @@ -local S = minetest.get_translator("mesecons_wallever") +local S = minetest.get_translator(minetest.get_current_modname()) local lever_get_output_rules = mesecon.rules.buttonlike_get -local on_rotate = function(pos, node, user, mode) +local function on_rotate(pos, node, user, mode) if mode == screwdriver.ROTATE_FACE then if node.param2 == 10 then node.param2 = 13 @@ -50,7 +50,7 @@ minetest.register_node("mesecons_walllever:wall_lever_off", { _tt_help = S("Provides redstone power while it's turned on"), _doc_items_longdesc = S("A lever is a redstone component which can be flipped on and off. It supplies redstone power to adjacent blocks while it is in the “on” state."), _doc_items_usagehelp = S("Use the lever to flip it on or off."), - on_rightclick = function (pos, node) + on_rightclick = function(pos, node) minetest.swap_node(pos, {name="mesecons_walllever:wall_lever_on", param2=node.param2}) mesecon.receptor_on(pos, lever_get_output_rules(node)) minetest.sound_play("mesecons_button_push", {pos=pos, max_hear_distance=16}, true) @@ -148,9 +148,9 @@ minetest.register_node("mesecons_walllever:wall_lever_on", { }, groups = {handy=1, not_in_creative_inventory = 1, dig_by_water=1, destroy_by_lava_flow=1, dig_by_piston=1, attached_node_facedir=1}, is_ground_content = false, - drop = '"mesecons_walllever:wall_lever_off" 1', + drop = "mesecons_walllever:wall_lever_off", _doc_items_create_entry = false, - on_rightclick = function (pos, node) + on_rightclick = function(pos, node) minetest.swap_node(pos, {name="mesecons_walllever:wall_lever_off", param2=node.param2}) mesecon.receptor_off(pos, lever_get_output_rules(node)) minetest.sound_play("mesecons_button_push", {pos=pos, max_hear_distance=16, pitch=0.9}, true) @@ -166,10 +166,10 @@ minetest.register_node("mesecons_walllever:wall_lever_on", { }) minetest.register_craft({ - output = 'mesecons_walllever:wall_lever_off', + output = "mesecons_walllever:wall_lever_off", recipe = { - {'mcl_core:stick'}, - {'mcl_core:cobble'}, + {"mcl_core:stick"}, + {"mcl_core:cobble"}, } }) diff --git a/mods/ITEMS/REDSTONE/mesecons_wires/init.lua b/mods/ITEMS/REDSTONE/mesecons_wires/init.lua index 3d00e5f20..0f2febc44 100644 --- a/mods/ITEMS/REDSTONE/mesecons_wires/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_wires/init.lua @@ -4,7 +4,7 @@ -- Where 0 means the wire has no visual connection to that direction and -- 1 means that the wire visually connects to that other node. -local S = minetest.get_translator("mesecons_wires") +local S = minetest.get_translator(minetest.get_current_modname()) -- ####################### -- ## Update wire looks ## @@ -28,7 +28,7 @@ local wire_rules = {x= 0, y=-1, z=-1}} -- self_pos = pos of any mesecon node, from_pos = pos of conductor to getconnect for -local wire_getconnect = function (from_pos, self_pos) +local function wire_getconnect(from_pos, self_pos) local node = minetest.get_node(self_pos) if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].mesecons then @@ -50,7 +50,7 @@ local wire_getconnect = function (from_pos, self_pos) end -- Update this node -local wire_updateconnect = function (pos) +local function wire_updateconnect(pos) local connections = {} for _, r in ipairs(wire_rules) do @@ -83,7 +83,7 @@ local wire_updateconnect = function (pos) minetest.set_node(pos, {name = "mesecons:wire_"..nodeid..state_suffix}) end -local update_on_place_dig = function (pos, node) +local function update_on_place_dig(pos, node) -- Update placed node (get_node again as it may have been dug) local nn = minetest.get_node(pos) if (minetest.registered_nodes[nn.name]) @@ -139,8 +139,8 @@ local selectionbox = } -- go to the next nodeid (ex.: 01000011 --> 01000100) -local nid_inc = function() end -nid_inc = function (nid) +local function nid_inc() end +function nid_inc(nid) local i = 0 while nid[i-1] ~= 1 do nid[i] = (nid[i] ~= 1) and 1 or 0 diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index 09f4d954c..fbf6fb751 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_anvils") +local S = minetest.get_translator(minetest.get_current_modname()) local MAX_NAME_LENGTH = 35 local MAX_WEAR = 65535 @@ -180,7 +180,7 @@ local function update_anvil_slots(meta) end -- Set the new output slot - if new_output ~= nil then + if new_output then inv:set_stack("output", 1, new_output) end end diff --git a/mods/ITEMS/mcl_armor/init.lua b/mods/ITEMS/mcl_armor/init.lua index 0f7725010..799bf2e9c 100644 --- a/mods/ITEMS/mcl_armor/init.lua +++ b/mods/ITEMS/mcl_armor/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_armor") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_armor = { longdesc = S("This is a piece of equippable armor which reduces the amount of damage you receive."), diff --git a/mods/ITEMS/mcl_armor/register.lua b/mods/ITEMS/mcl_armor/register.lua index de17fd20d..1f9ce7b02 100644 --- a/mods/ITEMS/mcl_armor/register.lua +++ b/mods/ITEMS/mcl_armor/register.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_armor") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_armor.register_set({ name = "leather", diff --git a/mods/ITEMS/mcl_armor_stand/init.lua b/mods/ITEMS/mcl_armor_stand/init.lua index 870d567fc..d6080b8f8 100644 --- a/mods/ITEMS/mcl_armor_stand/init.lua +++ b/mods/ITEMS/mcl_armor_stand/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_armor_stand") +local S = minetest.get_translator(minetest.get_current_modname()) -- Spawn a stand entity local function spawn_stand_entity(pos, node) diff --git a/mods/ITEMS/mcl_banners/init.lua b/mods/ITEMS/mcl_banners/init.lua index 4ab291804..490e22643 100644 --- a/mods/ITEMS/mcl_banners/init.lua +++ b/mods/ITEMS/mcl_banners/init.lua @@ -1,6 +1,11 @@ -local S = minetest.get_translator("mcl_banners") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) local N = function(s) return s end +local mod_mcl_core = minetest.get_modpath("mcl_core") +local mod_doc = minetest.get_modpath("doc") + local node_sounds if minetest.get_modpath("mcl_sounds") then node_sounds = mcl_sounds.node_sound_wood_defaults() @@ -84,7 +89,7 @@ for k,v in pairs(mcl_banners.colors) do end -- Add pattern/emblazoning crafting recipes -dofile(minetest.get_modpath("mcl_banners").."/patterncraft.lua") +dofile(modpath.."/patterncraft.lua") -- Overlay ratios (0-255) local base_color_ratio = 224 @@ -190,7 +195,7 @@ local function spawn_banner_entity(pos, hanging, itemstack) local colorid = colors_reverse[itemstack:get_name()] banner:get_luaentity():_set_textures(colorid, layers) local mname = imeta:get_string("name") - if mname ~= nil and mname ~= "" then + if mname and mname ~= "" then banner:get_luaentity()._item_name = mname banner:get_luaentity()._item_description = imeta:get_string("description") end @@ -542,7 +547,7 @@ for colorid, colortab in pairs(mcl_banners.colors) do end meta:set_int("rotation_level", rotation_level) - if banner_entity ~= nil then + if banner_entity then banner_entity:set_yaw(final_yaw) end @@ -568,7 +573,7 @@ for colorid, colortab in pairs(mcl_banners.colors) do end, }) - if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_wool") then + if mod_mcl_core and minetest.get_modpath("mcl_wool") then minetest.register_craft({ output = itemstring, recipe = { @@ -579,14 +584,14 @@ for colorid, colortab in pairs(mcl_banners.colors) do }) end - if minetest.get_modpath("doc") then + if mod_doc then -- Add item to node alias doc.add_entry_alias("nodes", "mcl_banners:standing_banner", "craftitems", itemstring) end end end -if minetest.get_modpath("doc") then +if mod_doc then -- Add item to node alias doc.add_entry_alias("nodes", "mcl_banners:standing_banner", "nodes", "mcl_banners:hanging_banner") end diff --git a/mods/ITEMS/mcl_banners/patterncraft.lua b/mods/ITEMS/mcl_banners/patterncraft.lua index 65699768e..bc2771fee 100644 --- a/mods/ITEMS/mcl_banners/patterncraft.lua +++ b/mods/ITEMS/mcl_banners/patterncraft.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_banners") +local S = minetest.get_translator(minetest.get_current_modname()) local N = function(s) return s end -- Pattern crafting. This file contains the code for crafting all the diff --git a/mods/ITEMS/mcl_beds/api.lua b/mods/ITEMS/mcl_beds/api.lua index ee59bc34b..85873f3c6 100644 --- a/mods/ITEMS/mcl_beds/api.lua +++ b/mods/ITEMS/mcl_beds/api.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_beds") +local S = minetest.get_translator(minetest.get_current_modname()) local minetest_get_node = minetest.get_node local minetest_get_node_or_nil = minetest.get_node_or_nil diff --git a/mods/ITEMS/mcl_beds/beds.lua b/mods/ITEMS/mcl_beds/beds.lua index 8f41c7a3f..5043c85d2 100644 --- a/mods/ITEMS/mcl_beds/beds.lua +++ b/mods/ITEMS/mcl_beds/beds.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_beds") +local S = minetest.get_translator(minetest.get_current_modname()) local mod_doc = minetest.get_modpath("doc") local nodebox = { diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index fd156757b..dc9afe2ba 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -1,11 +1,12 @@ -local S = minetest.get_translator("mcl_beds") +local S = minetest.get_translator(minetest.get_current_modname()) local F = minetest.formspec_escape -local pi = math.pi +local math = math +local vector = vector local player_in_bed = 0 local is_sp = minetest.is_singleplayer() -local weather_mod = minetest.get_modpath("mcl_weather") ~= nil -local explosions_mod = minetest.get_modpath("mcl_explosions") ~= nil +local weather_mod = minetest.get_modpath("mcl_weather") +local explosions_mod = minetest.get_modpath("mcl_explosions") local spawn_mod = minetest.get_modpath("mcl_spawn") local worlds_mod = minetest.get_modpath("mcl_worlds") @@ -14,11 +15,11 @@ local worlds_mod = minetest.get_modpath("mcl_worlds") local function get_look_yaw(pos) local n = minetest.get_node(pos) if n.param2 == 1 then - return pi / 2, n.param2 + return math.pi / 2, n.param2 elseif n.param2 == 3 then - return -pi / 2, n.param2 + return -math.pi / 2, n.param2 elseif n.param2 == 0 then - return pi, n.param2 + return math.pi, n.param2 else return 0, n.param2 end @@ -105,7 +106,7 @@ local function lay_down(player, pos, bed_pos, state, skip) -- The exceptions above apply. -- Zombie pigmen only prevent sleep while they are hostle. for _, obj in pairs(minetest.get_objects_inside_radius(bed_pos, 8)) do - if obj ~= nil and not obj:is_player() then + if obj and not obj:is_player() then local ent = obj:get_luaentity() local mobname = ent.name local def = minetest.registered_entities[mobname] @@ -122,7 +123,7 @@ local function lay_down(player, pos, bed_pos, state, skip) -- stand up if state ~= nil and not state then local p = mcl_beds.pos[name] or nil - if mcl_beds.player[name] ~= nil then + if mcl_beds.player[name] then mcl_beds.player[name] = nil player_in_bed = player_in_bed - 1 end @@ -157,7 +158,7 @@ local function lay_down(player, pos, bed_pos, state, skip) local def2 = minetest.registered_nodes[n2.name] if def1.walkable or def2.walkable then return false, S("You can't sleep, the bed is obstructed!") - elseif (def1.damage_per_second ~= nil and def1.damage_per_second > 0) or (def2.damage_per_second ~= nil and def2.damage_per_second > 0) then + elseif (def1.damage_per_second and def1.damage_per_second > 0) or (def2.damage_per_second and def2.damage_per_second > 0) then return false, S("It's too dangerous to sleep here!") end @@ -273,7 +274,7 @@ end -- Throw a player out of bed function mcl_beds.kick_player(player) local name = player:get_player_name() - if mcl_beds.player[name] ~= nil then + if mcl_beds.player[name] then lay_down(player, nil, nil, false) update_formspecs(false) minetest.close_formspec(name, "mcl_beds_form") diff --git a/mods/ITEMS/mcl_books/init.lua b/mods/ITEMS/mcl_books/init.lua index 0839c1650..e549ef6f3 100644 --- a/mods/ITEMS/mcl_books/init.lua +++ b/mods/ITEMS/mcl_books/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_books") +local S = minetest.get_translator(minetest.get_current_modname()) local max_text_length = 4500 -- TODO: Increase to 12800 when scroll bar was added to written book local max_title_length = 64 @@ -21,9 +21,9 @@ minetest.register_craftitem("mcl_books:book", { if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_mobitems") then minetest.register_craft({ - type = 'shapeless', - output = 'mcl_books:book', - recipe = { 'mcl_core:paper', 'mcl_core:paper', 'mcl_core:paper', 'mcl_mobitems:leather', } + type = "shapeless", + output = "mcl_books:book", + recipe = { "mcl_core:paper", "mcl_core:paper", "mcl_core:paper", "mcl_mobitems:leather", } }) end @@ -347,11 +347,11 @@ minetest.register_node("mcl_books:bookshelf", { }) minetest.register_craft({ - output = 'mcl_books:bookshelf', + output = "mcl_books:bookshelf", recipe = { - {'group:wood', 'group:wood', 'group:wood'}, - {'mcl_books:book', 'mcl_books:book', 'mcl_books:book'}, - {'group:wood', 'group:wood', 'group:wood'}, + {"group:wood", "group:wood", "group:wood"}, + {"mcl_books:book", "mcl_books:book", "mcl_books:book"}, + {"group:wood", "group:wood", "group:wood"}, } }) diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 8b2eb0ac0..9a22ee622 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -202,7 +202,7 @@ function ARROW_ENTITY.on_step(self, dtime) -- Arrows can only damage players and mobs if obj:is_player() then ok = true - elseif obj:get_luaentity() ~= nil then + elseif obj:get_luaentity() then if (obj:get_luaentity()._cmi_is_mob or obj:get_luaentity()._hittable_by_projectile) then ok = true end @@ -222,7 +222,7 @@ function ARROW_ENTITY.on_step(self, dtime) -- If an attackable object was found, we will damage the closest one only - if closest_object ~= nil then + if closest_object then local obj = closest_object local is_player = obj:is_player() local lua = obj:get_luaentity() @@ -273,25 +273,25 @@ function ARROW_ENTITY.on_step(self, dtime) else self._rotation_station = -90 end - self._y_position = random_arrow_positions('y', placement) - self._x_position = random_arrow_positions('x', placement) + self._y_position = random_arrow_positions("y", placement) + self._x_position = random_arrow_positions("x", placement) if self._y_position > 6 and self._x_position < 2 and self._x_position > -2 then - self._attach_parent = 'Head' + self._attach_parent = "Head" self._y_position = self._y_position - 6 elseif self._x_position > 2 then - self._attach_parent = 'Arm_Right' + self._attach_parent = "Arm_Right" self._y_position = self._y_position - 3 self._x_position = self._x_position - 2 elseif self._x_position < -2 then - self._attach_parent = 'Arm_Left' + self._attach_parent = "Arm_Left" self._y_position = self._y_position - 3 self._x_position = self._x_position + 2 else - self._attach_parent = 'Body' + self._attach_parent = "Body" end self._z_rotation = math.random(-30, 30) self._y_rotation = math.random( -30, 30) - self.object:set_attach(obj, self._attach_parent, {x=self._x_position,y=self._y_position,z=random_arrow_positions('z', placement)}, {x=0,y=self._rotation_station + self._y_rotation,z=self._z_rotation}) + self.object:set_attach(obj, self._attach_parent, {x=self._x_position,y=self._y_position,z=random_arrow_positions("z", placement)}, {x=0,y=self._rotation_station + self._y_rotation,z=self._z_rotation}) minetest.after(150, function() self.object:remove() end) @@ -494,15 +494,15 @@ minetest.register_entity("mcl_bows:arrow_entity", ARROW_ENTITY) if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_mobitems") then minetest.register_craft({ - output = 'mcl_bows:arrow 4', + output = "mcl_bows:arrow 4", recipe = { - {'mcl_core:flint'}, - {'mcl_core:stick'}, - {'mcl_mobitems:feather'} + {"mcl_core:flint"}, + {"mcl_core:stick"}, + {"mcl_mobitems:feather"} } }) end -if minetest.get_modpath("doc_identifier") ~= nil then +if minetest.get_modpath("doc_identifier") then doc.sub.identifier.register_object("mcl_bows:arrow_entity", "craftitems", "mcl_bows:arrow") end diff --git a/mods/ITEMS/mcl_bows/bow.lua b/mods/ITEMS/mcl_bows/bow.lua index 8d60f3969..23b6b4310 100644 --- a/mods/ITEMS/mcl_bows/bow.lua +++ b/mods/ITEMS/mcl_bows/bow.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_bows") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_bows = {} @@ -66,7 +66,7 @@ function mcl_bows.shoot_arrow(arrow_item, pos, dir, yaw, shooter, power, damage, le._knockback = knockback le._collectable = collectable minetest.sound_play("mcl_bows_bow_shoot", {pos=pos, max_hear_distance=16}, true) - if shooter ~= nil and shooter:is_player() then + if shooter and shooter:is_player() then if obj:get_luaentity().player == "" then obj:get_luaentity().player = shooter end @@ -362,19 +362,19 @@ end) if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_mobitems") then minetest.register_craft({ - output = 'mcl_bows:bow', + output = "mcl_bows:bow", recipe = { - {'', 'mcl_core:stick', 'mcl_mobitems:string'}, - {'mcl_core:stick', '', 'mcl_mobitems:string'}, - {'', 'mcl_core:stick', 'mcl_mobitems:string'}, + {"", "mcl_core:stick", "mcl_mobitems:string"}, + {"mcl_core:stick", "", "mcl_mobitems:string"}, + {"", "mcl_core:stick", "mcl_mobitems:string"}, } }) minetest.register_craft({ - output = 'mcl_bows:bow', + output = "mcl_bows:bow", recipe = { - {'mcl_mobitems:string', 'mcl_core:stick', ''}, - {'mcl_mobitems:string', '', 'mcl_core:stick'}, - {'mcl_mobitems:string', 'mcl_core:stick', ''}, + {"mcl_mobitems:string", "mcl_core:stick", ""}, + {"mcl_mobitems:string", "", "mcl_core:stick"}, + {"mcl_mobitems:string", "mcl_core:stick", ""}, } }) end diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index fd07006b7..90ccec636 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -13,10 +13,10 @@ local mod_mcl_core = minetest.get_modpath("mcl_core") if mod_mcl_core then minetest.register_craft({ - output = 'mcl_buckets:bucket_empty 1', + output = "mcl_buckets:bucket_empty 1", recipe = { - {'mcl_core:iron_ingot', '', 'mcl_core:iron_ingot'}, - {'', 'mcl_core:iron_ingot', ''}, + {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"}, + {"", "mcl_core:iron_ingot", ""}, } }) end @@ -58,7 +58,7 @@ function mcl_buckets.register_liquid(def) end end - if def.itemname ~= nil then + if def.itemname then minetest.register_craftitem(def.itemname, { description = def.name, _doc_items_longdesc = def.longdesc, @@ -201,7 +201,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { -- Check if pointing to a liquid source local liquiddef = mcl_buckets.liquids[nn] local new_bucket - if liquiddef ~= nil and liquiddef.itemname ~= nil and (nn == liquiddef.source_take) then + if liquiddef and liquiddef.itemname and (nn == liquiddef.source_take) then -- Fill bucket, but not in Creative Mode if not minetest.is_creative_enabled(user:get_player_name()) then @@ -259,7 +259,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { local liquiddef = mcl_buckets.liquids[dropnode.name] local new_bucket - if liquiddef ~= nil and liquiddef.itemname ~= nil and (dropnode.name == liquiddef.source_take) then + if liquiddef and liquiddef.itemname and (dropnode.name == liquiddef.source_take) then -- Fill bucket new_bucket = ItemStack({name = liquiddef.itemname}) sound_take(dropnode.name, droppos) diff --git a/mods/ITEMS/mcl_buckets/register.lua b/mods/ITEMS/mcl_buckets/register.lua index 5e46b6ce0..863aa074c 100644 --- a/mods/ITEMS/mcl_buckets/register.lua +++ b/mods/ITEMS/mcl_buckets/register.lua @@ -55,7 +55,7 @@ if mod_mcl_core then extra_check = function(pos, placer) -- Check protection local placer_name = "" - if placer ~= nil then + if placer then placer_name = placer:get_player_name() end if placer and minetest.is_protected(pos, placer_name) then @@ -98,7 +98,7 @@ if mod_mclx_core then extra_check = function(pos, placer) -- Check protection local placer_name = "" - if placer ~= nil then + if placer then placer_name = placer:get_player_name() end if placer and minetest.is_protected(pos, placer_name) then diff --git a/mods/ITEMS/mcl_cake/init.lua b/mods/ITEMS/mcl_cake/init.lua index aeb706287..777b7ec58 100644 --- a/mods/ITEMS/mcl_cake/init.lua +++ b/mods/ITEMS/mcl_cake/init.lua @@ -5,7 +5,7 @@ local CAKE_HUNGER_POINTS = 2 -local S = minetest.get_translator("mcl_cake") +local S = minetest.get_translator(minetest.get_current_modname()) local cake_texture = {"cake_top.png","cake_bottom.png","cake_inner.png","cake_side.png","cake_side.png","cake_side.png"} local slice_1 = { -7/16, -8/16, -7/16, -5/16, 0/16, 7/16} @@ -20,9 +20,9 @@ local full_cake = { -7/16, -8/16, -7/16, 7/16, 0/16, 7/16} minetest.register_craft({ output = "mcl_cake:cake", recipe = { - {'mcl_mobitems:milk_bucket', 'mcl_mobitems:milk_bucket', 'mcl_mobitems:milk_bucket'}, - {'mcl_core:sugar', 'mcl_throwing:egg', 'mcl_core:sugar'}, - {'mcl_farming:wheat_item', 'mcl_farming:wheat_item', 'mcl_farming:wheat_item'}, + {"mcl_mobitems:milk_bucket", "mcl_mobitems:milk_bucket", "mcl_mobitems:milk_bucket"}, + {"mcl_core:sugar", "mcl_throwing:egg", "mcl_core:sugar"}, + {"mcl_farming:wheat_item", "mcl_farming:wheat_item", "mcl_farming:wheat_item"}, }, replacements = { {"mcl_mobitems:milk_bucket", "mcl_buckets:bucket_empty"}, @@ -53,7 +53,7 @@ minetest.register_node("mcl_cake:cake", { }, stack_max = 1, groups = {handy=1, cake=7, food=2,no_eat_delay=1, attached_node=1, dig_by_piston=1, comparator_signal=14}, - drop = '', + drop = "", on_rightclick = function(pos, node, clicker, itemstack) -- Cake is subject to protection local name = clicker:get_player_name() @@ -126,7 +126,7 @@ local register_slice = function(level, nodebox, desc) fixed = nodebox, }, groups = {handy=1, cake=level, food=2,no_eat_delay=1,attached_node=1,not_in_creative_inventory=1,dig_by_piston=1,comparator_signal=level*2}, - drop = '', + drop = "", on_rightclick = on_rightclick, sounds = mcl_sounds.node_sound_leaves_defaults(), diff --git a/mods/ITEMS/mcl_cauldrons/init.lua b/mods/ITEMS/mcl_cauldrons/init.lua index 62c45170c..55866f5cc 100644 --- a/mods/ITEMS/mcl_cauldrons/init.lua +++ b/mods/ITEMS/mcl_cauldrons/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_cauldron") +local S = minetest.get_translator(minetest.get_current_modname()) -- Cauldron mod, adds cauldrons. diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index de7ef97ca..de8b9bd09 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_chests") +local S = minetest.get_translator(minetest.get_current_modname()) local mod_doc = minetest.get_modpath("doc") -- Chest Entity @@ -158,8 +158,8 @@ end --[[ List of open chests. Key: Player name Value: - If player is using a chest: { pos = } - Otherwise: nil ]] + If player is using a chest: { pos = } + Otherwise: nil ]] local open_chests = {} --[[local function back_is_blocked(pos, dir) @@ -171,7 +171,7 @@ local open_chests = {} end]] -- To be called if a player opened a chest -local player_chest_open = function(player, pos, node_name, textures, param2, double, sound, mesh, shulker) +local function player_chest_open(player, pos, node_name, textures, param2, double, sound, mesh, shulker) local name = player:get_player_name() open_chests[name] = {pos = pos, node_name = node_name, textures = textures, param2 = param2, double = double, sound = sound, mesh = mesh, shulker = shulker} if animate_chests then @@ -181,7 +181,7 @@ local player_chest_open = function(player, pos, node_name, textures, param2, dou end -- Simple protection checking functions -local protection_check_move = function(pos, from_list, from_index, to_list, to_index, count, player) +local function protection_check_move(pos, from_list, from_index, to_list, to_index, count, player) local name = player:get_player_name() if minetest.is_protected(pos, name) then minetest.record_protection_violation(pos, name) @@ -190,7 +190,7 @@ local protection_check_move = function(pos, from_list, from_index, to_list, to_i return count end end -local protection_check_put_take = function(pos, listname, index, stack, player) +local function protection_check_put_take(pos, listname, index, stack, player) local name = player:get_player_name() if minetest.is_protected(pos, name) then minetest.record_protection_violation(pos, name) @@ -203,7 +203,7 @@ end local trapped_chest_mesecons_rules = mesecon.rules.pplate -- To be called when a chest is closed (only relevant for trapped chest atm) -local chest_update_after_close = function(pos) +local function chest_update_after_close(pos) local node = minetest.get_node(pos) if node.name == "mcl_chests:trapped_chest_on_small" then @@ -230,7 +230,7 @@ local chest_update_after_close = function(pos) end -- To be called if a player closed a chest -local player_chest_close = function(player) +local function player_chest_close(player) local name = player:get_player_name() local open_chest = open_chests[name] if open_chest == nil then @@ -245,569 +245,569 @@ local player_chest_close = function(player) end -- This is a helper function to register both chests and trapped chests. Trapped chests will make use of the additional parameters -local register_chest = function(basename, desc, longdesc, usagehelp, tt_help, tiles_table, hidden, mesecons, on_rightclick_addendum, on_rightclick_addendum_left, on_rightclick_addendum_right, drop, canonical_basename) --- START OF register_chest FUNCTION BODY -if not drop then - drop = "mcl_chests:"..basename -else - drop = "mcl_chests:"..drop -end --- The basename of the "canonical" version of the node, if set (e.g.: trapped_chest_on → trapped_chest). --- Used to get a shared formspec ID and to swap the node back to the canonical version in on_construct. -if not canonical_basename then - canonical_basename = basename -end - -local double_chest_add_item = function(top_inv, bottom_inv, listname, stack) - if not stack or stack:is_empty() then - return +local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tiles_table, hidden, mesecons, on_rightclick_addendum, on_rightclick_addendum_left, on_rightclick_addendum_right, drop, canonical_basename) + -- START OF register_chest FUNCTION BODY + if not drop then + drop = "mcl_chests:"..basename + else + drop = "mcl_chests:"..drop + end + -- The basename of the "canonical" version of the node, if set (e.g.: trapped_chest_on → trapped_chest). + -- Used to get a shared formspec ID and to swap the node back to the canonical version in on_construct. + if not canonical_basename then + canonical_basename = basename end - local name = stack:get_name() + local function double_chest_add_item(top_inv, bottom_inv, listname, stack) + if not stack or stack:is_empty() then + return + end - local top_off = function(inv, stack) - for c, chest_stack in ipairs(inv:get_list(listname)) do + local name = stack:get_name() + + local function top_off(inv, stack) + for c, chest_stack in ipairs(inv:get_list(listname)) do + if stack:is_empty() then + break + end + + if chest_stack:get_name() == name and chest_stack:get_free_space() > 0 then + stack = chest_stack:add_item(stack) + inv:set_stack(listname, c, chest_stack) + end + end + + return stack + end + + stack = top_off(top_inv, stack) + stack = top_off(bottom_inv, stack) + + if not stack:is_empty() then + stack = top_inv:add_item(listname, stack) + if not stack:is_empty() then + bottom_inv:add_item(listname, stack) + end + end + end + + local function drop_items_chest(pos, oldnode, oldmetadata) + local meta = minetest.get_meta(pos) + local meta2 = meta + if oldmetadata then + meta:from_table(oldmetadata) + end + local inv = meta:get_inventory() + for i=1,inv:get_size("main") do + local stack = inv:get_stack("main", i) + if not stack:is_empty() then + local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} + minetest.add_item(p, stack) + end + end + meta:from_table(meta2:to_table()) + end + + local function on_chest_blast(pos) + local node = minetest.get_node(pos) + drop_items_chest(pos, node) + minetest.remove_node(pos) + end + + local function limit_put_list(stack, list) + for _, other in ipairs(list) do + stack = other:add_item(stack) if stack:is_empty() then break end - - if chest_stack:get_name() == name and chest_stack:get_free_space() > 0 then - stack = chest_stack:add_item(stack) - inv:set_stack(listname, c, chest_stack) - end end - return stack end - stack = top_off(top_inv, stack) - stack = top_off(bottom_inv, stack) + local function limit_put(stack, inv1, inv2) + local leftover = ItemStack(stack) + leftover = limit_put_list(leftover, inv1:get_list("main")) + leftover = limit_put_list(leftover, inv2:get_list("main")) + return stack:get_count() - leftover:get_count() + end - if not stack:is_empty() then - stack = top_inv:add_item(listname, stack) - if not stack:is_empty() then - bottom_inv:add_item(listname, stack) + local small_name = "mcl_chests:"..basename.."_small" + local small_textures = tiles_table.small + local left_name = "mcl_chests:"..basename.."_left" + local left_textures = tiles_table.double + + minetest.register_node("mcl_chests:"..basename, { + description = desc, + _tt_help = tt_help, + _doc_items_longdesc = longdesc, + _doc_items_usagehelp = usagehelp, + _doc_items_hidden = hidden, + drawtype = "mesh", + mesh = "mcl_chests_chest.obj", + tiles = small_textures, + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, + paramtype = "light", + paramtype2 = "facedir", + stack_max = 64, + sounds = mcl_sounds.node_sound_wood_defaults(), + groups = {deco_block=1}, + on_construct = function(pos, node) + local node = minetest.get_node(pos) + node.name = small_name + minetest.set_node(pos, node) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) + end, + }) + + local function close_forms(canonical_basename, pos) + local players = minetest.get_connected_players() + for p=1, #players do + if vector.distance(players[p]:get_pos(), pos) <= 30 then + minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z) + end end end -end -local drop_items_chest = function(pos, oldnode, oldmetadata) - local meta = minetest.get_meta(pos) - local meta2 = meta - if oldmetadata then - meta:from_table(oldmetadata) - end - local inv = meta:get_inventory() - for i=1,inv:get_size("main") do - local stack = inv:get_stack("main", i) - if not stack:is_empty() then - local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} - minetest.add_item(p, stack) - end - end - meta:from_table(meta2:to_table()) -end + minetest.register_node(small_name, { + description = desc, + _tt_help = tt_help, + _doc_items_longdesc = longdesc, + _doc_items_usagehelp = usagehelp, + _doc_items_hidden = hidden, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.4375, -0.5, -0.4375, 0.4375, 0.375, 0.4375}, + }, + tiles = {"mcl_chests_blank.png"}, + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true, + _chest_entity_textures = small_textures, + _chest_entity_sound = "default_chest", + _chest_entity_mesh = "mcl_chests_chest", + _chest_entity_animation_type = "chest", + paramtype = "light", + paramtype2 = "facedir", + stack_max = 64, + drop = drop, + groups = {handy=1,axey=1, container=2, deco_block=1, material_wood=1,flammable=-1,chest_entity=1, not_in_creative_inventory=1}, + is_ground_content = false, + sounds = mcl_sounds.node_sound_wood_defaults(), + on_construct = function(pos) + local param2 = minetest.get_node(pos).param2 + local meta = minetest.get_meta(pos) + --[[ This is a workaround for Minetest issue 5894 + . + Apparently if we don't do this, large chests initially don't work when + placed at chunk borders, and some chests randomly don't work after + placing. ]] + -- FIXME: Remove this workaround when the bug has been fixed. + -- BEGIN OF WORKAROUND -- + meta:set_string("workaround", "ignore_me") + meta:set_string("workaround", nil) -- Done to keep metadata clean + -- END OF WORKAROUND -- + local inv = meta:get_inventory() + inv:set_size("main", 9*3) + --[[ The "input" list is *another* workaround (hahahaha!) around the fact that Minetest + does not support listrings to put items into an alternative list if the first one + happens to be full. See . + This list is a hidden input-only list and immediately puts items into the appropriate chest. + It is only used for listrings and hoppers. This workaround is not that bad because it only + requires a simple “inventory allows” check for large chests.]] + -- FIXME: Refactor the listrings as soon Minetest supports alternative listrings + -- BEGIN OF LISTRING WORKAROUND + inv:set_size("input", 1) + -- END OF LISTRING WORKAROUND + if minetest.get_node(mcl_util.get_double_container_neighbor_pos(pos, param2, "right")).name == "mcl_chests:"..canonical_basename.."_small" then + minetest.swap_node(pos, {name="mcl_chests:"..canonical_basename.."_right",param2=param2}) + local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right") + minetest.swap_node(p, { name = "mcl_chests:"..canonical_basename.."_left", param2 = param2 }) + create_entity(p, "mcl_chests:"..canonical_basename.."_left", left_textures, param2, true, "default_chest", "mcl_chests_chest", "chest") + elseif minetest.get_node(mcl_util.get_double_container_neighbor_pos(pos, param2, "left")).name == "mcl_chests:"..canonical_basename.."_small" then + minetest.swap_node(pos, {name="mcl_chests:"..canonical_basename.."_left",param2=param2}) + create_entity(pos, "mcl_chests:"..canonical_basename.."_left", left_textures, param2, true, "default_chest", "mcl_chests_chest", "chest") + local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "left") + minetest.swap_node(p, { name = "mcl_chests:"..canonical_basename.."_right", param2 = param2 }) + else + minetest.swap_node(pos, { name = "mcl_chests:"..canonical_basename.."_small", param2 = param2 }) + create_entity(pos, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest", "chest") + end + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) + end, + after_dig_node = drop_items_chest, + on_blast = on_chest_blast, + allow_metadata_inventory_move = protection_check_move, + allow_metadata_inventory_take = protection_check_put_take, + allow_metadata_inventory_put = protection_check_put_take, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to chest at "..minetest.pos_to_string(pos)) + -- BEGIN OF LISTRING WORKAROUND + if listname == "input" then + local inv = minetest.get_inventory({type="node", pos=pos}) + inv:add_item("main", stack) + end + -- END OF LISTRING WORKAROUND + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from chest at "..minetest.pos_to_string(pos)) + end, + _mcl_blast_resistance = 2.5, + _mcl_hardness = 2.5, -local on_chest_blast = function(pos) - local node = minetest.get_node(pos) - drop_items_chest(pos, node) - minetest.remove_node(pos) -end + on_rightclick = function(pos, node, clicker) + if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name].groups.opaque == 1 then + -- won't open if there is no space from the top + return false + end + local name = minetest.get_meta(pos):get_string("name") + if name == "" then + name = S("Chest") + end -local function limit_put_list(stack, list) - for _, other in ipairs(list) do - stack = other:add_item(stack) - if stack:is_empty() then - break - end - end - return stack -end + minetest.show_formspec(clicker:get_player_name(), + "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, + "size[9,8.75]".. + "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]".. + "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]".. + mcl_formspec.get_itemslot_bg(0,0.5,9,3).. + "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. + "list[current_player;main;0,4.5;9,3;9]".. + mcl_formspec.get_itemslot_bg(0,4.5,9,3).. + "list[current_player;main;0,7.74;9,1;]".. + mcl_formspec.get_itemslot_bg(0,7.74,9,1).. + "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]".. + "listring[current_player;main]") -local function limit_put(stack, inv1, inv2) - local leftover = ItemStack(stack) - leftover = limit_put_list(leftover, inv1:get_list("main")) - leftover = limit_put_list(leftover, inv2:get_list("main")) - return stack:get_count() - leftover:get_count() -end + if on_rightclick_addendum then + on_rightclick_addendum(pos, node, clicker) + end -local small_name = "mcl_chests:"..basename.."_small" -local small_textures = tiles_table.small -local left_name = "mcl_chests:"..basename.."_left" -local left_textures = tiles_table.double + player_chest_open(clicker, pos, small_name, small_textures, node.param2, false, "default_chest", "mcl_chests_chest") + end, -minetest.register_node("mcl_chests:"..basename, { - description = desc, - _tt_help = tt_help, - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usagehelp, - _doc_items_hidden = hidden, - drawtype = "mesh", - mesh = "mcl_chests_chest.obj", - tiles = small_textures, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, - paramtype = "light", - paramtype2 = "facedir", - stack_max = 64, - sounds = mcl_sounds.node_sound_wood_defaults(), - groups = {deco_block=1}, - on_construct = function(pos, node) - local node = minetest.get_node(pos) - node.name = small_name - minetest.set_node(pos, node) - end, - after_place_node = function(pos, placer, itemstack, pointed_thing) - minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) - end, -}) + on_destruct = function(pos) + close_forms(canonical_basename, pos) + end, + mesecons = mesecons, + on_rotate = simple_rotate, + }) -local function close_forms(canonical_basename, pos) - local players = minetest.get_connected_players() - for p=1, #players do - if vector.distance(players[p]:get_pos(), pos) <= 30 then - minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z) - end - end -end - -minetest.register_node(small_name, { - description = desc, - _tt_help = tt_help, - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usagehelp, - _doc_items_hidden = hidden, - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = {-0.4375, -0.5, -0.4375, 0.4375, 0.375, 0.4375}, - }, - tiles = {"mcl_chests_blank.png"}, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true, - _chest_entity_textures = small_textures, - _chest_entity_sound = "default_chest", - _chest_entity_mesh = "mcl_chests_chest", - _chest_entity_animation_type = "chest", - paramtype = "light", - paramtype2 = "facedir", - stack_max = 64, - drop = drop, - groups = {handy=1,axey=1, container=2, deco_block=1, material_wood=1,flammable=-1,chest_entity=1, not_in_creative_inventory=1}, - is_ground_content = false, - sounds = mcl_sounds.node_sound_wood_defaults(), - on_construct = function(pos) - local param2 = minetest.get_node(pos).param2 - local meta = minetest.get_meta(pos) - --[[ This is a workaround for Minetest issue 5894 - . - Apparently if we don't do this, large chests initially don't work when - placed at chunk borders, and some chests randomly don't work after - placing. ]] - -- FIXME: Remove this workaround when the bug has been fixed. - -- BEGIN OF WORKAROUND -- - meta:set_string("workaround", "ignore_me") - meta:set_string("workaround", nil) -- Done to keep metadata clean - -- END OF WORKAROUND -- - local inv = meta:get_inventory() - inv:set_size("main", 9*3) - --[[ The "input" list is *another* workaround (hahahaha!) around the fact that Minetest - does not support listrings to put items into an alternative list if the first one - happens to be full. See . - This list is a hidden input-only list and immediately puts items into the appropriate chest. - It is only used for listrings and hoppers. This workaround is not that bad because it only - requires a simple “inventory allows” check for large chests.]] - -- FIXME: Refactor the listrings as soon Minetest supports alternative listrings - -- BEGIN OF LISTRING WORKAROUND - inv:set_size("input", 1) - -- END OF LISTRING WORKAROUND - if minetest.get_node(mcl_util.get_double_container_neighbor_pos(pos, param2, "right")).name == "mcl_chests:"..canonical_basename.."_small" then - minetest.swap_node(pos, {name="mcl_chests:"..canonical_basename.."_right",param2=param2}) - local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right") - minetest.swap_node(p, { name = "mcl_chests:"..canonical_basename.."_left", param2 = param2 }) - create_entity(p, "mcl_chests:"..canonical_basename.."_left", left_textures, param2, true, "default_chest", "mcl_chests_chest", "chest") - elseif minetest.get_node(mcl_util.get_double_container_neighbor_pos(pos, param2, "left")).name == "mcl_chests:"..canonical_basename.."_small" then - minetest.swap_node(pos, {name="mcl_chests:"..canonical_basename.."_left",param2=param2}) - create_entity(pos, "mcl_chests:"..canonical_basename.."_left", left_textures, param2, true, "default_chest", "mcl_chests_chest", "chest") + minetest.register_node(left_name, { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.4375, -0.5, -0.4375, 0.5, 0.375, 0.4375}, + }, + tiles = {"mcl_chests_blank.png"}, + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true, + _chest_entity_textures = left_textures, + _chest_entity_sound = "default_chest", + _chest_entity_mesh = "mcl_chests_chest", + _chest_entity_animation_type = "chest", + paramtype = "light", + paramtype2 = "facedir", + groups = {handy=1,axey=1, container=5,not_in_creative_inventory=1, material_wood=1,flammable=-1,chest_entity=1,double_chest=1}, + drop = drop, + is_ground_content = false, + sounds = mcl_sounds.node_sound_wood_defaults(), + on_construct = function(pos) + local n = minetest.get_node(pos) + local param2 = n.param2 local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "left") - minetest.swap_node(p, { name = "mcl_chests:"..canonical_basename.."_right", param2 = param2 }) - else - minetest.swap_node(pos, { name = "mcl_chests:"..canonical_basename.."_small", param2 = param2 }) - create_entity(pos, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest", "chest") - end - end, - after_place_node = function(pos, placer, itemstack, pointed_thing) - minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) - end, - after_dig_node = drop_items_chest, - on_blast = on_chest_blast, - allow_metadata_inventory_move = protection_check_move, - allow_metadata_inventory_take = protection_check_put_take, - allow_metadata_inventory_put = protection_check_put_take, - on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) - minetest.log("action", player:get_player_name().. - " moves stuff in chest at "..minetest.pos_to_string(pos)) - end, - on_metadata_inventory_put = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name().. - " moves stuff to chest at "..minetest.pos_to_string(pos)) - -- BEGIN OF LISTRING WORKAROUND - if listname == "input" then - local inv = minetest.get_inventory({type="node", pos=pos}) - inv:add_item("main", stack) - end - -- END OF LISTRING WORKAROUND - end, - on_metadata_inventory_take = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name().. - " takes stuff from chest at "..minetest.pos_to_string(pos)) - end, - _mcl_blast_resistance = 2.5, - _mcl_hardness = 2.5, + if not p or minetest.get_node(p).name ~= "mcl_chests:"..canonical_basename.."_right" then + n.name = "mcl_chests:"..canonical_basename.."_small" + minetest.swap_node(pos, n) + end + create_entity(pos, left_name, left_textures, param2, true, "default_chest", "mcl_chests_chest", "chest") + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) + end, + on_destruct = function(pos) + local n = minetest.get_node(pos) + if n.name == small_name then + return + end - on_rightclick = function(pos, node, clicker) - if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name].groups.opaque == 1 then - -- won't open if there is no space from the top - return false - end - local name = minetest.get_meta(pos):get_string("name") - if name == "" then - name = S("Chest") - end + close_forms(canonical_basename, pos) - minetest.show_formspec(clicker:get_player_name(), - "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, - "size[9,8.75]".. - "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]".. - "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]".. - mcl_formspec.get_itemslot_bg(0,0.5,9,3).. - "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. - "list[current_player;main;0,4.5;9,3;9]".. - mcl_formspec.get_itemslot_bg(0,4.5,9,3).. - "list[current_player;main;0,7.74;9,1;]".. - mcl_formspec.get_itemslot_bg(0,7.74,9,1).. - "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]".. - "listring[current_player;main]") + local param2 = n.param2 + local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "left") + if not p or minetest.get_node(p).name ~= "mcl_chests:"..basename.."_right" then + return + end + close_forms(canonical_basename, p) - if on_rightclick_addendum then - on_rightclick_addendum(pos, node, clicker) - end - - player_chest_open(clicker, pos, small_name, small_textures, node.param2, false, "default_chest", "mcl_chests_chest") - end, - - on_destruct = function(pos) - close_forms(canonical_basename, pos) - end, - mesecons = mesecons, - on_rotate = simple_rotate, -}) - -minetest.register_node(left_name, { - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = {-0.4375, -0.5, -0.4375, 0.5, 0.375, 0.4375}, - }, - tiles = {"mcl_chests_blank.png"}, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true, - _chest_entity_textures = left_textures, - _chest_entity_sound = "default_chest", - _chest_entity_mesh = "mcl_chests_chest", - _chest_entity_animation_type = "chest", - paramtype = "light", - paramtype2 = "facedir", - groups = {handy=1,axey=1, container=5,not_in_creative_inventory=1, material_wood=1,flammable=-1,chest_entity=1,double_chest=1}, - drop = drop, - is_ground_content = false, - sounds = mcl_sounds.node_sound_wood_defaults(), - on_construct = function(pos) - local n = minetest.get_node(pos) - local param2 = n.param2 - local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "left") - if not p or minetest.get_node(p).name ~= "mcl_chests:"..canonical_basename.."_right" then - n.name = "mcl_chests:"..canonical_basename.."_small" - minetest.swap_node(pos, n) - end - create_entity(pos, left_name, left_textures, param2, true, "default_chest", "mcl_chests_chest", "chest") - end, - after_place_node = function(pos, placer, itemstack, pointed_thing) - minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) - end, - on_destruct = function(pos) - local n = minetest.get_node(pos) - if n.name == small_name then - return - end - - close_forms(canonical_basename, pos) - - local param2 = n.param2 - local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "left") - if not p or minetest.get_node(p).name ~= "mcl_chests:"..basename.."_right" then - return - end - close_forms(canonical_basename, p) - - minetest.swap_node(p, { name = small_name, param2 = param2 }) - create_entity(p, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest", "chest") - end, - after_dig_node = drop_items_chest, - on_blast = on_chest_blast, - allow_metadata_inventory_move = protection_check_move, - allow_metadata_inventory_take = protection_check_put_take, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) - local name = player:get_player_name() - if minetest.is_protected(pos, name) then - minetest.record_protection_violation(pos, name) - return 0 - -- BEGIN OF LISTRING WORKAROUND - elseif listname == "input" then - local inv = minetest.get_inventory({type="node", pos=pos}) - local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "left") - local other_inv = minetest.get_inventory({type="node", pos=other_pos}) - return limit_put(stack, inv, other_inv) - --[[if inv:room_for_item("main", stack) then - return -1 - else - - if other_inv:room_for_item("main", stack) then + minetest.swap_node(p, { name = small_name, param2 = param2 }) + create_entity(p, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest", "chest") + end, + after_dig_node = drop_items_chest, + on_blast = on_chest_blast, + allow_metadata_inventory_move = protection_check_move, + allow_metadata_inventory_take = protection_check_put_take, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + -- BEGIN OF LISTRING WORKAROUND + elseif listname == "input" then + local inv = minetest.get_inventory({type="node", pos=pos}) + local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "left") + local other_inv = minetest.get_inventory({type="node", pos=other_pos}) + return limit_put(stack, inv, other_inv) + --[[if inv:room_for_item("main", stack) then return -1 else - return 0 - end - end]]-- - -- END OF LISTRING WORKAROUND - else - return stack:get_count() - end - end, - on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) - minetest.log("action", player:get_player_name().. - " moves stuff in chest at "..minetest.pos_to_string(pos)) - end, - on_metadata_inventory_put = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name().. - " moves stuff to chest at "..minetest.pos_to_string(pos)) - -- BEGIN OF LISTRING WORKAROUND - if listname == "input" then - local inv = minetest.get_inventory({type="node", pos=pos}) - local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "left") - local other_inv = minetest.get_inventory({type="node", pos=other_pos}) - inv:set_stack("input", 1, nil) - - double_chest_add_item(inv, other_inv, "main", stack) - end - -- END OF LISTRING WORKAROUND - end, - on_metadata_inventory_take = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name().. - " takes stuff from chest at "..minetest.pos_to_string(pos)) - end, - _mcl_blast_resistance = 2.5, - _mcl_hardness = 2.5, - - on_rightclick = function(pos, node, clicker) - local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "left") - if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name].groups.opaque == 1 - or minetest.registered_nodes[minetest.get_node({x = pos_other.x, y = pos_other.y + 1, z = pos_other.z}).name].groups.opaque == 1 then - -- won't open if there is no space from the top - return false - end - - local name = minetest.get_meta(pos):get_string("name") - if name == "" then - name = minetest.get_meta(pos_other):get_string("name") - end - if name == "" then - name = S("Large Chest") - end - - minetest.show_formspec(clicker:get_player_name(), - "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, - "size[9,11.5]".. - "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]".. - "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]".. - mcl_formspec.get_itemslot_bg(0,0.5,9,3).. - "list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,3.5;9,3;]".. - mcl_formspec.get_itemslot_bg(0,3.5,9,3).. - "label[0,7;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. - "list[current_player;main;0,7.5;9,3;9]".. - mcl_formspec.get_itemslot_bg(0,7.5,9,3).. - "list[current_player;main;0,10.75;9,1;]".. - mcl_formspec.get_itemslot_bg(0,10.75,9,1).. - -- BEGIN OF LISTRING WORKAROUND - "listring[current_player;main]".. - "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";input]".. - -- END OF LISTRING WORKAROUND - "listring[current_player;main]".. - "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]".. - "listring[current_player;main]".. - "listring[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main]") - - if on_rightclick_addendum_left then - on_rightclick_addendum_left(pos, node, clicker) - end - - player_chest_open(clicker, pos, left_name, left_textures, node.param2, true, "default_chest", "mcl_chests_chest") - end, - mesecons = mesecons, - on_rotate = no_rotate, -}) - -minetest.register_node("mcl_chests:"..basename.."_right", { - drawtype = "nodebox", - paramtype = "light", - paramtype2 = "facedir", - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, -0.4375, 0.4375, 0.375, 0.4375}, - }, - tiles = {"mcl_chests_blank.png"}, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true, - groups = {handy=1,axey=1, container=6,not_in_creative_inventory=1, material_wood=1,flammable=-1,double_chest=2}, - drop = drop, - is_ground_content = false, - sounds = mcl_sounds.node_sound_wood_defaults(), - on_construct = function(pos) - local n = minetest.get_node(pos) - local param2 = n.param2 - local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right") - if not p or minetest.get_node(p).name ~= "mcl_chests:"..canonical_basename.."_left" then - n.name = "mcl_chests:"..canonical_basename.."_small" - minetest.swap_node(pos, n) - end - end, - after_place_node = function(pos, placer, itemstack, pointed_thing) - minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) - end, - on_destruct = function(pos) - local n = minetest.get_node(pos) - if n.name == small_name then - return - end - - close_forms(canonical_basename, pos) - - local param2 = n.param2 - local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right") - if not p or minetest.get_node(p).name ~= "mcl_chests:"..basename.."_left" then - return - end - close_forms(canonical_basename, p) - - minetest.swap_node(p, { name = small_name, param2 = param2 }) - create_entity(p, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest", "chest") - end, - after_dig_node = drop_items_chest, - on_blast = on_chest_blast, - allow_metadata_inventory_move = protection_check_move, - allow_metadata_inventory_take = protection_check_put_take, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) - local name = player:get_player_name() - if minetest.is_protected(pos, name) then - minetest.record_protection_violation(pos, name) - return 0 - -- BEGIN OF LISTRING WORKAROUND - elseif listname == "input" then - local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "right") - local other_inv = minetest.get_inventory({type="node", pos=other_pos}) - local inv = minetest.get_inventory({type="node", pos=pos}) - --[[if other_inv:room_for_item("main", stack) then - return -1 + if other_inv:room_for_item("main", stack) then + return -1 + else + return 0 + end + end]]-- + -- END OF LISTRING WORKAROUND else - if inv:room_for_item("main", stack) then + return stack:get_count() + end + end, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to chest at "..minetest.pos_to_string(pos)) + -- BEGIN OF LISTRING WORKAROUND + if listname == "input" then + local inv = minetest.get_inventory({type="node", pos=pos}) + local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "left") + local other_inv = minetest.get_inventory({type="node", pos=other_pos}) + + inv:set_stack("input", 1, nil) + + double_chest_add_item(inv, other_inv, "main", stack) + end + -- END OF LISTRING WORKAROUND + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from chest at "..minetest.pos_to_string(pos)) + end, + _mcl_blast_resistance = 2.5, + _mcl_hardness = 2.5, + + on_rightclick = function(pos, node, clicker) + local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "left") + if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name].groups.opaque == 1 + or minetest.registered_nodes[minetest.get_node({x = pos_other.x, y = pos_other.y + 1, z = pos_other.z}).name].groups.opaque == 1 then + -- won't open if there is no space from the top + return false + end + + local name = minetest.get_meta(pos):get_string("name") + if name == "" then + name = minetest.get_meta(pos_other):get_string("name") + end + if name == "" then + name = S("Large Chest") + end + + minetest.show_formspec(clicker:get_player_name(), + "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, + "size[9,11.5]".. + "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]".. + "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]".. + mcl_formspec.get_itemslot_bg(0,0.5,9,3).. + "list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,3.5;9,3;]".. + mcl_formspec.get_itemslot_bg(0,3.5,9,3).. + "label[0,7;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. + "list[current_player;main;0,7.5;9,3;9]".. + mcl_formspec.get_itemslot_bg(0,7.5,9,3).. + "list[current_player;main;0,10.75;9,1;]".. + mcl_formspec.get_itemslot_bg(0,10.75,9,1).. + -- BEGIN OF LISTRING WORKAROUND + "listring[current_player;main]".. + "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";input]".. + -- END OF LISTRING WORKAROUND + "listring[current_player;main]".. + "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]".. + "listring[current_player;main]".. + "listring[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main]") + + if on_rightclick_addendum_left then + on_rightclick_addendum_left(pos, node, clicker) + end + + player_chest_open(clicker, pos, left_name, left_textures, node.param2, true, "default_chest", "mcl_chests_chest") + end, + mesecons = mesecons, + on_rotate = no_rotate, + }) + + minetest.register_node("mcl_chests:"..basename.."_right", { + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.4375, 0.4375, 0.375, 0.4375}, + }, + tiles = {"mcl_chests_blank.png"}, + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true, + groups = {handy=1,axey=1, container=6,not_in_creative_inventory=1, material_wood=1,flammable=-1,double_chest=2}, + drop = drop, + is_ground_content = false, + sounds = mcl_sounds.node_sound_wood_defaults(), + on_construct = function(pos) + local n = minetest.get_node(pos) + local param2 = n.param2 + local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right") + if not p or minetest.get_node(p).name ~= "mcl_chests:"..canonical_basename.."_left" then + n.name = "mcl_chests:"..canonical_basename.."_small" + minetest.swap_node(pos, n) + end + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) + end, + on_destruct = function(pos) + local n = minetest.get_node(pos) + if n.name == small_name then + return + end + + close_forms(canonical_basename, pos) + + local param2 = n.param2 + local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right") + if not p or minetest.get_node(p).name ~= "mcl_chests:"..basename.."_left" then + return + end + close_forms(canonical_basename, p) + + minetest.swap_node(p, { name = small_name, param2 = param2 }) + create_entity(p, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest", "chest") + end, + after_dig_node = drop_items_chest, + on_blast = on_chest_blast, + allow_metadata_inventory_move = protection_check_move, + allow_metadata_inventory_take = protection_check_put_take, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + -- BEGIN OF LISTRING WORKAROUND + elseif listname == "input" then + local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "right") + local other_inv = minetest.get_inventory({type="node", pos=other_pos}) + local inv = minetest.get_inventory({type="node", pos=pos}) + --[[if other_inv:room_for_item("main", stack) then return -1 else - return 0 - end - end--]] - return limit_put(stack, other_inv, inv) - -- END OF LISTRING WORKAROUND - else - return stack:get_count() - end - end, - on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) - minetest.log("action", player:get_player_name().. - " moves stuff in chest at "..minetest.pos_to_string(pos)) - end, - on_metadata_inventory_put = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name().. - " moves stuff to chest at "..minetest.pos_to_string(pos)) - -- BEGIN OF LISTRING WORKAROUND - if listname == "input" then - local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "right") - local other_inv = minetest.get_inventory({type="node", pos=other_pos}) - local inv = minetest.get_inventory({type="node", pos=pos}) + if inv:room_for_item("main", stack) then + return -1 + else + return 0 + end + end--]] + return limit_put(stack, other_inv, inv) + -- END OF LISTRING WORKAROUND + else + return stack:get_count() + end + end, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name().. + " moves stuff in chest at "..minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " moves stuff to chest at "..minetest.pos_to_string(pos)) + -- BEGIN OF LISTRING WORKAROUND + if listname == "input" then + local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "right") + local other_inv = minetest.get_inventory({type="node", pos=other_pos}) + local inv = minetest.get_inventory({type="node", pos=pos}) - inv:set_stack("input", 1, nil) + inv:set_stack("input", 1, nil) - double_chest_add_item(other_inv, inv, "main", stack) - end - -- END OF LISTRING WORKAROUND - end, - on_metadata_inventory_take = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name().. - " takes stuff from chest at "..minetest.pos_to_string(pos)) - end, - _mcl_blast_resistance = 2.5, - _mcl_hardness = 2.5, + double_chest_add_item(other_inv, inv, "main", stack) + end + -- END OF LISTRING WORKAROUND + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name().. + " takes stuff from chest at "..minetest.pos_to_string(pos)) + end, + _mcl_blast_resistance = 2.5, + _mcl_hardness = 2.5, - on_rightclick = function(pos, node, clicker) - local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right") - if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name].groups.opaque == 1 - or minetest.registered_nodes[minetest.get_node({x = pos_other.x, y = pos_other.y + 1, z = pos_other.z}).name].groups.opaque == 1 then - -- won't open if there is no space from the top - return false - end + on_rightclick = function(pos, node, clicker) + local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right") + if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name].groups.opaque == 1 + or minetest.registered_nodes[minetest.get_node({x = pos_other.x, y = pos_other.y + 1, z = pos_other.z}).name].groups.opaque == 1 then + -- won't open if there is no space from the top + return false + end - local name = minetest.get_meta(pos_other):get_string("name") - if name == "" then - name = minetest.get_meta(pos):get_string("name") - end - if name == "" then - name = S("Large Chest") - end + local name = minetest.get_meta(pos_other):get_string("name") + if name == "" then + name = minetest.get_meta(pos):get_string("name") + end + if name == "" then + name = S("Large Chest") + end - minetest.show_formspec(clicker:get_player_name(), - "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, + minetest.show_formspec(clicker:get_player_name(), + "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, - "size[9,11.5]".. - "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]".. - "list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,0.5;9,3;]".. - mcl_formspec.get_itemslot_bg(0,0.5,9,3).. - "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,3.5;9,3;]".. - mcl_formspec.get_itemslot_bg(0,3.5,9,3).. - "label[0,7;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. - "list[current_player;main;0,7.5;9,3;9]".. - mcl_formspec.get_itemslot_bg(0,7.5,9,3).. - "list[current_player;main;0,10.75;9,1;]".. - mcl_formspec.get_itemslot_bg(0,10.75,9,1).. - -- BEGIN OF LISTRING WORKAROUND - "listring[current_player;main]".. - "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";input]".. - -- END OF LISTRING WORKAROUND - "listring[current_player;main]".. - "listring[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main]".. - "listring[current_player;main]".. - "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]") + "size[9,11.5]".. + "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]".. + "list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,0.5;9,3;]".. + mcl_formspec.get_itemslot_bg(0,0.5,9,3).. + "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,3.5;9,3;]".. + mcl_formspec.get_itemslot_bg(0,3.5,9,3).. + "label[0,7;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. + "list[current_player;main;0,7.5;9,3;9]".. + mcl_formspec.get_itemslot_bg(0,7.5,9,3).. + "list[current_player;main;0,10.75;9,1;]".. + mcl_formspec.get_itemslot_bg(0,10.75,9,1).. + -- BEGIN OF LISTRING WORKAROUND + "listring[current_player;main]".. + "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";input]".. + -- END OF LISTRING WORKAROUND + "listring[current_player;main]".. + "listring[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main]".. + "listring[current_player;main]".. + "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]") - if on_rightclick_addendum_right then - on_rightclick_addendum_right(pos, node, clicker) - end + if on_rightclick_addendum_right then + on_rightclick_addendum_right(pos, node, clicker) + end - player_chest_open(clicker, pos_other, left_name, left_textures, node.param2, true, "default_chest", "mcl_chests_chest") - end, - mesecons = mesecons, - on_rotate = no_rotate, -}) + player_chest_open(clicker, pos_other, left_name, left_textures, node.param2, true, "default_chest", "mcl_chests_chest") + end, + mesecons = mesecons, + on_rotate = no_rotate, + }) -if mod_doc then - doc.add_entry_alias("nodes", small_name, "nodes", "mcl_chests:"..basename.."_left") - doc.add_entry_alias("nodes", small_name, "nodes", "mcl_chests:"..basename.."_right") -end + if mod_doc then + doc.add_entry_alias("nodes", small_name, "nodes", "mcl_chests:"..basename.."_left") + doc.add_entry_alias("nodes", small_name, "nodes", "mcl_chests:"..basename.."_right") + end --- END OF register_chest FUNCTION BODY + -- END OF register_chest FUNCTION BODY end local chestusage = S("To access its inventory, rightclick it. When broken, the items will drop out.") @@ -944,23 +944,23 @@ minetest.register_on_leaveplayer(function(player) end) minetest.register_craft({ - output = 'mcl_chests:chest', + output = "mcl_chests:chest", recipe = { - {'group:wood', 'group:wood', 'group:wood'}, - {'group:wood', '', 'group:wood'}, - {'group:wood', 'group:wood', 'group:wood'}, + {"group:wood", "group:wood", "group:wood"}, + {"group:wood", "", "group:wood"}, + {"group:wood", "group:wood", "group:wood"}, } }) minetest.register_craft({ - type = 'fuel', - recipe = 'mcl_chests:chest', + type = "fuel", + recipe = "mcl_chests:chest", burntime = 15 }) minetest.register_craft({ - type = 'fuel', - recipe = 'mcl_chests:trapped_chest', + type = "fuel", + recipe = "mcl_chests:trapped_chest", burntime = 15 }) @@ -1006,7 +1006,7 @@ minetest.register_node("mcl_chests:ender_chest_small", { drawtype = "nodebox", node_box = { type = "fixed", - fixed = {-0.4375, -0.5, -0.4375, 0.5, 0.375, 0.4375}, + fixed = {-0.4375, -0.5, -0.4375, 0.5, 0.375, 0.4375}, }, _chest_entity_textures = {"mcl_chests_ender.png"}, _chest_entity_sound = "mcl_chests_enderchest", @@ -1054,11 +1054,11 @@ minetest.register_on_joinplayer(function(player) end) minetest.register_craft({ - output = 'mcl_chests:ender_chest', + output = "mcl_chests:ender_chest", recipe = { - {'mcl_core:obsidian', 'mcl_core:obsidian', 'mcl_core:obsidian'}, - {'mcl_core:obsidian', 'mcl_end:ender_eye', 'mcl_core:obsidian'}, - {'mcl_core:obsidian', 'mcl_core:obsidian', 'mcl_core:obsidian'}, + {"mcl_core:obsidian", "mcl_core:obsidian", "mcl_core:obsidian"}, + {"mcl_core:obsidian", "mcl_end:ender_eye", "mcl_core:obsidian"}, + {"mcl_core:obsidian", "mcl_core:obsidian", "mcl_core:obsidian"}, } }) @@ -1314,17 +1314,17 @@ for color, desc in pairs(boxtypes) do minetest.register_craft({ type = "shapeless", - output = 'mcl_chests:'..color..'_shulker_box', - recipe = { 'group:shulker_box', 'mcl_dye:'..color } + output = "mcl_chests:"..color.."_shulker_box", + recipe = { "group:shulker_box", "mcl_dye:"..color } }) end minetest.register_craft({ - output = 'mcl_chests:violet_shulker_box', + output = "mcl_chests:violet_shulker_box", recipe = { - {'mcl_mobitems:shulker_shell'}, - {'mcl_chests:chest'}, - {'mcl_mobitems:shulker_shell'}, + {"mcl_mobitems:shulker_shell"}, + {"mcl_chests:chest"}, + {"mcl_mobitems:shulker_shell"}, } }) @@ -1411,10 +1411,10 @@ minetest.register_lbm({ minetest.register_lbm({ label = "Upgrade old ender chest formspec", - name = "mcl_chests:replace_old_ender_form", - nodenames = {"mcl_chests:ender_chest_small"}, - run_at_every_load = false, - action = function(pos, node) + name = "mcl_chests:replace_old_ender_form", + nodenames = {"mcl_chests:ender_chest_small"}, + run_at_every_load = false, + action = function(pos, node) minetest.get_meta(pos):set_string("formspec", "") - end, + end, }) diff --git a/mods/ITEMS/mcl_clock/init.lua b/mods/ITEMS/mcl_clock/init.lua index 0eb83ee80..65b32b91e 100644 --- a/mods/ITEMS/mcl_clock/init.lua +++ b/mods/ITEMS/mcl_clock/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_clock") +local S = minetest.get_translator(minetest.get_current_modname()) --[[ mcl_clock, renew of the renew of the mcl_clock mod @@ -41,7 +41,7 @@ function mcl_clock.get_clock_frame() return tostring(t) end -local doc_mod = minetest.get_modpath("doc") ~= nil +local doc_mod = minetest.get_modpath("doc") -- Register items function mcl_clock.register_item(name, image, creative, frame) @@ -125,9 +125,9 @@ end) minetest.register_craft({ output = mcl_clock.stereotype, recipe = { - {'', 'mcl_core:gold_ingot', ''}, - {'mcl_core:gold_ingot', 'mesecons:redstone', 'mcl_core:gold_ingot'}, - {'', 'mcl_core:gold_ingot', ''} + {"", "mcl_core:gold_ingot", ""}, + {"mcl_core:gold_ingot", "mesecons:redstone", "mcl_core:gold_ingot"}, + {"", "mcl_core:gold_ingot", ""} } }) diff --git a/mods/ITEMS/mcl_cocoas/init.lua b/mods/ITEMS/mcl_cocoas/init.lua index f19f85154..60ea9e573 100644 --- a/mods/ITEMS/mcl_cocoas/init.lua +++ b/mods/ITEMS/mcl_cocoas/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_cocoas") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_cocoas = {} diff --git a/mods/ITEMS/mcl_colorblocks/init.lua b/mods/ITEMS/mcl_colorblocks/init.lua index 4981b39b0..6eec8a9df 100644 --- a/mods/ITEMS/mcl_colorblocks/init.lua +++ b/mods/ITEMS/mcl_colorblocks/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_colorblocks") +local S = minetest.get_translator(minetest.get_current_modname()) local doc_mod = minetest.get_modpath("doc") local block = {} @@ -173,20 +173,20 @@ for _, row in ipairs(block.dyes) do -- Crafting recipes if craft_color_group then minetest.register_craft({ - output = 'mcl_colorblocks:hardened_clay_'..name..' 8', + output = "mcl_colorblocks:hardened_clay_"..name.." 8", recipe = { - {'mcl_colorblocks:hardened_clay', 'mcl_colorblocks:hardened_clay', 'mcl_colorblocks:hardened_clay'}, - {'mcl_colorblocks:hardened_clay', 'mcl_dye:'..craft_color_group, 'mcl_colorblocks:hardened_clay'}, - {'mcl_colorblocks:hardened_clay', 'mcl_colorblocks:hardened_clay', 'mcl_colorblocks:hardened_clay'}, + {"mcl_colorblocks:hardened_clay", "mcl_colorblocks:hardened_clay", "mcl_colorblocks:hardened_clay"}, + {"mcl_colorblocks:hardened_clay", "mcl_dye:"..craft_color_group, "mcl_colorblocks:hardened_clay"}, + {"mcl_colorblocks:hardened_clay", "mcl_colorblocks:hardened_clay", "mcl_colorblocks:hardened_clay"}, }, }) minetest.register_craft({ type = "shapeless", - output = 'mcl_colorblocks:concrete_powder_'..name..' 8', + output = "mcl_colorblocks:concrete_powder_"..name.." 8", recipe = { - 'mcl_core:sand', 'mcl_core:gravel', 'mcl_core:sand', - 'mcl_core:gravel', 'mcl_dye:'..craft_color_group, 'mcl_core:gravel', - 'mcl_core:sand', 'mcl_core:gravel', 'mcl_core:sand', + "mcl_core:sand", "mcl_core:gravel", "mcl_core:sand", + "mcl_core:gravel", "mcl_dye:"..craft_color_group, "mcl_core:gravel", + "mcl_core:sand", "mcl_core:gravel", "mcl_core:sand", } }) diff --git a/mods/ITEMS/mcl_compass/init.lua b/mods/ITEMS/mcl_compass/init.lua index 31944fa88..458ee8fdb 100644 --- a/mods/ITEMS/mcl_compass/init.lua +++ b/mods/ITEMS/mcl_compass/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_compass") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_compass = {} @@ -72,7 +72,7 @@ for frame = 0, compass_frames-1 do table.insert(images, "mcl_compass_compass_"..s..".png") end -local doc_mod = minetest.get_modpath("doc") ~= nil +local doc_mod = minetest.get_modpath("doc") local stereotype_frame = 18 for i,img in ipairs(images) do @@ -108,11 +108,11 @@ for i,img in ipairs(images) do end minetest.register_craft({ - output = 'mcl_compass:'..stereotype_frame, + output = "mcl_compass:"..stereotype_frame, recipe = { - {'', 'mcl_core:iron_ingot', ''}, - {'mcl_core:iron_ingot', 'mesecons:redstone', 'mcl_core:iron_ingot'}, - {'', 'mcl_core:iron_ingot', ''} + {"", "mcl_core:iron_ingot", ""}, + {"mcl_core:iron_ingot", "mesecons:redstone", "mcl_core:iron_ingot"}, + {"", "mcl_core:iron_ingot", ""} } }) diff --git a/mods/ITEMS/mcl_core/crafting.lua b/mods/ITEMS/mcl_core/crafting.lua index cec26e747..3ff2b142c 100644 --- a/mods/ITEMS/mcl_core/crafting.lua +++ b/mods/ITEMS/mcl_core/crafting.lua @@ -30,96 +30,96 @@ for _, p in pairs(planks) do end minetest.register_craft({ - type = 'shapeless', - output = 'mcl_core:mossycobble', - recipe = { 'mcl_core:cobble', 'mcl_core:vine' }, + type = "shapeless", + output = "mcl_core:mossycobble", + recipe = { "mcl_core:cobble", "mcl_core:vine" }, }) minetest.register_craft({ - type = 'shapeless', - output = 'mcl_core:stonebrickmossy', - recipe = { 'mcl_core:stonebrick', 'mcl_core:vine' }, + type = "shapeless", + output = "mcl_core:stonebrickmossy", + recipe = { "mcl_core:stonebrick", "mcl_core:vine" }, }) minetest.register_craft({ - output = 'mcl_core:coarse_dirt 4', + output = "mcl_core:coarse_dirt 4", recipe = { - {'mcl_core:dirt', 'mcl_core:gravel'}, - {'mcl_core:gravel', 'mcl_core:dirt'}, + {"mcl_core:dirt", "mcl_core:gravel"}, + {"mcl_core:gravel", "mcl_core:dirt"}, } }) minetest.register_craft({ - output = 'mcl_core:coarse_dirt 4', + output = "mcl_core:coarse_dirt 4", recipe = { - {'mcl_core:gravel', 'mcl_core:dirt'}, - {'mcl_core:dirt', 'mcl_core:gravel'}, + {"mcl_core:gravel", "mcl_core:dirt"}, + {"mcl_core:dirt", "mcl_core:gravel"}, } }) minetest.register_craft({ - output = 'mcl_core:sandstonesmooth 4', + output = "mcl_core:sandstonesmooth 4", recipe = { - {'mcl_core:sandstone','mcl_core:sandstone'}, - {'mcl_core:sandstone','mcl_core:sandstone'}, + {"mcl_core:sandstone","mcl_core:sandstone"}, + {"mcl_core:sandstone","mcl_core:sandstone"}, } }) minetest.register_craft({ - output = 'mcl_core:redsandstonesmooth 4', + output = "mcl_core:redsandstonesmooth 4", recipe = { - {'mcl_core:redsandstone','mcl_core:redsandstone'}, - {'mcl_core:redsandstone','mcl_core:redsandstone'}, + {"mcl_core:redsandstone","mcl_core:redsandstone"}, + {"mcl_core:redsandstone","mcl_core:redsandstone"}, } }) minetest.register_craft({ - output = 'mcl_core:granite_smooth 4', + output = "mcl_core:granite_smooth 4", recipe = { - {'mcl_core:granite', 'mcl_core:granite'}, - {'mcl_core:granite', 'mcl_core:granite'} + {"mcl_core:granite", "mcl_core:granite"}, + {"mcl_core:granite", "mcl_core:granite"} }, }) minetest.register_craft({ - output = 'mcl_core:andesite_smooth 4', + output = "mcl_core:andesite_smooth 4", recipe = { - {'mcl_core:andesite', 'mcl_core:andesite'}, - {'mcl_core:andesite', 'mcl_core:andesite'} + {"mcl_core:andesite", "mcl_core:andesite"}, + {"mcl_core:andesite", "mcl_core:andesite"} }, }) minetest.register_craft({ - output = 'mcl_core:diorite_smooth 4', + output = "mcl_core:diorite_smooth 4", recipe = { - {'mcl_core:diorite', 'mcl_core:diorite'}, - {'mcl_core:diorite', 'mcl_core:diorite'} + {"mcl_core:diorite", "mcl_core:diorite"}, + {"mcl_core:diorite", "mcl_core:diorite"} }, }) minetest.register_craft({ type = "shapeless", - output = 'mcl_core:granite', - recipe = {'mcl_core:diorite', 'mcl_nether:quartz'}, + output = "mcl_core:granite", + recipe = {"mcl_core:diorite", "mcl_nether:quartz"}, }) minetest.register_craft({ type = "shapeless", - output = 'mcl_core:andesite 2', - recipe = {'mcl_core:diorite', 'mcl_core:cobble'}, + output = "mcl_core:andesite 2", + recipe = {"mcl_core:diorite", "mcl_core:cobble"}, }) minetest.register_craft({ - output = 'mcl_core:diorite 2', + output = "mcl_core:diorite 2", recipe = { - {'mcl_core:cobble', 'mcl_nether:quartz'}, - {'mcl_nether:quartz', 'mcl_core:cobble'}, + {"mcl_core:cobble", "mcl_nether:quartz"}, + {"mcl_nether:quartz", "mcl_core:cobble"}, } }) minetest.register_craft({ - output = 'mcl_core:diorite 2', + output = "mcl_core:diorite 2", recipe = { - {'mcl_nether:quartz', 'mcl_core:cobble'}, - {'mcl_core:cobble', 'mcl_nether:quartz'}, + {"mcl_nether:quartz", "mcl_core:cobble"}, + {"mcl_core:cobble", "mcl_nether:quartz"}, } }) @@ -140,60 +140,60 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'mcl_core:stick 4', + output = "mcl_core:stick 4", recipe = { - {'group:wood'}, - {'group:wood'}, + {"group:wood"}, + {"group:wood"}, } }) minetest.register_craft({ - output = 'mcl_core:coalblock', + output = "mcl_core:coalblock", recipe = { - {'mcl_core:coal_lump', 'mcl_core:coal_lump', 'mcl_core:coal_lump'}, - {'mcl_core:coal_lump', 'mcl_core:coal_lump', 'mcl_core:coal_lump'}, - {'mcl_core:coal_lump', 'mcl_core:coal_lump', 'mcl_core:coal_lump'}, + {"mcl_core:coal_lump", "mcl_core:coal_lump", "mcl_core:coal_lump"}, + {"mcl_core:coal_lump", "mcl_core:coal_lump", "mcl_core:coal_lump"}, + {"mcl_core:coal_lump", "mcl_core:coal_lump", "mcl_core:coal_lump"}, } }) minetest.register_craft({ - output = 'mcl_core:coal_lump 9', + output = "mcl_core:coal_lump 9", recipe = { - {'mcl_core:coalblock'}, + {"mcl_core:coalblock"}, } }) minetest.register_craft({ - output = 'mcl_core:ironblock', + output = "mcl_core:ironblock", recipe = { - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"}, } }) minetest.register_craft({ - output = 'mcl_core:iron_ingot 9', + output = "mcl_core:iron_ingot 9", recipe = { - {'mcl_core:ironblock'}, + {"mcl_core:ironblock"}, } }) minetest.register_craft({ - output = 'mcl_core:goldblock', + output = "mcl_core:goldblock", recipe = { - {'mcl_core:gold_ingot', 'mcl_core:gold_ingot', 'mcl_core:gold_ingot'}, - {'mcl_core:gold_ingot', 'mcl_core:gold_ingot', 'mcl_core:gold_ingot'}, - {'mcl_core:gold_ingot', 'mcl_core:gold_ingot', 'mcl_core:gold_ingot'}, + {"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"}, + {"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"}, + {"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"}, } }) minetest.register_craft({ - output = 'mcl_core:gold_ingot 9', + output = "mcl_core:gold_ingot 9", recipe = { - {'mcl_core:goldblock'}, + {"mcl_core:goldblock"}, } }) @@ -227,119 +227,119 @@ minetest.register_craft({ minetest.register_craft({ type = "cooking", - output = 'mcl_core:iron_nugget', - recipe = 'mobs_mc:iron_horse_armor', + output = "mcl_core:iron_nugget", + recipe = "mobs_mc:iron_horse_armor", cooktime = 10, }) minetest.register_craft({ type = "cooking", - output = 'mcl_core:gold_nugget', - recipe = 'mobs_mc:gold_horse_armor', + output = "mcl_core:gold_nugget", + recipe = "mobs_mc:gold_horse_armor", cooktime = 10, }) minetest.register_craft({ - output = 'mcl_core:sandstone', + output = "mcl_core:sandstone", recipe = { - {'mcl_core:sand', 'mcl_core:sand'}, - {'mcl_core:sand', 'mcl_core:sand'}, + {"mcl_core:sand", "mcl_core:sand"}, + {"mcl_core:sand", "mcl_core:sand"}, } }) minetest.register_craft({ - output = 'mcl_core:redsandstone', + output = "mcl_core:redsandstone", recipe = { - {'mcl_core:redsand', 'mcl_core:redsand'}, - {'mcl_core:redsand', 'mcl_core:redsand'}, + {"mcl_core:redsand", "mcl_core:redsand"}, + {"mcl_core:redsand", "mcl_core:redsand"}, } }) minetest.register_craft({ - output = 'mcl_core:clay', + output = "mcl_core:clay", recipe = { - {'mcl_core:clay_lump', 'mcl_core:clay_lump'}, - {'mcl_core:clay_lump', 'mcl_core:clay_lump'}, + {"mcl_core:clay_lump", "mcl_core:clay_lump"}, + {"mcl_core:clay_lump", "mcl_core:clay_lump"}, } }) minetest.register_craft({ - output = 'mcl_core:brick_block', + output = "mcl_core:brick_block", recipe = { - {'mcl_core:brick', 'mcl_core:brick'}, - {'mcl_core:brick', 'mcl_core:brick'}, + {"mcl_core:brick", "mcl_core:brick"}, + {"mcl_core:brick", "mcl_core:brick"}, } }) minetest.register_craft({ - output = 'mcl_core:paper 3', + output = "mcl_core:paper 3", recipe = { - {'mcl_core:reeds', 'mcl_core:reeds', 'mcl_core:reeds'}, + {"mcl_core:reeds", "mcl_core:reeds", "mcl_core:reeds"}, } }) minetest.register_craft({ - output = 'mcl_core:ladder 3', + output = "mcl_core:ladder 3", recipe = { - {'mcl_core:stick', '', 'mcl_core:stick'}, - {'mcl_core:stick', 'mcl_core:stick', 'mcl_core:stick'}, - {'mcl_core:stick', '', 'mcl_core:stick'}, + {"mcl_core:stick", "", "mcl_core:stick"}, + {"mcl_core:stick", "mcl_core:stick", "mcl_core:stick"}, + {"mcl_core:stick", "", "mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_core:stonebrick 4', + output = "mcl_core:stonebrick 4", recipe = { - {'mcl_core:stone', 'mcl_core:stone'}, - {'mcl_core:stone', 'mcl_core:stone'}, + {"mcl_core:stone", "mcl_core:stone"}, + {"mcl_core:stone", "mcl_core:stone"}, } }) minetest.register_craft({ - output = 'mcl_core:lapisblock', + output = "mcl_core:lapisblock", recipe = { - {'mcl_dye:blue', 'mcl_dye:blue', 'mcl_dye:blue'}, - {'mcl_dye:blue', 'mcl_dye:blue', 'mcl_dye:blue'}, - {'mcl_dye:blue', 'mcl_dye:blue', 'mcl_dye:blue'}, + {"mcl_dye:blue", "mcl_dye:blue", "mcl_dye:blue"}, + {"mcl_dye:blue", "mcl_dye:blue", "mcl_dye:blue"}, + {"mcl_dye:blue", "mcl_dye:blue", "mcl_dye:blue"}, } }) minetest.register_craft({ - output = 'mcl_dye:blue 9', + output = "mcl_dye:blue 9", recipe = { - {'mcl_core:lapisblock'}, + {"mcl_core:lapisblock"}, } }) minetest.register_craft({ output = "mcl_core:emeraldblock", recipe = { - {'mcl_core:emerald', 'mcl_core:emerald', 'mcl_core:emerald'}, - {'mcl_core:emerald', 'mcl_core:emerald', 'mcl_core:emerald'}, - {'mcl_core:emerald', 'mcl_core:emerald', 'mcl_core:emerald'}, + {"mcl_core:emerald", "mcl_core:emerald", "mcl_core:emerald"}, + {"mcl_core:emerald", "mcl_core:emerald", "mcl_core:emerald"}, + {"mcl_core:emerald", "mcl_core:emerald", "mcl_core:emerald"}, } }) minetest.register_craft({ - output = 'mcl_core:emerald 9', + output = "mcl_core:emerald 9", recipe = { - {'mcl_core:emeraldblock'}, + {"mcl_core:emeraldblock"}, } }) minetest.register_craft({ output = "mcl_core:diamondblock", recipe = { - {'mcl_core:diamond', 'mcl_core:diamond', 'mcl_core:diamond'}, - {'mcl_core:diamond', 'mcl_core:diamond', 'mcl_core:diamond'}, - {'mcl_core:diamond', 'mcl_core:diamond', 'mcl_core:diamond'}, + {"mcl_core:diamond", "mcl_core:diamond", "mcl_core:diamond"}, + {"mcl_core:diamond", "mcl_core:diamond", "mcl_core:diamond"}, + {"mcl_core:diamond", "mcl_core:diamond", "mcl_core:diamond"}, } }) minetest.register_craft({ - output = 'mcl_core:diamond 9', + output = "mcl_core:diamond 9", recipe = { - {'mcl_core:diamondblock'}, + {"mcl_core:diamondblock"}, } }) @@ -347,7 +347,7 @@ minetest.register_craft({ output = "mcl_core:apple_gold", recipe = { {"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"}, - {"mcl_core:gold_ingot", 'mcl_core:apple', "mcl_core:gold_ingot"}, + {"mcl_core:gold_ingot", "mcl_core:apple", "mcl_core:gold_ingot"}, {"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"}, } }) @@ -368,17 +368,17 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'mcl_core:snowblock', + output = "mcl_core:snowblock", recipe = { - {'mcl_throwing:snowball', 'mcl_throwing:snowball'}, - {'mcl_throwing:snowball', 'mcl_throwing:snowball'}, + {"mcl_throwing:snowball", "mcl_throwing:snowball"}, + {"mcl_throwing:snowball", "mcl_throwing:snowball"}, } }) minetest.register_craft({ - output = 'mcl_core:snow 6', + output = "mcl_core:snow 6", recipe = { - {'mcl_core:snowblock', 'mcl_core:snowblock', 'mcl_core:snowblock'}, + {"mcl_core:snowblock", "mcl_core:snowblock", "mcl_core:snowblock"}, } }) diff --git a/mods/ITEMS/mcl_core/craftitems.lua b/mods/ITEMS/mcl_core/craftitems.lua index 886535473..03f30b7b9 100644 --- a/mods/ITEMS/mcl_core/craftitems.lua +++ b/mods/ITEMS/mcl_core/craftitems.lua @@ -1,6 +1,6 @@ -- mods/default/craftitems.lua -local S = minetest.get_translator("mcl_core") +local S = minetest.get_translator(minetest.get_current_modname()) -- -- Crafting items diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index f66240b94..f0633914b 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -2,8 +2,13 @@ -- Lava vs water interactions -- +local modpath = minetest.get_modpath(minetest.get_current_modname()) + local mg_name = minetest.get_mapgen_setting("mg_name") +local math = math +local vector = vector + local OAK_TREE_ID = 1 local DARK_OAK_TREE_ID = 2 local SPRUCE_TREE_ID = 3 @@ -247,7 +252,7 @@ end -- Check if a node stops a tree from growing. Torches, plants, wood, tree, -- leaves and dirt does not affect tree growth. local function node_stops_growth(node) - if node.name == 'air' then + if node.name == "air" then return false end @@ -457,12 +462,12 @@ function mcl_core.generate_balloon_oak_tree(pos) local s = math.random(1, 12) if s == 1 then -- Small balloon oak - path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_oak_balloon.mts" + path = modpath .. "/schematics/mcl_core_oak_balloon.mts" offset = { x = -2, y = -1, z = -2 } else -- Large balloon oak local t = math.random(1, 4) - path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_oak_large_"..t..".mts" + path = modpath .. "/schematics/mcl_core_oak_large_"..t..".mts" if t == 1 or t == 3 then offset = { x = -3, y = -1, z = -3 } elseif t == 2 or t == 4 then @@ -473,16 +478,16 @@ function mcl_core.generate_balloon_oak_tree(pos) end -- Oak -function mcl_core.generate_oak_tree(pos) - local path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_oak_classic.mts" - local offset = { x = -2, y = -1, z = -2 } +local path_oak_tree = modpath.."/schematics/mcl_core_oak_classic.mts" - minetest.place_schematic(vector.add(pos, offset), path, "random", nil, false) +function mcl_core.generate_oak_tree(pos) + local offset = { x = -2, y = -1, z = -2 } + minetest.place_schematic(vector.add(pos, offset), path_oak_tree, "random", nil, false) end -- Birch function mcl_core.generate_birch_tree(pos) - local path = minetest.get_modpath("mcl_core") .. + local path = modpath .. "/schematics/mcl_core_birch.mts" minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, path, "random", nil, false) end @@ -596,7 +601,7 @@ end function mcl_core.generate_spruce_tree(pos) local r = math.random(1, 3) - local path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_spruce_"..r..".mts" + local path = modpath .. "/schematics/mcl_core_spruce_"..r..".mts" minetest.place_schematic({ x = pos.x - 3, y = pos.y - 1, z = pos.z - 3 }, path, "0", nil, false) end @@ -607,13 +612,13 @@ function mcl_core.generate_huge_spruce_tree(pos) local offset = { x = -4, y = -1, z = -5 } if r1 <= 2 then -- Mega Spruce Taiga (full canopy) - path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_spruce_huge_"..r2..".mts" + path = modpath.."/schematics/mcl_core_spruce_huge_"..r2..".mts" else -- Mega Taiga (leaves only at top) if r2 == 1 or r2 == 3 then offset = { x = -3, y = -1, z = -4} end - path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_spruce_huge_up_"..r2..".mts" + path = modpath.."/schematics/mcl_core_spruce_huge_up_"..r2..".mts" end minetest.place_schematic(vector.add(pos, offset), path, "0", nil, false) end @@ -631,15 +636,14 @@ function mcl_core.generate_acacia_tree(pos) elseif r == 1 or r == 5 then offset = { x = -5, y = -1, z = -5 } end - local path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_acacia_"..r..".mts" + local path = modpath.."/schematics/mcl_core_acacia_"..r..".mts" minetest.place_schematic(vector.add(pos, offset), path, "random", nil, false) end -- Generate dark oak tree with 2×2 trunk. -- With pos being the lower X and the higher Z value of the trunk function mcl_core.generate_dark_oak_tree(pos) - local path = minetest.get_modpath("mcl_core") .. - "/schematics/mcl_core_dark_oak.mts" + local path = modpath.."/schematics/mcl_core_dark_oak.mts" minetest.place_schematic({x = pos.x - 3, y = pos.y - 1, z = pos.z - 4}, path, "random", nil, false) end @@ -739,8 +743,7 @@ function mcl_core.generate_v6_jungle_tree(pos) end function mcl_core.generate_jungle_tree(pos) - local path = minetest.get_modpath("mcl_core") .. - "/schematics/mcl_core_jungle_tree.mts" + local path = modpath.."/schematics/mcl_core_jungle_tree.mts" minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, path, "random", nil, false) end @@ -749,8 +752,7 @@ end function mcl_core.generate_huge_jungle_tree(pos) -- 2 variants local r = math.random(1, 2) - local path = minetest.get_modpath("mcl_core") .. - "/schematics/mcl_core_jungle_tree_huge_"..r..".mts" + local path = modpath.."/schematics/mcl_core_jungle_tree_huge_"..r..".mts" minetest.place_schematic({x = pos.x - 6, y = pos.y - 1, z = pos.z - 7}, path, "random", nil, false) end @@ -1335,9 +1337,8 @@ mcl_core.leafdecay_enable_cache = true mcl_core.leafdecay_trunk_find_allow_accumulator = 0 minetest.register_globalstep(function(dtime) - local finds_per_second = 5000 - mcl_core.leafdecay_trunk_find_allow_accumulator = - math.floor(dtime * finds_per_second) + --local finds_per_second = 5000 + mcl_core.leafdecay_trunk_find_allow_accumulator = math.floor(dtime * 5000) end) minetest.register_abm({ diff --git a/mods/ITEMS/mcl_core/init.lua b/mods/ITEMS/mcl_core/init.lua index 897382e01..c345d057b 100644 --- a/mods/ITEMS/mcl_core/init.lua +++ b/mods/ITEMS/mcl_core/init.lua @@ -17,7 +17,7 @@ mcl_autogroup.register_diggroup("swordy_cobweb") mcl_autogroup.register_diggroup("hoey") -- Load files -local modpath = minetest.get_modpath("mcl_core") +local modpath = minetest.get_modpath(minetest.get_current_modname()) dofile(modpath.."/functions.lua") dofile(modpath.."/nodes_base.lua") -- Simple solid cubic nodes with simple definitions dofile(modpath.."/nodes_liquid.lua") -- Liquids diff --git a/mods/ITEMS/mcl_core/nodes_base.lua b/mods/ITEMS/mcl_core/nodes_base.lua index 9baa6c33e..d4bfd7636 100644 --- a/mods/ITEMS/mcl_core/nodes_base.lua +++ b/mods/ITEMS/mcl_core/nodes_base.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_core") +local S = minetest.get_translator(minetest.get_current_modname()) -- Simple solid cubic nodes, most of them are the ground materials and simple building blocks @@ -16,7 +16,7 @@ mcl_core.fortune_drop_ore = { discrete_uniform_distribution = true, min_count = 2, max_count = 1, - get_chance = function (fortune_level) return 1 - 2 / (fortune_level + 2) end, + get_chance = function(fortune_level) return 1 - 2 / (fortune_level + 2) end, multiply = true, } @@ -28,7 +28,7 @@ minetest.register_node("mcl_core:stone", { is_ground_content = true, stack_max = 64, groups = {pickaxey=1, stone=1, building_block=1, material_stone=1}, - drop = 'mcl_core:cobble', + drop = "mcl_core:cobble", sounds = mcl_sounds.node_sound_stone_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 1.5, @@ -48,7 +48,7 @@ minetest.register_node("mcl_core:stone_with_coal", { is_ground_content = true, stack_max = 64, groups = {pickaxey=1, building_block=1, material_stone=1, xp=1}, - drop = 'mcl_core:coal_lump', + drop = "mcl_core:coal_lump", sounds = mcl_sounds.node_sound_stone_defaults(), _mcl_blast_resistance = 3, _mcl_hardness = 3, @@ -63,7 +63,7 @@ minetest.register_node("mcl_core:stone_with_iron", { is_ground_content = true, stack_max = 64, groups = {pickaxey=3, building_block=1, material_stone=1}, - drop = 'mcl_core:stone_with_iron', + drop = "mcl_core:stone_with_iron", sounds = mcl_sounds.node_sound_stone_defaults(), _mcl_blast_resistance = 3, _mcl_hardness = 3, @@ -179,11 +179,11 @@ minetest.register_node("mcl_core:stone_with_lapis", { drop = { max_items = 1, items = { - {items = {'mcl_dye:blue 8'},rarity = 5}, - {items = {'mcl_dye:blue 7'},rarity = 5}, - {items = {'mcl_dye:blue 6'},rarity = 5}, - {items = {'mcl_dye:blue 5'},rarity = 5}, - {items = {'mcl_dye:blue 4'}}, + {items = {"mcl_dye:blue 8"},rarity = 5}, + {items = {"mcl_dye:blue 7"},rarity = 5}, + {items = {"mcl_dye:blue 6"},rarity = 5}, + {items = {"mcl_dye:blue 5"},rarity = 5}, + {items = {"mcl_dye:blue 4"}}, } }, sounds = mcl_sounds.node_sound_stone_defaults(), @@ -369,7 +369,7 @@ minetest.register_node("mcl_core:dirt_with_grass", { is_ground_content = true, stack_max = 64, groups = {handy=1,shovely=1,dirt=2,grass_block=1, grass_block_no_snow=1, soil=1, soil_sapling=2, soil_sugarcane=1, cultivatable=2, spreading_dirt_type=1, enderman_takable=1, building_block=1}, - drop = 'mcl_core:dirt', + drop = "mcl_core:dirt", sounds = mcl_sounds.node_sound_dirt_defaults({ footstep = {name="default_grass_footstep", gain=0.1}, }), @@ -422,7 +422,7 @@ minetest.register_node("mcl_core:mycelium", { is_ground_content = true, stack_max = 64, groups = {handy=1,shovely=1, dirt=2,spreading_dirt_type=1, enderman_takable=1, building_block=1}, - drop = 'mcl_core:dirt', + drop = "mcl_core:dirt", sounds = mcl_sounds.node_sound_dirt_defaults({ footstep = {name="default_grass_footstep", gain=0.1}, }), @@ -442,7 +442,7 @@ minetest.register_node("mcl_core:podzol", { is_ground_content = true, stack_max = 64, groups = {handy=1,shovely=3, dirt=2,soil=1, soil_sapling=2, soil_sugarcane=1, enderman_takable=1, building_block=1}, - drop = 'mcl_core:dirt', + drop = "mcl_core:dirt", sounds = mcl_sounds.node_sound_dirt_defaults(), on_construct = mcl_core.on_snowable_construct, _mcl_snowed = "mcl_core:podzol_snow", @@ -487,8 +487,8 @@ minetest.register_node("mcl_core:gravel", { drop = { max_items = 1, items = { - {items = {'mcl_core:flint'},rarity = 10}, - {items = {'mcl_core:gravel'}} + {items = {"mcl_core:flint"},rarity = 10}, + {items = {"mcl_core:gravel"}} } }, sounds = mcl_sounds.node_sound_dirt_defaults({ @@ -501,15 +501,15 @@ minetest.register_node("mcl_core:gravel", { [1] = { max_items = 1, items = { - {items = {'mcl_core:flint'},rarity = 7}, - {items = {'mcl_core:gravel'}} + {items = {"mcl_core:flint"},rarity = 7}, + {items = {"mcl_core:gravel"}} } }, [2] = { max_items = 1, items = { - {items = {'mcl_core:flint'},rarity = 4}, - {items = {'mcl_core:gravel'}} + {items = {"mcl_core:flint"},rarity = 4}, + {items = {"mcl_core:gravel"}} } }, [3] = "mcl_core:flint", @@ -652,7 +652,7 @@ minetest.register_node("mcl_core:clay", { is_ground_content = true, stack_max = 64, groups = {handy=1,shovely=1, enderman_takable=1, building_block=1}, - drop = 'mcl_core:clay_lump 4', + drop = "mcl_core:clay_lump 4", sounds = mcl_sounds.node_sound_dirt_defaults(), _mcl_blast_resistance = 0.6, _mcl_hardness = 0.6, @@ -683,7 +683,7 @@ minetest.register_node("mcl_core:bedrock", { sounds = mcl_sounds.node_sound_stone_defaults(), is_ground_content = false, on_blast = function() end, - drop = '', + drop = "", _mcl_blast_resistance = 3600000, _mcl_hardness = -1, @@ -955,7 +955,7 @@ for i=1,8 do fixed = { -0.5, -0.5, -0.5, 0.5, -0.5 + (2*i)/16, 0.5 }, } end - local on_place = function(itemstack, placer, pointed_thing) + local function on_place(itemstack, placer, pointed_thing) -- Placement is only allowed on top of solid blocks if pointed_thing.type ~= "node" then -- no interaction possible with entities diff --git a/mods/ITEMS/mcl_core/nodes_cactuscane.lua b/mods/ITEMS/mcl_core/nodes_cactuscane.lua index 4ec005170..839102534 100644 --- a/mods/ITEMS/mcl_core/nodes_cactuscane.lua +++ b/mods/ITEMS/mcl_core/nodes_cactuscane.lua @@ -1,6 +1,6 @@ -- Cactus and Sugar Cane -local S = minetest.get_translator("mcl_core") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_node("mcl_core:cactus", { description = S("Cactus"), diff --git a/mods/ITEMS/mcl_core/nodes_climb.lua b/mods/ITEMS/mcl_core/nodes_climb.lua index ad861b4f2..9505bb19a 100644 --- a/mods/ITEMS/mcl_core/nodes_climb.lua +++ b/mods/ITEMS/mcl_core/nodes_climb.lua @@ -1,5 +1,5 @@ -- Climbable nodes -local S = minetest.get_translator("mcl_core") +local S = minetest.get_translator(minetest.get_current_modname()) local function rotate_climbable(pos, node, user, mode) if mode == screwdriver.ROTATE_FACE then diff --git a/mods/ITEMS/mcl_core/nodes_glass.lua b/mods/ITEMS/mcl_core/nodes_glass.lua index 8c12d8b93..6e7ab350b 100644 --- a/mods/ITEMS/mcl_core/nodes_glass.lua +++ b/mods/ITEMS/mcl_core/nodes_glass.lua @@ -1,5 +1,5 @@ -- Glass nodes -local S = minetest.get_translator("mcl_core") +local S = minetest.get_translator(minetest.get_current_modname()) local mod_doc = minetest.get_modpath("doc") minetest.register_node("mcl_core:glass", { @@ -56,11 +56,11 @@ function mcl_core.add_stained_glass(desc, recipeitem, colorgroup, color) }) minetest.register_craft({ - output = 'mcl_core:glass_'..color..' 8', + output = "mcl_core:glass_"..color.." 8", recipe = { - {'mcl_core:glass','mcl_core:glass','mcl_core:glass'}, - {'mcl_core:glass',recipeitem,'mcl_core:glass'}, - {'mcl_core:glass','mcl_core:glass','mcl_core:glass'}, + {"mcl_core:glass","mcl_core:glass","mcl_core:glass"}, + {"mcl_core:glass",recipeitem,"mcl_core:glass"}, + {"mcl_core:glass","mcl_core:glass","mcl_core:glass"}, } }) diff --git a/mods/ITEMS/mcl_core/nodes_liquid.lua b/mods/ITEMS/mcl_core/nodes_liquid.lua index 42276685e..0e0f71a11 100644 --- a/mods/ITEMS/mcl_core/nodes_liquid.lua +++ b/mods/ITEMS/mcl_core/nodes_liquid.lua @@ -1,7 +1,6 @@ -- Liquids: Water and lava -local S = minetest.get_translator("mcl_core") -local N = function(s) return s end +local S = minetest.get_translator(minetest.get_current_modname()) local vector = vector local math = math @@ -16,13 +15,6 @@ if minetest.features.use_texture_alpha_string_modes then USE_TEXTURE_ALPHA = "blend" end -local lava_death_messages = { - N("@1 melted in lava."), - N("@1 took a bath in a hot lava tub."), - N("@1 died in lava."), - N("@1 could not survive in lava."), -} - minetest.register_node("mcl_core:water_flowing", { description = S("Flowing Water"), _doc_items_create_entry = false, @@ -148,7 +140,6 @@ minetest.register_node("mcl_core:lava_flowing", { liquid_renewable = false, liquid_range = 3, damage_per_second = 4*2, - _mcl_node_death_message = lava_death_messages, post_effect_color = {a=245, r=208, g=73, b=10}, groups = { lava=3, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1, set_on_fire=15}, _mcl_blast_resistance = 100, @@ -203,7 +194,6 @@ S("• When lava is directly above water, the water turns into stone."), liquid_renewable = false, liquid_range = 3, damage_per_second = 4*2, - _mcl_node_death_message = lava_death_messages, post_effect_color = {a=245, r=208, g=73, b=10}, stack_max = 64, groups = { lava=3, lava_source=1, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1, set_on_fire=15, fire_damage=1}, diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index a8188350a..67669a861 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -1,11 +1,13 @@ -- Other nodes -local S = minetest.get_translator("mcl_core") +local S = minetest.get_translator(minetest.get_current_modname()) + +local mod_screwdriver = minetest.get_modpath("screwdriver") -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil local on_rotate if mod_screwdriver then on_rotate = screwdriver.rotate_3way end + local alldirs = {{x=0,y=0,z=1}, {x=1,y=0,z=0}, {x=0,y=0,z=-1}, {x=-1,y=0,z=0}, {x=0,y=-1,z=0}, {x=0,y=1,z=0}} minetest.register_node("mcl_core:bone_block", { @@ -52,7 +54,7 @@ minetest.register_node("mcl_core:slimeblock", { }, _mcl_blast_resistance = 0, _mcl_hardness = 0, - mvps_sticky = function (pos, node, piston_pos) + mvps_sticky = function(pos, node, piston_pos) local connected = {} for n, v in ipairs(alldirs) do local neighbor_pos = vector.add(pos, v) @@ -172,7 +174,7 @@ minetest.register_node("mcl_core:barrier", { drop = "", _mcl_blast_resistance = 36000008, _mcl_hardness = -1, - after_place_node = function (pos, placer, itemstack, pointed_thing) + after_place_node = function(pos, placer, itemstack, pointed_thing) if placer == nil then return end diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index a72935f05..c73829d6c 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -1,7 +1,8 @@ -- Tree nodes: Wood, Wooden Planks, Sapling, Leaves, Stripped Wood -local S = minetest.get_translator("mcl_core") +local S = minetest.get_translator(minetest.get_current_modname()) + +local mod_screwdriver = minetest.get_modpath("screwdriver") -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil local on_rotate if mod_screwdriver then on_rotate = screwdriver.rotate_3way @@ -51,7 +52,7 @@ local function register_tree_trunk(subname, description_trunk, description_bark, end -- Register stripped trunk and stripped wood -local register_stripped_trunk = function(subname, description_stripped_trunk, description_stripped_bark, longdesc, tile_stripped_inner, tile_stripped_bark) +local function register_stripped_trunk(subname, description_stripped_trunk, description_stripped_bark, longdesc, tile_stripped_inner, tile_stripped_bark) minetest.register_node("mcl_core:"..subname, { description = description_stripped_trunk, _doc_items_longdesc = longdesc, diff --git a/mods/ITEMS/mcl_crafting_table/init.lua b/mods/ITEMS/mcl_crafting_table/init.lua index cbf1cff34..58b46d668 100644 --- a/mods/ITEMS/mcl_crafting_table/init.lua +++ b/mods/ITEMS/mcl_crafting_table/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_crafting_table") +local S = minetest.get_translator(minetest.get_current_modname()) local formspec_escape = minetest.formspec_escape local show_formspec = minetest.show_formspec local C = minetest.colorize diff --git a/mods/ITEMS/mcl_doors/api_doors.lua b/mods/ITEMS/mcl_doors/api_doors.lua index 909bb47e4..7d00c4c69 100644 --- a/mods/ITEMS/mcl_doors/api_doors.lua +++ b/mods/ITEMS/mcl_doors/api_doors.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_doors") +local S = minetest.get_translator(minetest.get_current_modname()) local minetest_get_meta = minetest.get_meta -- This helper function calls on_place_node callbacks. diff --git a/mods/ITEMS/mcl_doors/api_trapdoors.lua b/mods/ITEMS/mcl_doors/api_trapdoors.lua index 3999ad0bf..3d2a8e891 100644 --- a/mods/ITEMS/mcl_doors/api_trapdoors.lua +++ b/mods/ITEMS/mcl_doors/api_trapdoors.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_doors") +local S = minetest.get_translator(minetest.get_current_modname()) -- Wrapper around mintest.pointed_thing_to_face_pos. local function get_fpos(placer, pointed_thing) diff --git a/mods/ITEMS/mcl_doors/register.lua b/mods/ITEMS/mcl_doors/register.lua index 2ffd4b245..c998f6538 100644 --- a/mods/ITEMS/mcl_doors/register.lua +++ b/mods/ITEMS/mcl_doors/register.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_doors") +local S = minetest.get_translator(minetest.get_current_modname()) --[[ Doors ]] @@ -260,9 +260,9 @@ mcl_doors:register_trapdoor("mcl_doors:iron_trapdoor", { }) minetest.register_craft({ - output = 'mcl_doors:iron_trapdoor', + output = "mcl_doors:iron_trapdoor", recipe = { - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot"}, } }) diff --git a/mods/ITEMS/mcl_dye/init.lua b/mods/ITEMS/mcl_dye/init.lua index 863abd3d2..6771a95e5 100644 --- a/mods/ITEMS/mcl_dye/init.lua +++ b/mods/ITEMS/mcl_dye/init.lua @@ -7,13 +7,16 @@ -- Note: As this uses basecolor_*, you'd need 9 of these. -- minetest.register_craft({ -- type = "shapeless", --- output = ':item_yellow', --- recipe = {':item_no_color', 'group:basecolor_yellow'}, +-- output = ":item_yellow", +-- recipe = {":item_no_color", "group:basecolor_yellow"}, -- }) mcl_dye = {} -local S = minetest.get_translator("mcl_dye") +local S = minetest.get_translator(minetest.get_current_modname()) + +local math = math +local string = string -- Other mods can use these for looping through available colors mcl_dye.basecolors = {"white", "grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta"} @@ -94,7 +97,7 @@ for d=1, #dyelocal.dyes do end -- Takes an unicolor group name (e.g. “unicolor_white”) and returns a corresponding dye name (if it exists), nil otherwise. -mcl_dye.unicolor_to_dye = function(unicolor_group) +function mcl_dye.unicolor_to_dye(unicolor_group) local color = dyelocal.unicolor_to_dye_id[unicolor_group] if color then return "mcl_dye:" .. color @@ -126,7 +129,7 @@ end -- Bone Meal -mcl_dye.apply_bone_meal = function(pointed_thing) +function mcl_dye.apply_bone_meal(pointed_thing) -- Bone meal currently spawns all flowers found in the plains. local flowers_table_plains = { "mcl_flowers:dandelion", @@ -216,25 +219,24 @@ mcl_dye.apply_bone_meal = function(pointed_thing) end return false -- Wheat, Potato, Carrot, Pumpkin Stem, Melon Stem: Advance by 2-5 stages - elseif string.find(n.name, "mcl_farming:wheat_") ~= nil then + elseif string.find(n.name, "mcl_farming:wheat_") then local stages = math.random(2, 5) return mcl_farming:grow_plant("plant_wheat", pos, n, stages, true) - elseif string.find(n.name, "mcl_farming:potato_") ~= nil then + elseif string.find(n.name, "mcl_farming:potato_") then local stages = math.random(2, 5) return mcl_farming:grow_plant("plant_potato", pos, n, stages, true) - elseif string.find(n.name, "mcl_farming:carrot_") ~= nil then + elseif string.find(n.name, "mcl_farming:carrot_") then local stages = math.random(2, 5) return mcl_farming:grow_plant("plant_carrot", pos, n, stages, true) - elseif string.find(n.name, "mcl_farming:pumpkin_") ~= nil then + elseif string.find(n.name, "mcl_farming:pumpkin_") then local stages = math.random(2, 5) return mcl_farming:grow_plant("plant_pumpkin_stem", pos, n, stages, true) - elseif string.find(n.name, "mcl_farming:melontige_") ~= nil then + elseif string.find(n.name, "mcl_farming:melontige_") then local stages = math.random(2, 5) return mcl_farming:grow_plant("plant_melon_stem", pos, n, stages, true) - - elseif string.find(n.name, "mcl_farming:beetroot_") ~= nil then + elseif string.find(n.name, "mcl_farming:beetroot_") then -- Beetroot: 75% chance to advance to next stage - if math.random(1,100) <= 75 then + if math.random(1, 100) <= 75 then return mcl_farming:grow_plant("plant_beetroot", pos, n, 1, true) end elseif n.name == "mcl_cocoas:cocoa_1" or n.name == "mcl_cocoas:cocoa_2" then diff --git a/mods/ITEMS/mcl_enchanting/enchantments.lua b/mods/ITEMS/mcl_enchanting/enchantments.lua index 84327e3f6..ecc9fe113 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_enchanting") +local S = minetest.get_translator(minetest.get_current_modname()) -- Taken from https://minecraft.gamepedia.com/Enchanting diff --git a/mods/ITEMS/mcl_enchanting/engine.lua b/mods/ITEMS/mcl_enchanting/engine.lua index d2db2281a..d2a749947 100644 --- a/mods/ITEMS/mcl_enchanting/engine.lua +++ b/mods/ITEMS/mcl_enchanting/engine.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_enchanting") +local S = minetest.get_translator(minetest.get_current_modname()) local F = minetest.formspec_escape function mcl_enchanting.is_book(itemname) diff --git a/mods/ITEMS/mcl_enchanting/init.lua b/mods/ITEMS/mcl_enchanting/init.lua index 06f9b0f75..5aec1ced6 100644 --- a/mods/ITEMS/mcl_enchanting/init.lua +++ b/mods/ITEMS/mcl_enchanting/init.lua @@ -1,5 +1,6 @@ -local modpath = minetest.get_modpath("mcl_enchanting") -local S = minetest.get_translator("mcl_enchanting") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) local math = math local vector = vector @@ -151,7 +152,7 @@ minetest.register_craftitem("mcl_enchanting:book_enchanted", { minetest.register_alias("mcl_books:book_enchanted", "mcl_enchanting:book_enchanted") -local spawn_book_entity = function(pos, respawn) +local function spawn_book_entity(pos, respawn) if respawn then -- Check if we already have a book local objs = minetest.get_objects_inside_radius(pos, 1) diff --git a/mods/ITEMS/mcl_end/building.lua b/mods/ITEMS/mcl_end/building.lua index 94fd26434..3c8f7f66c 100644 --- a/mods/ITEMS/mcl_end/building.lua +++ b/mods/ITEMS/mcl_end/building.lua @@ -1,7 +1,8 @@ -- Building blocks and decorative nodes -local S = minetest.get_translator("mcl_end") +local S = minetest.get_translator(minetest.get_current_modname()) + +local mod_screwdriver = minetest.get_modpath("screwdriver") -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil local on_rotate if mod_screwdriver then on_rotate = screwdriver.rotate_3way diff --git a/mods/ITEMS/mcl_end/chorus_plant.lua b/mods/ITEMS/mcl_end/chorus_plant.lua index 0e35ff286..24307b5ed 100644 --- a/mods/ITEMS/mcl_end/chorus_plant.lua +++ b/mods/ITEMS/mcl_end/chorus_plant.lua @@ -1,7 +1,10 @@ -- Chorus plants -- This includes chorus flowers, chorus plant stem nodes and chorus fruit -local S = minetest.get_translator("mcl_end") +local S = minetest.get_translator(minetest.get_current_modname()) + +local math = math +local table = table --- Plant parts --- @@ -32,7 +35,7 @@ local no_detach = {} function mcl_end.detach_chorus_plant(start_pos, digger) -- This node should not call a detach function, do NOTHING local hash = minetest.hash_node_position(start_pos) - if no_detach[hash] ~= nil then + if no_detach[hash] then return end @@ -471,7 +474,7 @@ minetest.register_abm({ -- * Maximum attempts: 16 -- -- Returns true on success. -local random_teleport = function(player) +local function random_teleport(player) local pos = player:get_pos() -- 16 attempts to find a suitable position for a=1, 16 do diff --git a/mods/ITEMS/mcl_end/end_crystal.lua b/mods/ITEMS/mcl_end/end_crystal.lua index a188be383..b7c80c55a 100644 --- a/mods/ITEMS/mcl_end/end_crystal.lua +++ b/mods/ITEMS/mcl_end/end_crystal.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_end") +local S = minetest.get_translator(minetest.get_current_modname()) local vector = vector diff --git a/mods/ITEMS/mcl_end/eye_of_ender.lua b/mods/ITEMS/mcl_end/eye_of_ender.lua index afac9ebfc..ea3d70aba 100644 --- a/mods/ITEMS/mcl_end/eye_of_ender.lua +++ b/mods/ITEMS/mcl_end/eye_of_ender.lua @@ -1,5 +1,5 @@ -- Eye of Ender -local S = minetest.get_translator("mcl_end") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_entity("mcl_end:ender_eye", { physical = false, diff --git a/mods/ITEMS/mcl_farming/beetroot.lua b/mods/ITEMS/mcl_farming/beetroot.lua index 7caf5103e..e312aa262 100644 --- a/mods/ITEMS/mcl_farming/beetroot.lua +++ b/mods/ITEMS/mcl_farming/beetroot.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_craftitem("mcl_farming:beetroot_seeds", { description = S("Beetroot Seeds"), diff --git a/mods/ITEMS/mcl_farming/carrots.lua b/mods/ITEMS/mcl_farming/carrots.lua index 4599d39ee..7983c58a2 100644 --- a/mods/ITEMS/mcl_farming/carrots.lua +++ b/mods/ITEMS/mcl_farming/carrots.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) for i=1, 7 do local texture, sel_height @@ -63,10 +63,10 @@ minetest.register_node("mcl_farming:carrot", { drop = { max_items = 1, items = { - { items = {'mcl_farming:carrot_item 4'}, rarity = 5 }, - { items = {'mcl_farming:carrot_item 3'}, rarity = 2 }, - { items = {'mcl_farming:carrot_item 2'}, rarity = 2 }, - { items = {'mcl_farming:carrot_item 1'} }, + { items = {"mcl_farming:carrot_item 4"}, rarity = 5 }, + { items = {"mcl_farming:carrot_item 3"}, rarity = 2 }, + { items = {"mcl_farming:carrot_item 2"}, rarity = 2 }, + { items = {"mcl_farming:carrot_item 1"} }, } }, selection_box = { @@ -91,7 +91,7 @@ minetest.register_craftitem("mcl_farming:carrot_item", { on_secondary_use = minetest.item_eat(3), on_place = function(itemstack, placer, pointed_thing) local new = mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:carrot_1") - if new ~= nil then + if new then return new else return minetest.do_item_eat(3, nil, itemstack, placer, pointed_thing) @@ -112,9 +112,9 @@ minetest.register_craftitem("mcl_farming:carrot_item_gold", { minetest.register_craft({ output = "mcl_farming:carrot_item_gold", recipe = { - {'mcl_core:gold_nugget', 'mcl_core:gold_nugget', 'mcl_core:gold_nugget'}, - {'mcl_core:gold_nugget', 'mcl_farming:carrot_item', 'mcl_core:gold_nugget'}, - {'mcl_core:gold_nugget', 'mcl_core:gold_nugget', 'mcl_core:gold_nugget'}, + {"mcl_core:gold_nugget", "mcl_core:gold_nugget", "mcl_core:gold_nugget"}, + {"mcl_core:gold_nugget", "mcl_farming:carrot_item", "mcl_core:gold_nugget"}, + {"mcl_core:gold_nugget", "mcl_core:gold_nugget", "mcl_core:gold_nugget"}, } }) diff --git a/mods/ITEMS/mcl_farming/hoes.lua b/mods/ITEMS/mcl_farming/hoes.lua index db470b999..28ad938f4 100644 --- a/mods/ITEMS/mcl_farming/hoes.lua +++ b/mods/ITEMS/mcl_farming/hoes.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) local function create_soil(pos, inv) if pos == nil then diff --git a/mods/ITEMS/mcl_farming/melon.lua b/mods/ITEMS/mcl_farming/melon.lua index 38b4c713c..b3e49a61f 100644 --- a/mods/ITEMS/mcl_farming/melon.lua +++ b/mods/ITEMS/mcl_farming/melon.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) -- Seeds minetest.register_craftitem("mcl_farming:melon_seeds", { @@ -25,11 +25,11 @@ local melon_base_def = { drop = { max_items = 1, items = { - { items = {'mcl_farming:melon_item 7'}, rarity = 14 }, - { items = {'mcl_farming:melon_item 6'}, rarity = 10 }, - { items = {'mcl_farming:melon_item 5'}, rarity = 5 }, - { items = {'mcl_farming:melon_item 4'}, rarity = 2 }, - { items = {'mcl_farming:melon_item 3'} }, + { items = {"mcl_farming:melon_item 7"}, rarity = 14 }, + { items = {"mcl_farming:melon_item 6"}, rarity = 10 }, + { items = {"mcl_farming:melon_item 5"}, rarity = 5 }, + { items = {"mcl_farming:melon_item 4"}, rarity = 2 }, + { items = {"mcl_farming:melon_item 3"} }, } }, sounds = mcl_sounds.node_sound_wood_defaults(), @@ -144,11 +144,11 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'mcl_farming:melon', + output = "mcl_farming:melon", recipe = { - {'mcl_farming:melon_item', 'mcl_farming:melon_item', 'mcl_farming:melon_item'}, - {'mcl_farming:melon_item', 'mcl_farming:melon_item', 'mcl_farming:melon_item'}, - {'mcl_farming:melon_item', 'mcl_farming:melon_item', 'mcl_farming:melon_item'}, + {"mcl_farming:melon_item", "mcl_farming:melon_item", "mcl_farming:melon_item"}, + {"mcl_farming:melon_item", "mcl_farming:melon_item", "mcl_farming:melon_item"}, + {"mcl_farming:melon_item", "mcl_farming:melon_item", "mcl_farming:melon_item"}, } }) diff --git a/mods/ITEMS/mcl_farming/potatoes.lua b/mods/ITEMS/mcl_farming/potatoes.lua index a7f5a7084..79cd13115 100644 --- a/mods/ITEMS/mcl_farming/potatoes.lua +++ b/mods/ITEMS/mcl_farming/potatoes.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) -- Premature potato plants @@ -67,11 +67,11 @@ minetest.register_node("mcl_farming:potato", { inventory_image = "mcl_farming_potatoes_stage_3.png", drop = { items = { - { items = {'mcl_farming:potato_item 1'} }, - { items = {'mcl_farming:potato_item 1'}, rarity = 2 }, - { items = {'mcl_farming:potato_item 1'}, rarity = 2 }, - { items = {'mcl_farming:potato_item 1'}, rarity = 2 }, - { items = {'mcl_farming:potato_item_poison 1'}, rarity = 50 } + { items = {"mcl_farming:potato_item 1"} }, + { items = {"mcl_farming:potato_item 1"}, rarity = 2 }, + { items = {"mcl_farming:potato_item 1"}, rarity = 2 }, + { items = {"mcl_farming:potato_item 1"}, rarity = 2 }, + { items = {"mcl_farming:potato_item_poison 1"}, rarity = 50 } } }, selection_box = { @@ -97,7 +97,7 @@ minetest.register_craftitem("mcl_farming:potato_item", { on_secondary_use = minetest.item_eat(1), on_place = function(itemstack, placer, pointed_thing) local new = mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:potato_1") - if new ~= nil then + if new then return new else return minetest.do_item_eat(1, nil, itemstack, placer, pointed_thing) diff --git a/mods/ITEMS/mcl_farming/pumpkin.lua b/mods/ITEMS/mcl_farming/pumpkin.lua index 86ddf707b..5850aa8bc 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -1,6 +1,7 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) + +local mod_screwdriver = minetest.get_modpath("screwdriver") -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil local on_rotate if mod_screwdriver then on_rotate = screwdriver.rotate_simple diff --git a/mods/ITEMS/mcl_farming/shared_functions.lua b/mods/ITEMS/mcl_farming/shared_functions.lua index 025894a11..e942415f5 100644 --- a/mods/ITEMS/mcl_farming/shared_functions.lua +++ b/mods/ITEMS/mcl_farming/shared_functions.lua @@ -1,11 +1,15 @@ +local math = math +local tostring = tostring + mcl_farming.plant_lists = {} + local plant_lists = {} local plant_nodename_to_id_list = {} local function get_intervals_counter(pos, interval, chance) local meta = minetest.get_meta(pos) - local time_speed = tonumber(minetest.settings:get('time_speed') or 72) + local time_speed = tonumber(minetest.settings:get("time_speed") or 72) local current_game_time if time_speed == nil then return 1 @@ -206,7 +210,7 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s -- Connect the stem at stempos to the first neighboring gourd block. -- No-op if not a stem or no gourd block found - local try_connect_stem = function(stempos) + local function try_connect_stem(stempos) local stem = minetest.get_node(stempos) if stem.name ~= full_unconnected_stem then return false @@ -232,7 +236,7 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s -- Register gourd if not gourd_def.after_dig_node then - gourd_def.after_dig_node = function(blockpos, oldnode, oldmetadata, user) + function gourd_def.after_dig_node(blockpos, oldnode, oldmetadata, user) -- Disconnect any connected stems, turning them back to normal stems for n=1, #neighbors do local offset = neighbors[n] @@ -247,7 +251,7 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s end end if not gourd_def.on_construct then - gourd_def.on_construct = function(blockpos) + function gourd_def.on_construct(blockpos) -- Connect all unconnected stems at full size for n=1, #neighbors do local stempos = vector.add(blockpos, neighbors[n]) @@ -295,7 +299,7 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s end if not stem_def.on_construct then - stem_def.on_construct = function(stempos) + function stem_def.on_construct(stempos) -- Connect stem to gourd (if possible) try_connect_stem(stempos) end diff --git a/mods/ITEMS/mcl_farming/soil.lua b/mods/ITEMS/mcl_farming/soil.lua index f7a7bbbfb..8b31d888f 100644 --- a/mods/ITEMS/mcl_farming/soil.lua +++ b/mods/ITEMS/mcl_farming/soil.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_node("mcl_farming:soil", { tiles = {"mcl_farming_farmland_dry.png", "default_dirt.png"}, @@ -76,7 +76,7 @@ minetest.register_abm({ end -- Check an area of 9×2×9 around the node for nodename (9×9 on same level and 9×9 below) - local check_surroundings = function(pos, nodename) + local function check_surroundings(pos, nodename) local nodes = minetest.find_nodes_in_area({x=pos.x-4,y=pos.y,z=pos.z-4}, {x=pos.x+4,y=pos.y+1,z=pos.z+4}, {nodename}) return #nodes > 0 end diff --git a/mods/ITEMS/mcl_farming/wheat.lua b/mods/ITEMS/mcl_farming/wheat.lua index d986e5be3..da1b84b2d 100644 --- a/mods/ITEMS/mcl_farming/wheat.lua +++ b/mods/ITEMS/mcl_farming/wheat.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_farming") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_craftitem("mcl_farming:wheat_seeds", { -- Original Minecraft name: “Seeds” @@ -85,10 +85,10 @@ minetest.register_node("mcl_farming:wheat", { drop = { max_items = 4, items = { - { items = {'mcl_farming:wheat_seeds'} }, - { items = {'mcl_farming:wheat_seeds'}, rarity = 2}, - { items = {'mcl_farming:wheat_seeds'}, rarity = 5}, - { items = {'mcl_farming:wheat_item'} } + { items = {"mcl_farming:wheat_seeds"} }, + { items = {"mcl_farming:wheat_seeds"}, rarity = 2}, + { items = {"mcl_farming:wheat_seeds"}, rarity = 5}, + { items = {"mcl_farming:wheat_item"} } } }, groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1, attached_node=1, @@ -110,14 +110,14 @@ minetest.register_craftitem("mcl_farming:wheat_item", { minetest.register_craft({ output = "mcl_farming:bread", recipe = { - {'mcl_farming:wheat_item', 'mcl_farming:wheat_item', 'mcl_farming:wheat_item'}, + {"mcl_farming:wheat_item", "mcl_farming:wheat_item", "mcl_farming:wheat_item"}, } }) minetest.register_craft({ output = "mcl_farming:cookie 8", recipe = { - {'mcl_farming:wheat_item', 'mcl_dye:brown', 'mcl_farming:wheat_item'}, + {"mcl_farming:wheat_item", "mcl_dye:brown", "mcl_farming:wheat_item"}, } }) @@ -142,7 +142,7 @@ minetest.register_craftitem("mcl_farming:bread", { on_secondary_use = minetest.item_eat(5), }) -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local mod_screwdriver = minetest.get_modpath("screwdriver") local on_rotate if mod_screwdriver then on_rotate = screwdriver.rotate_3way @@ -165,18 +165,18 @@ minetest.register_node("mcl_farming:hay_block", { }) minetest.register_craft({ - output = 'mcl_farming:hay_block', + output = "mcl_farming:hay_block", recipe = { - {'mcl_farming:wheat_item', 'mcl_farming:wheat_item', 'mcl_farming:wheat_item'}, - {'mcl_farming:wheat_item', 'mcl_farming:wheat_item', 'mcl_farming:wheat_item'}, - {'mcl_farming:wheat_item', 'mcl_farming:wheat_item', 'mcl_farming:wheat_item'}, + {"mcl_farming:wheat_item", "mcl_farming:wheat_item", "mcl_farming:wheat_item"}, + {"mcl_farming:wheat_item", "mcl_farming:wheat_item", "mcl_farming:wheat_item"}, + {"mcl_farming:wheat_item", "mcl_farming:wheat_item", "mcl_farming:wheat_item"}, } }) minetest.register_craft({ - output = 'mcl_farming:wheat_item 9', + output = "mcl_farming:wheat_item 9", recipe = { - {'mcl_farming:hay_block'}, + {"mcl_farming:hay_block"}, } }) diff --git a/mods/ITEMS/mcl_fences/init.lua b/mods/ITEMS/mcl_fences/init.lua index ddd85d470..243cc2219 100644 --- a/mods/ITEMS/mcl_fences/init.lua +++ b/mods/ITEMS/mcl_fences/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_fences") +local S = minetest.get_translator(minetest.get_current_modname()) -- Node box local p = {-2/16, -0.5, -2/16, 2/16, 0.5, 2/16} @@ -237,7 +237,7 @@ function mcl_fences.register_fence_gate(id, fence_gate_name, texture, groups, ha return gate_id, open_gate_id end -mcl_fences.register_fence_and_fence_gate = function(id, fence_name, fence_gate_name, texture_fence, groups, hardness, blast_resistance, connects_to, sounds, sound_open, sound_close, sound_gain_open, sound_gain_close, texture_fence_gate) +function mcl_fences.register_fence_and_fence_gate(id, fence_name, fence_gate_name, texture_fence, groups, hardness, blast_resistance, connects_to, sounds, sound_open, sound_close, sound_gain_open, sound_gain_close, texture_fence_gate) if texture_fence_gate == nil then texture_fence_gate = texture_fence end @@ -272,17 +272,17 @@ for w=1, #woods do mcl_fences.register_fence_and_fence_gate(id, wood[2], wood[3], wood[4], wood_groups, 2, 15, wood_connect, wood_sounds) minetest.register_craft({ - output = 'mcl_fences:'..id..' 3', + output = "mcl_fences:"..id.." 3", recipe = { - {wood[6], 'mcl_core:stick', wood[6]}, - {wood[6], 'mcl_core:stick', wood[6]}, + {wood[6], "mcl_core:stick", wood[6]}, + {wood[6], "mcl_core:stick", wood[6]}, } }) minetest.register_craft({ - output = 'mcl_fences:'..id_gate, + output = "mcl_fences:"..id_gate, recipe = { - {'mcl_core:stick', wood[6], 'mcl_core:stick'}, - {'mcl_core:stick', wood[6], 'mcl_core:stick'}, + {"mcl_core:stick", wood[6], "mcl_core:stick"}, + {"mcl_core:stick", wood[6], "mcl_core:stick"}, } }) end @@ -292,7 +292,7 @@ end mcl_fences.register_fence("nether_brick_fence", S("Nether Brick Fence"), "mcl_fences_fence_nether_brick.png", {pickaxey=1, deco_block=1, fence_nether_brick=1}, 2, 30, {"group:fence_nether_brick"}, mcl_sounds.node_sound_stone_defaults()) minetest.register_craft({ - output = 'mcl_fences:nether_brick_fence 6', + output = "mcl_fences:nether_brick_fence 6", recipe = { {"mcl_nether:nether_brick", "mcl_nether:netherbrick", "mcl_nether:nether_brick"}, {"mcl_nether:nether_brick", "mcl_nether:netherbrick", "mcl_nether:nether_brick"}, diff --git a/mods/ITEMS/mcl_fire/fire_charge.lua b/mods/ITEMS/mcl_fire/fire_charge.lua index 69e536790..4d18e44ed 100644 --- a/mods/ITEMS/mcl_fire/fire_charge.lua +++ b/mods/ITEMS/mcl_fire/fire_charge.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_fire") +local S = minetest.get_translator(minetest.get_current_modname()) local get_node = minetest.get_node local add_entity = minetest.add_entity @@ -14,11 +14,9 @@ minetest.register_craftitem("mcl_fire:fire_charge", { stack_max = 64, on_place = function(itemstack, user, pointed_thing) -- Use pointed node's on_rightclick function first, if present - local node = get_node(pointed_thing.under) - if user and not user:get_player_control().sneak then - if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then - return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack - end + local new_stack = mcl_util.call_on_rightclick(itemstack, user, pointed_thing) + if new_stack then + return new_stack end -- Check protection @@ -29,6 +27,7 @@ minetest.register_craftitem("mcl_fire:fire_charge", { end -- Ignite/light fire + local node = get_node(pointed_thing.under) if pointed_thing.type == "node" then local nodedef = minetest.registered_nodes[node.name] if nodedef and nodedef._on_ignite then @@ -59,7 +58,7 @@ minetest.register_craftitem("mcl_fire:fire_charge", { }) minetest.register_craft({ - type = 'shapeless', - output = 'mcl_fire:fire_charge 3', - recipe = { 'mcl_mobitems:blaze_powder', 'group:coal', 'mcl_mobitems:gunpowder' }, + type = "shapeless", + output = "mcl_fire:fire_charge 3", + recipe = { "mcl_mobitems:blaze_powder", "group:coal", "mcl_mobitems:gunpowder" }, }) diff --git a/mods/ITEMS/mcl_fire/flint_and_steel.lua b/mods/ITEMS/mcl_fire/flint_and_steel.lua index 5aa02aec1..39a4ce882 100644 --- a/mods/ITEMS/mcl_fire/flint_and_steel.lua +++ b/mods/ITEMS/mcl_fire/flint_and_steel.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_fire") +local S = minetest.get_translator(minetest.get_current_modname()) local get_node = minetest.get_node local add_node = minetest.add_node @@ -14,11 +14,9 @@ minetest.register_tool("mcl_fire:flint_and_steel", { groups = { tool = 1, }, on_place = function(itemstack, user, pointed_thing) -- Use pointed node's on_rightclick function first, if present - local node = get_node(pointed_thing.under) - if user and not user:get_player_control().sneak then - if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then - return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack - end + local new_stack = mcl_util.call_on_rightclick(itemstack, user, pointed_thing) + if new_stack then + return new_stack end -- Check protection local protname = user:get_player_name() @@ -76,7 +74,7 @@ minetest.register_tool("mcl_fire:flint_and_steel", { }) minetest.register_craft({ - type = 'shapeless', - output = 'mcl_fire:flint_and_steel', - recipe = { 'mcl_core:iron_ingot', 'mcl_core:flint'}, + type = "shapeless", + output = "mcl_fire:flint_and_steel", + recipe = { "mcl_core:iron_ingot", "mcl_core:flint"}, }) diff --git a/mods/ITEMS/mcl_fire/init.lua b/mods/ITEMS/mcl_fire/init.lua index f1a95fec6..9f1337a5d 100644 --- a/mods/ITEMS/mcl_fire/init.lua +++ b/mods/ITEMS/mcl_fire/init.lua @@ -1,10 +1,10 @@ -- Global namespace for functions mcl_fire = {} -local modpath = minetest.get_modpath(minetest.get_current_modname()) -local S = minetest.get_translator("mcl_fire") -local N = function(s) return s end +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) local has_mcl_portals = minetest.get_modpath("mcl_portals") @@ -86,18 +86,11 @@ else eternal_fire_help = S("Eternal fire is a damaging block. Eternal fire can be extinguished by punches and nearby water blocks. Other than (normal) fire, eternal fire does not get extinguished on its own and also continues to burn under rain. Punching eternal fire is safe, but it hurts if you stand inside.") end -local fire_death_messages = { - N("@1 has been cooked crisp."), - N("@1 felt the burn."), - N("@1 died in the flames."), - N("@1 died in a fire."), -} - -local fire_timer = function(pos) +local function fire_timer(pos) minetest.get_node_timer(pos):start(math.random(3, 7)) end -local spawn_fire = function(pos, age) +local function spawn_fire(pos, age) set_node(pos, {name="mcl_fire:fire", param2 = age}) minetest.check_single_for_falling({x=pos.x, y=pos.y+1, z=pos.z}) end @@ -124,7 +117,6 @@ minetest.register_node("mcl_fire:fire", { buildable_to = true, sunlight_propagates = true, damage_per_second = 1, - _mcl_node_death_message = fire_death_messages, groups = {fire = 1, dig_immediate = 3, not_in_creative_inventory = 1, dig_by_piston=1, destroys_items=1, set_on_fire=8}, floodable = true, on_flood = function(pos, oldnode, newnode) @@ -255,7 +247,6 @@ minetest.register_node("mcl_fire:eternal_fire", { buildable_to = true, sunlight_propagates = true, damage_per_second = 1, - _mcl_node_death_message = fire_death_messages, groups = {fire = 1, dig_immediate = 3, not_in_creative_inventory = 1, dig_by_piston = 1, destroys_items = 1, set_on_fire=8}, floodable = true, on_flood = function(pos, oldnode, newnode) diff --git a/mods/ITEMS/mcl_fire/mod.conf b/mods/ITEMS/mcl_fire/mod.conf index da94d9278..4a1d52ee2 100644 --- a/mods/ITEMS/mcl_fire/mod.conf +++ b/mods/ITEMS/mcl_fire/mod.conf @@ -1,3 +1,3 @@ name = mcl_fire -depends = mcl_core, mcl_worlds, mcl_sounds, mcl_particles +depends = mcl_core, mcl_worlds, mcl_sounds, mcl_particles, mcl_util optional_depends = mcl_portals \ No newline at end of file diff --git a/mods/ITEMS/mcl_fireworks/register.lua b/mods/ITEMS/mcl_fireworks/register.lua index c441254cb..23066b663 100644 --- a/mods/ITEMS/mcl_fireworks/register.lua +++ b/mods/ITEMS/mcl_fireworks/register.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_fireworks") +local S = minetest.get_translator(minetest.get_current_modname()) local tt_help = S("Flight Duration:") local description = S("Firework Rocket") diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index 567e96e96..66a0aad68 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -1,6 +1,6 @@ --Fishing Rod, Bobber, and Flying Bobber mechanics and Bobber artwork by Rootyjr. -local S = minetest.get_translator("mcl_fishing") +local S = minetest.get_translator(minetest.get_current_modname()) local math = math @@ -190,7 +190,7 @@ local bobber_on_step = function(self, dtime) end local wield = player:get_wielded_item() --Check if player is nearby - if self.player ~= nil and player ~= nil then + if self.player and player then --Destroy bobber if item not wielded. if ((not wield) or (minetest.get_item_group(wield:get_name(), "fishing_rod") <= 0)) then self.object:remove() @@ -373,17 +373,17 @@ minetest.register_tool("mcl_fishing:fishing_rod", { minetest.register_craft({ output = "mcl_fishing:fishing_rod", recipe = { - {'','','mcl_core:stick'}, - {'','mcl_core:stick','mcl_mobitems:string'}, - {'mcl_core:stick','','mcl_mobitems:string'}, + {"","","mcl_core:stick"}, + {"","mcl_core:stick","mcl_mobitems:string"}, + {"mcl_core:stick","","mcl_mobitems:string"}, } }) minetest.register_craft({ output = "mcl_fishing:fishing_rod", recipe = { - {'mcl_core:stick', '', ''}, - {'mcl_mobitems:string', 'mcl_core:stick', ''}, - {'mcl_mobitems:string','','mcl_core:stick'}, + {"mcl_core:stick", "", ""}, + {"mcl_mobitems:string", "mcl_core:stick", ""}, + {"mcl_mobitems:string","","mcl_core:stick"}, } }) minetest.register_craft({ diff --git a/mods/ITEMS/mcl_flowerpots/init.lua b/mods/ITEMS/mcl_flowerpots/init.lua index 21d4c04e6..578553b31 100644 --- a/mods/ITEMS/mcl_flowerpots/init.lua +++ b/mods/ITEMS/mcl_flowerpots/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_flowerpots") +local S = minetest.get_translator(minetest.get_current_modname()) local has_doc = minetest.get_modpath("doc") mcl_flowerpots = {} @@ -49,11 +49,11 @@ minetest.register_node("mcl_flowerpots:flower_pot", { }) minetest.register_craft({ - output = 'mcl_flowerpots:flower_pot', + output = "mcl_flowerpots:flower_pot", recipe = { - {'mcl_core:brick', '', 'mcl_core:brick'}, - {'', 'mcl_core:brick', ''}, - {'', '', ''}, + {"mcl_core:brick", "", "mcl_core:brick"}, + {"", "mcl_core:brick", ""}, + {"", "", ""}, } }) diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index d07a125cb..14e0df5cb 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -1,7 +1,9 @@ -local S = minetest.get_translator("mcl_flowers") -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) + +local mod_screwdriver = minetest.get_modpath("screwdriver") local has_mcl_flowerpots = minetest.get_modpath("mcl_flowerpots") -local modpath = minetest.get_modpath("mcl_flowers") mcl_flowers = {} mcl_flowers.registered_simple_flowers = {} @@ -58,7 +60,7 @@ function mcl_flowers.register_simple_flower(name, def) local newname = "mcl_flowers:"..name if not def._mcl_silk_touch_drop then def._mcl_silk_touch_drop = nil end if not def.drop then def.drop = newname end - mcl_flowers.registered_simple_flowers[newname] = { + mcl_flowers.registered_simple_flowers[newname] = { name=name, desc=def.desc, image=def.image, @@ -101,10 +103,10 @@ local wheat_seed_drop = { max_items = 1, items = { { - items = {'mcl_farming:wheat_seeds'}, + items = {"mcl_farming:wheat_seeds"}, rarity = 8, }, - } + }, } local fortune_wheat_seed_drop = { @@ -458,7 +460,6 @@ minetest.register_node("mcl_flowers:waterlily", { end end end - return itemstack end, on_rotate = on_rotate, @@ -469,29 +470,29 @@ minetest.register_alias("mcl_core:tallgrass", "mcl_flowers:tallgrass") -- mcimport support: re-adds missing double_plant tops in mcimported worlds. local mg_name = minetest.get_mapgen_setting("mg_name") -local mod_mcimport = minetest.get_modpath("mcimport") ~= nil +local mod_mcimport = minetest.get_modpath("mcimport") + 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" } - if mod_mcimport and mg_name == "singlenode" and fix_doubleplants == true then - local flowernames = { "peony", "rose_bush", "lilac", "sunflower", "double_fern", "double_grass" } - - minetest.register_lbm({ - label = "Add double plant tops.", - name = "mcl_flowers:double_plant_topper", - run_at_every_load = true, - nodenames = { "mcl_flowers:peony", "mcl_flowers:rose_bush", "mcl_flowers:lilac", "mcl_flowers:sunflower", "mcl_flowers:double_fern", "mcl_flowers:double_grass" }, - action = function(pos, node) - for c=1, 6 do - local flowername = flowernames[c] - local bottom = pos - local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z } - if node.name == "mcl_flowers:"..flowername then - minetest.set_node(top, {name = "mcl_flowers:"..flowername.."_top"}) - end + minetest.register_lbm({ + label = "Add double plant tops.", + name = "mcl_flowers:double_plant_topper", + run_at_every_load = true, + nodenames = { "mcl_flowers:peony", "mcl_flowers:rose_bush", "mcl_flowers:lilac", "mcl_flowers:sunflower", "mcl_flowers:double_fern", "mcl_flowers:double_grass" }, + action = function(pos, node) + for c = 1, 6 do + local flowername = flowernames[c] + local bottom = pos + local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z } + if node.name == "mcl_flowers:"..flowername then + minetest.set_node(top, {name = "mcl_flowers:"..flowername.."_top"}) end - end, - }) - end + end + end, + }) +end dofile(modpath.."/register.lua") diff --git a/mods/ITEMS/mcl_flowers/register.lua b/mods/ITEMS/mcl_flowers/register.lua index 9b65caebf..b45f3e1ee 100644 --- a/mods/ITEMS/mcl_flowers/register.lua +++ b/mods/ITEMS/mcl_flowers/register.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_flowers") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_flowers.register_simple_flower("poppy", { desc = S("Poppy"), diff --git a/mods/ITEMS/mcl_furnaces/init.lua b/mods/ITEMS/mcl_furnaces/init.lua index af2a60952..e31406f6a 100644 --- a/mods/ITEMS/mcl_furnaces/init.lua +++ b/mods/ITEMS/mcl_furnaces/init.lua @@ -1,5 +1,5 @@ -local S = minetest.get_translator("mcl_furnaces") +local S = minetest.get_translator(minetest.get_current_modname()) local LIGHT_ACTIVE_FURNACE = 13 @@ -217,14 +217,14 @@ end local function furnace_reset_delta_time(pos) local meta = minetest.get_meta(pos) - local time_speed = tonumber(minetest.settings:get('time_speed') or 72) + local time_speed = tonumber(minetest.settings:get("time_speed") or 72) if (time_speed < 0.1) then return end local time_multiplier = 86400 / time_speed local current_game_time = .0 + ((minetest.get_day_count() + minetest.get_timeofday()) * time_multiplier) - -- TODO: Change meta:get/set_string() to get/set_float() for 'last_gametime'. + -- TODO: Change meta:get/set_string() to get/set_float() for "last_gametime". -- In Windows *_float() works OK but under Linux it returns rounded unusable values like 449540.000000000 local last_game_time = meta:get_string("last_gametime") if last_game_time then @@ -239,7 +239,7 @@ end local function furnace_get_delta_time(pos, elapsed) local meta = minetest.get_meta(pos) - local time_speed = tonumber(minetest.settings:get('time_speed') or 72) + local time_speed = tonumber(minetest.settings:get("time_speed") or 72) local current_game_time if (time_speed < 0.1) then return meta, elapsed @@ -478,9 +478,9 @@ minetest.register_node("mcl_furnaces:furnace", { local meta = minetest.get_meta(pos) meta:set_string("formspec", inactive_formspec) local inv = meta:get_inventory() - inv:set_size('src', 1) - inv:set_size('fuel', 1) - inv:set_size('dst', 1) + inv:set_size("src", 1) + inv:set_size("fuel", 1) + inv:set_size("dst", 1) end, on_destruct = function(pos) mcl_particles.delete_node_particlespawners(pos) diff --git a/mods/ITEMS/mcl_heads/init.lua b/mods/ITEMS/mcl_heads/init.lua index 4bcee2279..78356de71 100644 --- a/mods/ITEMS/mcl_heads/init.lua +++ b/mods/ITEMS/mcl_heads/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_heads") +local S = minetest.get_translator(minetest.get_current_modname()) local mod_doc = minetest.get_modpath("doc") local mod_screwdriver = minetest.get_modpath("screwdriver") diff --git a/mods/ITEMS/mcl_hoppers/init.lua b/mods/ITEMS/mcl_hoppers/init.lua index eaff8f83d..ca6cb60e2 100644 --- a/mods/ITEMS/mcl_hoppers/init.lua +++ b/mods/ITEMS/mcl_hoppers/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_hoppers") +local S = minetest.get_translator(minetest.get_current_modname()) --[[ BEGIN OF NODE DEFINITIONS ]] diff --git a/mods/ITEMS/mcl_itemframes/init.lua b/mods/ITEMS/mcl_itemframes/init.lua index fbd4d545a..d46a393b8 100644 --- a/mods/ITEMS/mcl_itemframes/init.lua +++ b/mods/ITEMS/mcl_itemframes/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_itemframes") +local S = minetest.get_translator(minetest.get_current_modname()) local VISUAL_SIZE = 0.3 @@ -13,8 +13,8 @@ minetest.register_entity("mcl_itemframes:item",{ _scale = 1, on_activate = function(self, staticdata) - if staticdata ~= nil and staticdata ~= "" then - local data = staticdata:split(';') + if staticdata and staticdata ~= "" then + local data = staticdata:split(";") if data and data[1] and data[2] then self._nodename = data[1] self._texture = data[2] @@ -25,7 +25,7 @@ minetest.register_entity("mcl_itemframes:item",{ end end end - if self._texture ~= nil then + if self._texture then self.object:set_properties({ textures={self._texture}, visual_size={x=VISUAL_SIZE/self._scale, y=VISUAL_SIZE/self._scale}, @@ -33,10 +33,10 @@ minetest.register_entity("mcl_itemframes:item",{ end end, get_staticdata = function(self) - if self._nodename ~= nil and self._texture ~= nil then - local ret = self._nodename .. ';' .. self._texture - if self._scale ~= nil then - ret = ret .. ';' .. self._scale + if self._nodename and self._texture then + local ret = self._nodename .. ";" .. self._texture + if self._scale then + ret = ret .. ";" .. self._scale end return ret end @@ -44,7 +44,7 @@ minetest.register_entity("mcl_itemframes:item",{ end, _update_texture = function(self) - if self._texture ~= nil then + if self._texture then self.object:set_properties({ textures={self._texture}, visual_size={x=VISUAL_SIZE/self._scale, y=VISUAL_SIZE/self._scale}, @@ -299,11 +299,11 @@ minetest.register_node("mcl_itemframes:item_frame",{ }) minetest.register_craft({ - output = 'mcl_itemframes:item_frame', + output = "mcl_itemframes:item_frame", recipe = { - {'mcl_core:stick', 'mcl_core:stick', 'mcl_core:stick'}, - {'mcl_core:stick', 'mcl_mobitems:leather', 'mcl_core:stick'}, - {'mcl_core:stick', 'mcl_core:stick', 'mcl_core:stick'}, + {"mcl_core:stick", "mcl_core:stick", "mcl_core:stick"}, + {"mcl_core:stick", "mcl_mobitems:leather", "mcl_core:stick"}, + {"mcl_core:stick", "mcl_core:stick", "mcl_core:stick"}, } }) diff --git a/mods/ITEMS/mcl_jukebox/init.lua b/mods/ITEMS/mcl_jukebox/init.lua index 249603b58..ebee6f7bb 100644 --- a/mods/ITEMS/mcl_jukebox/init.lua +++ b/mods/ITEMS/mcl_jukebox/init.lua @@ -1,4 +1,7 @@ -local S = minetest.get_translator("mcl_jukebox") +local S = minetest.get_translator(minetest.get_current_modname()) +local C = minetest.colorize + +local math = math mcl_jukebox = {} mcl_jukebox.registered_records = {} @@ -20,8 +23,8 @@ function mcl_jukebox.register_record(title, author, identifier, image, sound) local usagehelp = S("Place a music disc into an empty jukebox to play the music. Use the jukebox again to retrieve the music disc. The music can only be heard by you, not by other players.") minetest.register_craftitem(":mcl_jukebox:record_"..identifier, { description = - core.colorize(mcl_colors.AQUA, S("Music Disc")) .. "\n" .. - core.colorize(mcl_colors.GRAY, S("@1—@2", author, title)), + C(mcl_colors.AQUA, S("Music Disc")) .. "\n" .. + C(mcl_colors.GRAY, S("@1—@2", author, title)), _doc_items_create_entry = true, _doc_items_entry_name = entryname, _doc_items_longdesc = longdesc, @@ -45,7 +48,7 @@ local function now_playing(player, name) end local id - if hud ~= nil then + if hud then id = hud player:hud_change(id, "text", text) else @@ -67,7 +70,7 @@ local function now_playing(player, name) if not player or not player:is_player() or not active_huds[playername] or not hud_sequence_numbers[playername] or seq ~= hud_sequence_numbers[playername] then return end - if id ~= nil and id == active_huds[playername] then + if id and id == active_huds[playername] then player:hud_remove(active_huds[playername]) active_huds[playername] = nil end @@ -82,19 +85,19 @@ end) -- Jukebox crafting minetest.register_craft({ - output = 'mcl_jukebox:jukebox', + output = "mcl_jukebox:jukebox", recipe = { - {'group:wood', 'group:wood', 'group:wood'}, - {'group:wood', 'mcl_core:diamond', 'group:wood'}, - {'group:wood', 'group:wood', 'group:wood'}, + {"group:wood", "group:wood", "group:wood"}, + {"group:wood", "mcl_core:diamond", "group:wood"}, + {"group:wood", "group:wood", "group:wood"}, } }) -local play_record = function(pos, itemstack, player) +local function play_record(pos, itemstack, player) local name = itemstack:get_name() if mcl_jukebox.registered_records[name] then local cname = player:get_player_name() - if active_tracks[cname] ~= nil then + if active_tracks[cname] then minetest.sound_stop(active_tracks[cname]) active_tracks[cname] = nil end @@ -134,7 +137,7 @@ minetest.register_node("mcl_jukebox:jukebox", { local inv = meta:get_inventory() if not inv:is_empty("main") then -- Jukebox contains a disc: Stop music and remove disc - if active_tracks[cname] ~= nil then + if active_tracks[cname] then minetest.sound_stop(active_tracks[cname]) end local lx = pos.x @@ -145,11 +148,11 @@ minetest.register_node("mcl_jukebox:jukebox", { -- Rotate record to match with “slot” texture dropped_item:set_yaw(math.pi/2) inv:set_stack("main", 1, "") - if active_tracks[cname] ~= nil then + if active_tracks[cname] then minetest.sound_stop(active_tracks[cname]) active_tracks[cname] = nil end - if active_huds[cname] ~= nil then + if active_huds[cname] then clicker:hud_remove(active_huds[cname]) active_huds[cname] = nil end @@ -204,11 +207,11 @@ minetest.register_node("mcl_jukebox:jukebox", { local dropped_item = minetest.add_item(p, stack) -- Rotate record to match with “slot” texture dropped_item:set_yaw(math.pi/2) - if active_tracks[name] ~= nil then + if active_tracks[name] then minetest.sound_stop(active_tracks[name]) active_tracks[name] = nil end - if active_huds[name] ~= nil then + if active_huds[name] then digger:hud_remove(active_huds[name]) active_huds[name] = nil end diff --git a/mods/ITEMS/mcl_maps/init.lua b/mods/ITEMS/mcl_maps/init.lua index ccdaf6dfd..d2ff951ad 100644 --- a/mods/ITEMS/mcl_maps/init.lua +++ b/mods/ITEMS/mcl_maps/init.lua @@ -1,8 +1,21 @@ mcl_maps = {} -local S = minetest.get_translator("mcl_maps") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) + +local math = math +local vector = vector +local table = table +local pairs = pairs + +local pos_to_string = minetest.pos_to_string +local string_to_pos = minetest.string_to_pos +local get_item_group = minetest.get_item_group +local dynamic_add_media = minetest.dynamic_add_media +local get_connected_players = minetest.get_connected_players + local storage = minetest.get_mod_storage() -local modpath = minetest.get_modpath("mcl_maps") local worldpath = minetest.get_worldpath() local map_textures_path = worldpath .. "/mcl_maps/" --local last_finished_id = storage:get_int("next_id") - 1 @@ -36,8 +49,8 @@ function mcl_maps.create_map(pos) storage:set_int("next_id", next_id + 1) local id = tostring(next_id) meta:set_string("mcl_maps:id", id) - meta:set_string("mcl_maps:minp", minetest.pos_to_string(minp)) - meta:set_string("mcl_maps:maxp", minetest.pos_to_string(maxp)) + meta:set_string("mcl_maps:minp", pos_to_string(minp)) + meta:set_string("mcl_maps:maxp", pos_to_string(maxp)) tt.reload_itemstack_description(itemstack) creating_maps[id] = true @@ -135,7 +148,7 @@ function mcl_maps.load_map(id) if not loaded_maps[id] then loaded_maps[id] = true - minetest.dynamic_add_media(map_textures_path .. texture, function() end) + dynamic_add_media(map_textures_path .. texture, function() end) end return texture @@ -216,14 +229,14 @@ end local old_add_item = minetest.add_item function minetest.add_item(pos, stack) stack = ItemStack(stack) - if minetest.get_item_group(stack:get_name(), "filled_map") > 0 then + if get_item_group(stack:get_name(), "filled_map") > 0 then stack:set_name("mcl_maps:filled_map") end return old_add_item(pos, stack) end tt.register_priority_snippet(function(itemstring, _, itemstack) - if itemstack and minetest.get_item_group(itemstring, "filled_map") > 0 then + if itemstack and get_item_group(itemstring, "filled_map") > 0 then local id = itemstack:get_meta():get_string("mcl_maps:id") if id ~= "" then return "#" .. id, mcl_colors.GRAY @@ -249,7 +262,7 @@ minetest.register_craft({ local function on_craft(itemstack, player, old_craft_grid, craft_inv) if itemstack:get_name() == "mcl_maps:filled_map" then for _, stack in pairs(old_craft_grid) do - if minetest.get_item_group(stack:get_name(), "filled_map") > 0 then + if get_item_group(stack:get_name(), "filled_map") > 0 then itemstack:get_meta():from_table(stack:get_meta():to_table()) return itemstack end @@ -286,7 +299,7 @@ minetest.register_on_leaveplayer(function(player) end) minetest.register_globalstep(function(dtime) - for _, player in pairs(minetest.get_connected_players()) do + for _, player in pairs(get_connected_players()) do local wield = player:get_wielded_item() local texture = mcl_maps.load_map_item(wield) local hud = huds[player] @@ -306,8 +319,8 @@ minetest.register_globalstep(function(dtime) local pos = vector.round(player:get_pos()) local meta = wield:get_meta() - local minp = minetest.string_to_pos(meta:get_string("mcl_maps:minp")) - local maxp = minetest.string_to_pos(meta:get_string("mcl_maps:maxp")) + local minp = string_to_pos(meta:get_string("mcl_maps:minp")) + local maxp = string_to_pos(meta:get_string("mcl_maps:maxp")) local marker = "mcl_maps_player_arrow.png" diff --git a/mods/ITEMS/mcl_mobitems/init.lua b/mods/ITEMS/mcl_mobitems/init.lua index 1b7929722..a7b04d3d4 100644 --- a/mods/ITEMS/mcl_mobitems/init.lua +++ b/mods/ITEMS/mcl_mobitems/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_mobitems") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_craftitem("mcl_mobitems:rotten_flesh", { description = S("Rotten Flesh"), @@ -135,7 +135,7 @@ minetest.register_craftitem("mcl_mobitems:cooked_rabbit", { }) -- Reset food poisoning and status effects -local drink_milk = function(itemstack, player, pointed_thing) +local function drink_milk(itemstack, player, pointed_thing) local bucket = minetest.do_item_eat(0, "mcl_buckets:bucket_empty", itemstack, player, pointed_thing) -- Check if we were allowed to drink this (eat delay check) if mcl_hunger.active and (bucket:get_name() ~= "mcl_mobitems:milk_bucket" or minetest.is_creative_enabled(player:get_player_name())) then @@ -426,7 +426,7 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'mcl_mobitems:slimeball 9', + output = "mcl_mobitems:slimeball 9", recipe = {{"mcl_core:slimeblock"}}, }) diff --git a/mods/ITEMS/mcl_mobspawners/init.lua b/mods/ITEMS/mcl_mobspawners/init.lua index bd9d0c53a..6c5d7f6e4 100644 --- a/mods/ITEMS/mcl_mobspawners/init.lua +++ b/mods/ITEMS/mcl_mobspawners/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_mobspawners") +local S = minetest.get_translator(minetest.get_current_modname()) local math = math local table = table @@ -22,7 +22,7 @@ end local function find_doll(pos) for _,obj in pairs(minetest.get_objects_inside_radius(pos, 0.5)) do if not obj:is_player() then - if obj ~= nil and obj:get_luaentity().name == "mcl_mobspawners:doll" then + if obj and obj:get_luaentity().name == "mcl_mobspawners:doll" then return obj end end @@ -136,7 +136,7 @@ end -- Spawn mobs around pos -- NOTE: The node is timer-based, rather than ABM-based. -local spawn_mobs = function(pos, elapsed) +local function spawn_mobs(pos, elapsed) -- get meta local meta = minetest.get_meta(pos) diff --git a/mods/ITEMS/mcl_monster_eggs/init.lua b/mods/ITEMS/mcl_monster_eggs/init.lua index dd986d127..59ab72876 100644 --- a/mods/ITEMS/mcl_monster_eggs/init.lua +++ b/mods/ITEMS/mcl_monster_eggs/init.lua @@ -1,16 +1,16 @@ -- Monster eggs! -- Blocks which spawn silverfish when destroyed. -local S = minetest.get_translator("mcl_monster_eggs") +local S = minetest.get_translator(minetest.get_current_modname()) -local spawn_silverfish = function(pos, oldnode, oldmetadata, digger) +local function spawn_silverfish(pos, oldnode, oldmetadata, digger) if not minetest.is_creative_enabled("") then minetest.add_entity(pos, "mobs_mc:silverfish") end end -- Template function for registering monster egg blocks -local register_block = function(subname, description, tiles, is_ground_content) +local function register_block(subname, description, tiles, is_ground_content) if is_ground_content == nil then is_ground_content = false end @@ -19,7 +19,7 @@ local register_block = function(subname, description, tiles, is_ground_content) tiles = tiles, is_ground_content = is_ground_content, groups = {dig_immediate = 3, spawns_silverfish = 1, deco_block = 1}, - drop = '', + drop = "", sounds = mcl_sounds.node_sound_stone_defaults(), after_dig_node = spawn_silverfish, _tt_help = S("Hides a silverfish"), diff --git a/mods/ITEMS/mcl_mushrooms/huge.lua b/mods/ITEMS/mcl_mushrooms/huge.lua index 12b00db8c..617f12810 100644 --- a/mods/ITEMS/mcl_mushrooms/huge.lua +++ b/mods/ITEMS/mcl_mushrooms/huge.lua @@ -1,4 +1,6 @@ -local S = minetest.get_translator("mcl_mushrooms") +local S = minetest.get_translator(minetest.get_current_modname()) + +local vector = vector local template = { groups = {handy=1,axey=1, building_block = 1, material_wood = 1, flammable = -1 }, @@ -12,16 +14,16 @@ local template = { local red = table.copy(template) red.drop = { items = { - { items = {'mcl_mushrooms:mushroom_red 1'}, rarity = 2 }, - { items = {'mcl_mushrooms:mushroom_red 1'}, rarity = 2 }, + { items = {"mcl_mushrooms:mushroom_red"}, rarity = 2 }, + { items = {"mcl_mushrooms:mushroom_red"}, rarity = 2 }, } } local brown= table.copy(template) brown.drop = { items = { - { items = {'mcl_mushrooms:mushroom_brown 1'}, rarity = 2 }, - { items = {'mcl_mushrooms:mushroom_brown 1'}, rarity = 2 }, + { items = {"mcl_mushrooms:mushroom_brown"}, rarity = 2 }, + { items = {"mcl_mushrooms:mushroom_brown"}, rarity = 2 }, } } @@ -40,7 +42,7 @@ local function to_binary(num) return binary end -local register_mushroom = function(color, species_id, template, d_cap, d_stem, d_stem_all, longdesc_cap, longdesc_stem) +local function register_mushroom(color, species_id, template, d_cap, d_stem, d_stem_all, longdesc_cap, longdesc_stem) -- Stem texture on all sides local stem_full = table.copy(template) @@ -73,7 +75,7 @@ local register_mushroom = function(color, species_id, template, d_cap, d_stem, d block._doc_items_usagehelp = S("By placing huge mushroom blocks of the same species next to each other, the sides that touch each other will turn into pores permanently.") block.tiles = { "mcl_mushrooms_mushroom_block_skin_"..color..".png" } - block.on_construct = function(pos) + function block.on_construct(pos) local sides = { { { x= 0, y= 1, z= 0 }, 2 }, { { x= 0, y=-1, z= 0 }, 1 }, @@ -85,7 +87,7 @@ local register_mushroom = function(color, species_id, template, d_cap, d_stem, d -- Replace the side of a mushroom node. Returns the new node. -- Or nil, if unchanged. - local replace_side = function(pos, node, side) + local function replace_side(pos, node, side) local bin = string.sub(node.name, -6) if string.sub(bin, side, side) == "1" then local new_bin diff --git a/mods/ITEMS/mcl_mushrooms/small.lua b/mods/ITEMS/mcl_mushrooms/small.lua index 52c64928f..c6d7edcdc 100644 --- a/mods/ITEMS/mcl_mushrooms/small.lua +++ b/mods/ITEMS/mcl_mushrooms/small.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_mushrooms") +local S = minetest.get_translator(minetest.get_current_modname()) local on_place = mcl_util.generate_on_place_plant_function(function(place_pos, place_node) local soil_node = minetest.get_node_or_nil({x=place_pos.x, y=place_pos.y-1, z=place_pos.z}) @@ -87,7 +87,7 @@ minetest.register_craftitem("mcl_mushrooms:mushroom_stew", { minetest.register_craft({ type = "shapeless", output = "mcl_mushrooms:mushroom_stew", - recipe = {'mcl_core:bowl', 'mcl_mushrooms:mushroom_brown', 'mcl_mushrooms:mushroom_red'} + recipe = {"mcl_core:bowl", "mcl_mushrooms:mushroom_brown", "mcl_mushrooms:mushroom_red"} }) --[[ Mushroom spread and death diff --git a/mods/ITEMS/mcl_nether/init.lua b/mods/ITEMS/mcl_nether/init.lua index 0a0e2b183..c5afe66ae 100644 --- a/mods/ITEMS/mcl_nether/init.lua +++ b/mods/ITEMS/mcl_nether/init.lua @@ -1,6 +1,6 @@ -local S = minetest.get_translator("mcl_nether") +local S = minetest.get_translator(minetest.get_current_modname()) -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local mod_screwdriver = minetest.get_modpath("screwdriver") local on_rotate if mod_screwdriver then on_rotate = screwdriver.rotate_3way @@ -16,9 +16,9 @@ minetest.register_node("mcl_nether:glowstone", { drop = { max_items = 1, items = { - {items = {'mcl_nether:glowstone_dust 4'},rarity = 3}, - {items = {'mcl_nether:glowstone_dust 3'},rarity = 3}, - {items = {'mcl_nether:glowstone_dust 2'}}, + {items = {"mcl_nether:glowstone_dust 4"}, rarity = 3}, + {items = {"mcl_nether:glowstone_dust 3"}, rarity = 3}, + {items = {"mcl_nether:glowstone_dust 2"}}, } }, paramtype = "light", @@ -43,7 +43,7 @@ minetest.register_node("mcl_nether:quartz_ore", { tiles = {"mcl_nether_quartz_ore.png"}, is_ground_content = true, groups = {pickaxey=1, building_block=1, material_stone=1, xp=3}, - drop = 'mcl_nether:quartz', + drop = "mcl_nether:quartz", sounds = mcl_sounds.node_sound_stone_defaults(), _mcl_blast_resistance = 3, _mcl_hardness = 3, @@ -53,13 +53,14 @@ minetest.register_node("mcl_nether:quartz_ore", { -- For eternal fire on top of netherrack and magma blocks -- (this code does not require a dependency on mcl_fire) -local eternal_after_destruct = function(pos, oldnode) +local function eternal_after_destruct(pos, oldnode) pos.y = pos.y + 1 if minetest.get_node(pos).name == "mcl_fire:eternal_fire" then minetest.remove_node(pos) end end -local eternal_on_ignite = function(player, pointed_thing) + +local function eternal_on_ignite(player, pointed_thing) local pos = pointed_thing.under local flame_pos = {x = pos.x, y = pos.y + 1, z = pos.z} local fn = minetest.get_node(flame_pos) @@ -265,34 +266,34 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'mcl_nether:quartz_block', + output = "mcl_nether:quartz_block", recipe = { - {'mcl_nether:quartz', 'mcl_nether:quartz'}, - {'mcl_nether:quartz', 'mcl_nether:quartz'}, + {"mcl_nether:quartz", "mcl_nether:quartz"}, + {"mcl_nether:quartz", "mcl_nether:quartz"}, } }) minetest.register_craft({ - output = 'mcl_nether:quartz_pillar 2', + output = "mcl_nether:quartz_pillar 2", recipe = { - {'mcl_nether:quartz_block'}, - {'mcl_nether:quartz_block'}, + {"mcl_nether:quartz_block"}, + {"mcl_nether:quartz_block"}, } }) minetest.register_craft({ output = "mcl_nether:glowstone", recipe = { - {'mcl_nether:glowstone_dust', 'mcl_nether:glowstone_dust'}, - {'mcl_nether:glowstone_dust', 'mcl_nether:glowstone_dust'}, + {"mcl_nether:glowstone_dust", "mcl_nether:glowstone_dust"}, + {"mcl_nether:glowstone_dust", "mcl_nether:glowstone_dust"}, } }) minetest.register_craft({ output = "mcl_nether:magma", recipe = { - {'mcl_mobitems:magma_cream', 'mcl_mobitems:magma_cream'}, - {'mcl_mobitems:magma_cream', 'mcl_mobitems:magma_cream'}, + {"mcl_mobitems:magma_cream", "mcl_mobitems:magma_cream"}, + {"mcl_mobitems:magma_cream", "mcl_mobitems:magma_cream"}, } }) @@ -306,32 +307,32 @@ minetest.register_craft({ minetest.register_craft({ output = "mcl_nether:nether_brick", recipe = { - {'mcl_nether:netherbrick', 'mcl_nether:netherbrick'}, - {'mcl_nether:netherbrick', 'mcl_nether:netherbrick'}, + {"mcl_nether:netherbrick", "mcl_nether:netherbrick"}, + {"mcl_nether:netherbrick", "mcl_nether:netherbrick"}, } }) minetest.register_craft({ output = "mcl_nether:red_nether_brick", recipe = { - {'mcl_nether:nether_wart_item', 'mcl_nether:netherbrick'}, - {'mcl_nether:netherbrick', 'mcl_nether:nether_wart_item'}, + {"mcl_nether:nether_wart_item", "mcl_nether:netherbrick"}, + {"mcl_nether:netherbrick", "mcl_nether:nether_wart_item"}, } }) minetest.register_craft({ output = "mcl_nether:red_nether_brick", recipe = { - {'mcl_nether:netherbrick', 'mcl_nether:nether_wart_item'}, - {'mcl_nether:nether_wart_item', 'mcl_nether:netherbrick'}, + {"mcl_nether:netherbrick", "mcl_nether:nether_wart_item"}, + {"mcl_nether:nether_wart_item", "mcl_nether:netherbrick"}, } }) minetest.register_craft({ output = "mcl_nether:nether_wart_block", recipe = { - {'mcl_nether:nether_wart_item', 'mcl_nether:nether_wart_item', 'mcl_nether:nether_wart_item'}, - {'mcl_nether:nether_wart_item', 'mcl_nether:nether_wart_item', 'mcl_nether:nether_wart_item'}, - {'mcl_nether:nether_wart_item', 'mcl_nether:nether_wart_item', 'mcl_nether:nether_wart_item'}, + {"mcl_nether:nether_wart_item", "mcl_nether:nether_wart_item", "mcl_nether:nether_wart_item"}, + {"mcl_nether:nether_wart_item", "mcl_nether:nether_wart_item", "mcl_nether:nether_wart_item"}, + {"mcl_nether:nether_wart_item", "mcl_nether:nether_wart_item", "mcl_nether:nether_wart_item"}, } }) diff --git a/mods/ITEMS/mcl_nether/nether_wart.lua b/mods/ITEMS/mcl_nether/nether_wart.lua index 681abe094..41b23f662 100644 --- a/mods/ITEMS/mcl_nether/nether_wart.lua +++ b/mods/ITEMS/mcl_nether/nether_wart.lua @@ -1,4 +1,6 @@ -local S = minetest.get_translator("mcl_nether") +local S = minetest.get_translator(minetest.get_current_modname()) + +local table = table minetest.register_node("mcl_nether:nether_wart_0", { description = S("Premature Nether Wart (Stage 1)"), @@ -127,7 +129,7 @@ minetest.register_craftitem("mcl_nether:nether_wart_item", { -- Check for correct soil type local chk = minetest.get_item_group(minetest.get_node(soilpos).name, "soil_nether_wart") - if chk ~= 0 and chk ~= nil then + if chk and chk ~= 0 then -- Check if node above soil node allows placement if minetest.registered_items[minetest.get_node(placepos).name].buildable_to then -- Place nether wart diff --git a/mods/ITEMS/mcl_ocean/corals.lua b/mods/ITEMS/mcl_ocean/corals.lua index 376b8a22f..338929a19 100644 --- a/mods/ITEMS/mcl_ocean/corals.lua +++ b/mods/ITEMS/mcl_ocean/corals.lua @@ -1,5 +1,5 @@ -local S = minetest.get_translator("mcl_ocean") -local mod_doc = minetest.get_modpath("doc") ~= nil +local S = minetest.get_translator(minetest.get_current_modname()) +local mod_doc = minetest.get_modpath("doc") local corals = { { "tube", S("Tube Coral Block"), S("Dead Tube Coral Block"), S("Tube Coral"), S("Dead Tube Coral"), S("Tube Coral Fan"), S("Dead Tube Coral Fan") }, diff --git a/mods/ITEMS/mcl_ocean/kelp.lua b/mods/ITEMS/mcl_ocean/kelp.lua index fb6045e78..422f475ac 100644 --- a/mods/ITEMS/mcl_ocean/kelp.lua +++ b/mods/ITEMS/mcl_ocean/kelp.lua @@ -7,8 +7,8 @@ -- TODO: In MC, you can't actually destroy kelp by bucket'ing water in the middle. -- However, because of the plantlike_rooted hack, we'll just allow it for now. -local S = minetest.get_translator("mcl_ocean") -local mod_doc = minetest.get_modpath("doc") ~= nil +local S = minetest.get_translator(minetest.get_current_modname()) +local mod_doc = minetest.get_modpath("doc") -------------------------------------------------------------------------------- -- local-ify runtime functions @@ -763,7 +763,7 @@ minetest.register_craftitem("mcl_ocean:dried_kelp", { }) -local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local mod_screwdriver = minetest.get_modpath("screwdriver") local on_rotate if mod_screwdriver then on_rotate = screwdriver.rotate_3way diff --git a/mods/ITEMS/mcl_ocean/prismarine.lua b/mods/ITEMS/mcl_ocean/prismarine.lua index 647e87fe1..e38b3e0a6 100644 --- a/mods/ITEMS/mcl_ocean/prismarine.lua +++ b/mods/ITEMS/mcl_ocean/prismarine.lua @@ -1,6 +1,6 @@ -- Nodes -local S = minetest.get_translator("mcl_ocean") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_node("mcl_ocean:sea_lantern", { description = S("Sea Lantern"), @@ -12,8 +12,8 @@ minetest.register_node("mcl_ocean:sea_lantern", { drop = { max_items = 1, items = { - { items = {'mcl_ocean:prismarine_crystals 3'}, rarity = 2 }, - { items = {'mcl_ocean:prismarine_crystals 2'}} + { items = {"mcl_ocean:prismarine_crystals 3"}, rarity = 2 }, + { items = {"mcl_ocean:prismarine_crystals 2"}} } }, tiles = {{name="mcl_ocean_sea_lantern.png", animation={type="vertical_frames", aspect_w=32, aspect_h=32, length=1.25}}}, @@ -89,37 +89,37 @@ minetest.register_craftitem("mcl_ocean:prismarine_shard", { -- Crafting minetest.register_craft({ - output = 'mcl_ocean:sea_lantern', + output = "mcl_ocean:sea_lantern", recipe = { - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_crystals', 'mcl_ocean:prismarine_shard'}, - {'mcl_ocean:prismarine_crystals', 'mcl_ocean:prismarine_crystals', 'mcl_ocean:prismarine_crystals'}, - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_crystals', 'mcl_ocean:prismarine_shard'}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_crystals", "mcl_ocean:prismarine_shard"}, + {"mcl_ocean:prismarine_crystals", "mcl_ocean:prismarine_crystals", "mcl_ocean:prismarine_crystals"}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_crystals", "mcl_ocean:prismarine_shard"}, } }) minetest.register_craft({ - output = 'mcl_ocean:prismarine', + output = "mcl_ocean:prismarine", recipe = { - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'}, - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard"}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard"}, } }) minetest.register_craft({ - output = 'mcl_ocean:prismarine_brick', + output = "mcl_ocean:prismarine_brick", recipe = { - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'}, - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'}, - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard"}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard"}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard"}, } }) minetest.register_craft({ - output = 'mcl_ocean:prismarine_dark', + output = "mcl_ocean:prismarine_dark", recipe = { - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'}, - {'mcl_ocean:prismarine_shard', 'mcl_dye:black', 'mcl_ocean:prismarine_shard'}, - {'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard"}, + {"mcl_ocean:prismarine_shard", "mcl_dye:black", "mcl_ocean:prismarine_shard"}, + {"mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard"}, } }) diff --git a/mods/ITEMS/mcl_ocean/sea_pickle.lua b/mods/ITEMS/mcl_ocean/sea_pickle.lua index 067bb39a3..d215fd3b3 100644 --- a/mods/ITEMS/mcl_ocean/sea_pickle.lua +++ b/mods/ITEMS/mcl_ocean/sea_pickle.lua @@ -1,5 +1,6 @@ -local S = minetest.get_translator("mcl_ocean") -local mod_doc = minetest.get_modpath("doc") ~= nil +local S = minetest.get_translator(minetest.get_current_modname()) + +local mod_doc = minetest.get_modpath("doc") local function sea_pickle_on_place(itemstack, placer, pointed_thing) if pointed_thing.type ~= "node" or not placer then diff --git a/mods/ITEMS/mcl_ocean/seagrass.lua b/mods/ITEMS/mcl_ocean/seagrass.lua index bd6400a32..5fd382775 100644 --- a/mods/ITEMS/mcl_ocean/seagrass.lua +++ b/mods/ITEMS/mcl_ocean/seagrass.lua @@ -1,5 +1,6 @@ -local S = minetest.get_translator("mcl_ocean") -local mod_doc = minetest.get_modpath("doc") ~= nil +local S = minetest.get_translator(minetest.get_current_modname()) + +local mod_doc = minetest.get_modpath("doc") -- List of supported surfaces for seagrass local surfaces = { diff --git a/mods/ITEMS/mcl_portals/init.lua b/mods/ITEMS/mcl_portals/init.lua index 080051ffa..972e93473 100644 --- a/mods/ITEMS/mcl_portals/init.lua +++ b/mods/ITEMS/mcl_portals/init.lua @@ -4,13 +4,15 @@ mcl_portals = { storage = minetest.get_mod_storage(), } +local modpath = minetest.get_modpath(minetest.get_current_modname()) + -- Nether portal: -- Obsidian frame, activated by flint and steel -dofile(minetest.get_modpath("mcl_portals").."/portal_nether.lua") +dofile(modpath.."/portal_nether.lua") -- End portal (W.I.P): -- Red nether brick block frame, activated by an eye of ender -dofile(minetest.get_modpath("mcl_portals").."/portal_end.lua") +dofile(modpath.."/portal_end.lua") -dofile(minetest.get_modpath("mcl_portals").."/portal_gateway.lua") +dofile(modpath.."/portal_gateway.lua") diff --git a/mods/ITEMS/mcl_portals/portal_end.lua b/mods/ITEMS/mcl_portals/portal_end.lua index 5b402bdc0..085205cfd 100644 --- a/mods/ITEMS/mcl_portals/portal_end.lua +++ b/mods/ITEMS/mcl_portals/portal_end.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_portals") +local S = minetest.get_translator(minetest.get_current_modname()) local table = table local vector = vector @@ -10,7 +10,7 @@ local math = math --local mg_name = minetest.get_mapgen_setting("mg_name") -local destroy_portal = function(pos) +local function destroy_portal(pos) local neighbors = { { x=1, y=0, z=0 }, { x=-1, y=0, z=0 }, diff --git a/mods/ITEMS/mcl_portals/portal_gateway.lua b/mods/ITEMS/mcl_portals/portal_gateway.lua index c738da1a4..ca15a61d5 100644 --- a/mods/ITEMS/mcl_portals/portal_gateway.lua +++ b/mods/ITEMS/mcl_portals/portal_gateway.lua @@ -1,6 +1,8 @@ -local S = minetest.get_translator("mcl_portals") +local S = minetest.get_translator(minetest.get_current_modname()) local storage = mcl_portals.storage +local vector = vector + local gateway_positions = { {x = 96, y = -26925, z = 0}, {x = 91, y = -26925, z = 29}, @@ -24,9 +26,10 @@ local gateway_positions = { {x = 91, y = -26925, z = -29}, } +local path_gateway_portal = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_gateway_portal.mts" + local function spawn_gateway_portal(pos, dest_str) - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_gateway_portal.mts" - return mcl_structures.place_schematic(vector.add(pos, vector.new(-1, -2, -1)), path, "0", nil, true, nil, dest_str and function() + return mcl_structures.place_schematic(vector.add(pos, vector.new(-1, -2, -1)), path_gateway_portal, "0", nil, true, nil, dest_str and function() minetest.get_meta(pos):set_string("mcl_portals:gateway_destination", dest_str) end) end diff --git a/mods/ITEMS/mcl_portals/portal_nether.lua b/mods/ITEMS/mcl_portals/portal_nether.lua index ec8e40d22..3f15a134d 100644 --- a/mods/ITEMS/mcl_portals/portal_nether.lua +++ b/mods/ITEMS/mcl_portals/portal_nether.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_portals") +local S = minetest.get_translator(minetest.get_current_modname()) local SCAN_2_MAP_CHUNKS = true -- slower but helps to find more suitable places @@ -210,7 +210,7 @@ local function destroy_nether_portal(pos, node) local nn, orientation = node.name, node.param2 local obsidian = nn == OBSIDIAN - local check_remove = function(pos, orientation) + local function check_remove(pos, orientation) local node = get_node(pos) if node and (node.name == PORTAL and (orientation == nil or (node.param2 == orientation))) then minetest.remove_node(pos) diff --git a/mods/ITEMS/mcl_potions/commands.lua b/mods/ITEMS/mcl_potions/commands.lua index ad1d65b7f..1fbf591d9 100644 --- a/mods/ITEMS/mcl_potions/commands.lua +++ b/mods/ITEMS/mcl_potions/commands.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_potions") +local S = minetest.get_translator(minetest.get_current_modname()) -- ░█████╗░██╗░░██╗░█████╗░████████╗  ░█████╗░░█████╗░███╗░░░███╗███╗░░░███╗░█████╗░███╗░░██╗██████╗░░██████╗ -- ██╔══██╗██║░░██║██╔══██╗╚══██╔══╝  ██╔══██╗██╔══██╗████╗░████║████╗░████║██╔══██╗████╗░██║██╔══██╗██╔════╝ diff --git a/mods/ITEMS/mcl_potions/init.lua b/mods/ITEMS/mcl_potions/init.lua index 6cfa0dc50..36f45b01a 100644 --- a/mods/ITEMS/mcl_potions/init.lua +++ b/mods/ITEMS/mcl_potions/init.lua @@ -1,4 +1,7 @@ -local S = minetest.get_translator("mcl_potions") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) + mcl_potions = {} -- duration effects of redstone are a factor of 8/3 @@ -16,8 +19,6 @@ mcl_potions.INV_FACTOR = 0.50 mcl_potions.SPLASH_FACTOR = 0.75 mcl_potions.LINGERING_FACTOR = 0.25 - -local modpath = minetest.get_modpath("mcl_potions") dofile(modpath .. "/functions.lua") dofile(modpath .. "/commands.lua") dofile(modpath .. "/splash.lua") @@ -143,7 +144,7 @@ minetest.register_craft( { -- Template function for creating images of filled potions -- - colorstring must be a ColorString of form “#RRGGBB”, e.g. “#0000FF” for blue. -- - opacity is optional opacity from 0-255 (default: 127) -local potion_image = function(colorstring, opacity) +local function potion_image(colorstring, opacity) if not opacity then opacity = 127 end @@ -271,7 +272,7 @@ minetest.register_craftitem("mcl_potions:river_water", { }) -- Hurt mobs -local water_splash = function(obj, damage) +local function water_splash(obj, damage) if not obj then return end @@ -314,9 +315,9 @@ minetest.register_craftitem("mcl_potions:speckled_melon", { minetest.register_craft({ output = "mcl_potions:speckled_melon", recipe = { - {'mcl_core:gold_nugget', 'mcl_core:gold_nugget', 'mcl_core:gold_nugget'}, - {'mcl_core:gold_nugget', 'mcl_farming:melon_item', 'mcl_core:gold_nugget'}, - {'mcl_core:gold_nugget', 'mcl_core:gold_nugget', 'mcl_core:gold_nugget'}, + {"mcl_core:gold_nugget", "mcl_core:gold_nugget", "mcl_core:gold_nugget"}, + {"mcl_core:gold_nugget", "mcl_farming:melon_item", "mcl_core:gold_nugget"}, + {"mcl_core:gold_nugget", "mcl_core:gold_nugget", "mcl_core:gold_nugget"}, } }) @@ -428,21 +429,20 @@ local mod_table = { -- Compare two ingredients for compatable alchemy function mcl_potions.get_alchemy(ingr, pot) - - if output_table[pot] ~= nil then + if output_table[pot] then local brew_table = output_table[pot] - if brew_table[ingr] ~= nil then + if brew_table[ingr] then return brew_table[ingr] end end - if mod_table[ingr] ~= nil then + if mod_table[ingr] then local brew_table = mod_table[ingr] - if brew_table[pot] ~= nil then + if brew_table[pot] then return brew_table[pot] end diff --git a/mods/ITEMS/mcl_potions/lingering.lua b/mods/ITEMS/mcl_potions/lingering.lua index f4f0e249d..d22dd4181 100644 --- a/mods/ITEMS/mcl_potions/lingering.lua +++ b/mods/ITEMS/mcl_potions/lingering.lua @@ -1,19 +1,16 @@ -local S = minetest.get_translator("mcl_potions") +local S = minetest.get_translator(minetest.get_current_modname()) -local lingering_image = function(colorstring, opacity) +local function lingering_image(colorstring, opacity) if not opacity then opacity = 127 end return "mcl_potions_splash_overlay.png^[colorize:"..colorstring..":"..tostring(opacity).."^mcl_potions_lingering_bottle.png" end - local lingering_effect_at = {} local function add_lingering_effect(pos, color, def, is_water, instant) - lingering_effect_at[pos] = {color = color, timer = 30, def = def, is_water = is_water} - end local function linger_particles(pos, d, texture, color) diff --git a/mods/ITEMS/mcl_potions/potions.lua b/mods/ITEMS/mcl_potions/potions.lua index b9c2aad24..3d89d1d40 100644 --- a/mods/ITEMS/mcl_potions/potions.lua +++ b/mods/ITEMS/mcl_potions/potions.lua @@ -1,7 +1,7 @@ -local S = minetest.get_translator("mcl_potions") +local S = minetest.get_translator(minetest.get_current_modname()) --local brewhelp = S("Try different combinations to create potions.") -local potion_image = function(colorstring, opacity) +local function potion_image(colorstring, opacity) if not opacity then opacity = 127 end diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index f986134d6..112b58754 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -1,7 +1,7 @@ -local S = minetest.get_translator("mcl_potions") +local S = minetest.get_translator(minetest.get_current_modname()) local GRAVITY = tonumber(minetest.settings:get("movement_gravity")) -local splash_image = function(colorstring, opacity) +local function splash_image(colorstring, opacity) if not opacity then opacity = 127 end @@ -10,7 +10,6 @@ end function mcl_potions.register_splash(name, descr, color, def) - local id = "mcl_potions:"..name.."_splash" local longdesc = def.longdesc if not def.no_effect then diff --git a/mods/ITEMS/mcl_potions/tipped_arrow.lua b/mods/ITEMS/mcl_potions/tipped_arrow.lua index abeae8106..3991b2773 100644 --- a/mods/ITEMS/mcl_potions/tipped_arrow.lua +++ b/mods/ITEMS/mcl_potions/tipped_arrow.lua @@ -1,4 +1,7 @@ -local S = minetest.get_translator("mcl_potions") +local S = minetest.get_translator(minetest.get_current_modname()) + +local math = math + -- Time in seconds after which a stuck arrow is deleted local ARROW_TIMEOUT = 60 -- Time after which stuck arrow is rechecked for being stuck @@ -8,7 +11,7 @@ local STUCK_RECHECK_TIME = 5 local YAW_OFFSET = -math.pi/2 -local dir_to_pitch = function(dir) +local function dir_to_pitch(dir) --local dir2 = vector.normalize(dir) local xz = math.abs(dir.x) + math.abs(dir.z) return -math.atan2(-dir.y, xz) @@ -121,7 +124,7 @@ function mcl_potions.register_arrow(name, desc, color, def) } -- Destroy arrow entity self at pos and drops it as an item - local spawn_item = function(self, pos) + local function spawn_item(self, pos) if not minetest.is_creative_enabled("") then local item = minetest.add_item(pos, "mcl_potions:"..name.."_arrow") item:set_velocity({x=0, y=0, z=0}) @@ -130,7 +133,7 @@ function mcl_potions.register_arrow(name, desc, color, def) self.object:remove() end - ARROW_ENTITY.on_step = function(self, dtime) + function ARROW_ENTITY.on_step(self, dtime) local pos = self.object:get_pos() local dpos = table.copy(pos) -- digital pos dpos = vector.round(dpos) @@ -215,7 +218,7 @@ function mcl_potions.register_arrow(name, desc, color, def) -- Arrows can only damage players and mobs if obj ~= self._shooter and obj:is_player() then ok = true - elseif obj:get_luaentity() ~= nil then + elseif obj:get_luaentity() then if obj ~= self._shooter and obj:get_luaentity()._cmi_is_mob then ok = true end @@ -234,7 +237,7 @@ function mcl_potions.register_arrow(name, desc, color, def) end -- If an attackable object was found, we will damage the closest one only - if closest_object ~= nil then + if closest_object then local obj = closest_object local is_player = obj:is_player() local lua = obj:get_luaentity() @@ -386,13 +389,13 @@ function mcl_potions.register_arrow(name, desc, color, def) -- Force recheck of stuck arrows when punched. -- Otherwise, punching has no effect. - ARROW_ENTITY.on_punch = function(self) + function ARROW_ENTITY.on_punch(self) if self._stuck then self._stuckrechecktimer = STUCK_RECHECK_TIME end end - ARROW_ENTITY.get_staticdata = function(self) + function ARROW_ENTITY.get_staticdata(self) local out = { lastpos = self._lastpos, startpos = self._startpos, @@ -413,7 +416,7 @@ function mcl_potions.register_arrow(name, desc, color, def) return minetest.serialize(out) end - ARROW_ENTITY.on_activate = function(self, staticdata, dtime_s) + function ARROW_ENTITY.on_activate(self, staticdata, dtime_s) local data = minetest.deserialize(staticdata) if data then self._stuck = data.stuck @@ -451,20 +454,18 @@ function mcl_potions.register_arrow(name, desc, color, def) minetest.register_entity("mcl_potions:"..name.."_arrow_entity", ARROW_ENTITY) if minetest.get_modpath("mcl_bows") then - minetest.register_craft({ - output = 'mcl_potions:'..name..'_arrow 8', + output = "mcl_potions:"..name.."_arrow 8", recipe = { - {'mcl_bows:arrow','mcl_bows:arrow','mcl_bows:arrow'}, - {'mcl_bows:arrow','mcl_potions:'..name..'_lingering','mcl_bows:arrow'}, - {'mcl_bows:arrow','mcl_bows:arrow','mcl_bows:arrow'} + {"mcl_bows:arrow","mcl_bows:arrow","mcl_bows:arrow"}, + {"mcl_bows:arrow","mcl_potions:"..name.."_lingering","mcl_bows:arrow"}, + {"mcl_bows:arrow","mcl_bows:arrow","mcl_bows:arrow"} } }) end - if minetest.get_modpath("doc_identifier") ~= nil then + if minetest.get_modpath("doc_identifier") then doc.sub.identifier.register_object("mcl_bows:arrow_entity", "craftitems", "mcl_bows:arrow") end - end diff --git a/mods/ITEMS/mcl_signs/init.lua b/mods/ITEMS/mcl_signs/init.lua index be9db2fee..b6bfb3fe8 100644 --- a/mods/ITEMS/mcl_signs/init.lua +++ b/mods/ITEMS/mcl_signs/init.lua @@ -1,6 +1,10 @@ -local S = minetest.get_translator("mcl_signs") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) local F = minetest.formspec_escape +local table = table + -- Load the characters map (characters.txt) --[[ File format of characters.txt: It's an UTF-8 encoded text file that contains metadata for all supported characters. It contains a sequence of info blocks, one for each character. Each info block is made out of 3 lines: @@ -13,7 +17,7 @@ After line 3, another info block may follow. This repeats until the end of the f All character files must be 5 or 6 pixels wide (5 pixels are preferred) ]] -local chars_file = io.open(minetest.get_modpath("mcl_signs").."/characters.txt", "r") +local chars_file = io.open(modpath.."/characters.txt", "r") -- FIXME: Support more characters (many characters are missing). Currently ASCII and Latin-1 Supplement are supported. local charmap = {} if not chars_file then @@ -46,7 +50,7 @@ local function round(num, idp) return math.floor(num * mult + 0.5) / mult end -local string_to_array = function(str) +local function string_to_array(str) local tab = {} for i=1,string.len(str) do table.insert(tab, string.sub(str, i,i)) @@ -54,7 +58,7 @@ local string_to_array = function(str) return tab end -local string_to_line_array = function(str) +local function string_to_line_array(str) local tab = {} local current = 1 local linechar = 1 @@ -73,7 +77,7 @@ local string_to_line_array = function(str) return tab end -local create_lines = function(text) +local function create_lines(text) local line_num = 1 local tab = {} for _, line in ipairs(string_to_line_array(text)) do @@ -86,7 +90,7 @@ local create_lines = function(text) return tab end -local generate_line = function(s, ypos) +local function generate_line(s, ypos) local i = 1 local parsed = {} local width = 0 @@ -95,10 +99,10 @@ local generate_line = function(s, ypos) while chars < LINE_LENGTH and i <= #s do local file -- Get and render character - if charmap[s:sub(i, i)] ~= nil then + if charmap[s:sub(i, i)] then file = charmap[s:sub(i, i)] i = i + 1 - elseif i < #s and charmap[s:sub(i, i + 1)] ~= nil then + elseif i < #s and charmap[s:sub(i, i + 1)] then file = charmap[s:sub(i, i + 1)] i = i + 2 else @@ -108,7 +112,7 @@ local generate_line = function(s, ypos) i = i + 1 minetest.log("verbose", "[mcl_signs] Unknown symbol in '"..s.."' at "..i) end - if file ~= nil then + if file then width = width + printed_char_width table.insert(parsed, file) chars = chars + 1 @@ -125,7 +129,7 @@ local generate_line = function(s, ypos) return texture end -local generate_texture = function(lines, signnodename) +local function generate_texture(lines, signnodename) local texture = "[combine:"..SIGN_WIDTH.."x"..SIGN_WIDTH local ypos if signnodename == "mcl_signs:wall_sign" then @@ -152,6 +156,7 @@ local signtext_info_wall = { local signtext_info_standing = {} local m = -1/16 + 1/64 + for rot=0, 15 do local yaw = math.pi*2 - (((math.pi*2) / 16) * rot) local delta = vector.multiply(minetest.yaw_to_dir(yaw), m) @@ -187,7 +192,7 @@ end local sign_groups = {handy=1,axey=1, deco_block=1, material_wood=1, attached_node=1, dig_by_piston=1, flammable=-1} -local destruct_sign = function(pos) +local function destruct_sign(pos) local objects = minetest.get_objects_inside_radius(pos, 0.5) for _, v in ipairs(objects) do local ent = v:get_luaentity() @@ -203,7 +208,7 @@ local destruct_sign = function(pos) end end -local update_sign = function(pos, fields, sender, force_remove) +local function update_sign(pos, fields, sender, force_remove) local meta = minetest.get_meta(pos) if not meta then return @@ -256,7 +261,7 @@ local update_sign = function(pos, fields, sender, force_remove) text_entity:set_yaw(sign_info.yaw) end -local show_formspec = function(player, pos) +local function show_formspec(player, pos) minetest.show_formspec( player:get_player_name(), "mcl_signs:set_text_"..pos.x.."_"..pos.y.."_"..pos.z, @@ -518,7 +523,7 @@ minetest.register_entity("mcl_signs:text", { _signnodename = nil, -- node name of sign node to which the text belongs on_activate = function(self, staticdata) - if staticdata ~= nil and staticdata ~= "" then + if staticdata and staticdata ~= "" then local des = minetest.deserialize(staticdata) if des then self._signnodename = des._signnodename @@ -545,11 +550,11 @@ minetest.register_craft({ if minetest.get_modpath("mcl_core") then minetest.register_craft({ - output = 'mcl_signs:wall_sign 3', + output = "mcl_signs:wall_sign 3", recipe = { - {'group:wood', 'group:wood', 'group:wood'}, - {'group:wood', 'group:wood', 'group:wood'}, - {'', 'mcl_core:stick', ''}, + {"group:wood", "group:wood", "group:wood"}, + {"group:wood", "group:wood", "group:wood"}, + {"", "mcl_core:stick", ""}, } }) end diff --git a/mods/ITEMS/mcl_sponges/init.lua b/mods/ITEMS/mcl_sponges/init.lua index 147db6cc5..a1998ecb0 100644 --- a/mods/ITEMS/mcl_sponges/init.lua +++ b/mods/ITEMS/mcl_sponges/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_sponges") +local S = minetest.get_translator(minetest.get_current_modname()) local absorb = function(pos) local change = false @@ -73,7 +73,7 @@ minetest.register_node("mcl_sponges:sponge", { on_water = true end local water_found = minetest.find_node_near(pos, 1, "group:water") - if water_found ~= nil then + if water_found then on_water = true end if on_water then diff --git a/mods/ITEMS/mcl_stairs/api.lua b/mods/ITEMS/mcl_stairs/api.lua index cca54226f..34afb018e 100644 --- a/mods/ITEMS/mcl_stairs/api.lua +++ b/mods/ITEMS/mcl_stairs/api.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_stairs") +local S = minetest.get_translator(minetest.get_current_modname()) -- Core mcl_stairs API @@ -155,7 +155,7 @@ function mcl_stairs.register_stair(subname, recipeitem, groups, images, descript if recipeitem then minetest.register_craft({ - output = 'mcl_stairs:stair_' .. subname .. ' 4', + output = "mcl_stairs:stair_" .. subname .. " 4", recipe = { {recipeitem, "", ""}, {recipeitem, recipeitem, ""}, @@ -165,7 +165,7 @@ function mcl_stairs.register_stair(subname, recipeitem, groups, images, descript -- Flipped recipe minetest.register_craft({ - output = 'mcl_stairs:stair_' .. subname .. ' 4', + output = "mcl_stairs:stair_" .. subname .. " 4", recipe = { {"", "", recipeitem}, {"", recipeitem, recipeitem}, @@ -297,7 +297,7 @@ function mcl_stairs.register_slab(subname, recipeitem, groups, images, descripti topdef._doc_items_usagehelp = nil topdef.drop = lower_slab topdef._mcl_other_slab_half = lower_slab - topdef.on_rotate = function(pos, node, user, mode, param2) + function topdef.on_rotate(pos, node, user, mode, param2) -- Flip slab if mode == screwdriver.ROTATE_AXIS then node.name = lower_slab diff --git a/mods/ITEMS/mcl_stairs/cornerstair.lua b/mods/ITEMS/mcl_stairs/cornerstair.lua index 2d5f214e1..ae3eb4ea3 100644 --- a/mods/ITEMS/mcl_stairs/cornerstair.lua +++ b/mods/ITEMS/mcl_stairs/cornerstair.lua @@ -5,7 +5,7 @@ mcl_stairs.cornerstair = {} -local get_stair_param = function(node) +local function get_stair_param(node) local stair = minetest.get_item_group(node.name, "stair") if stair == 1 then return node.param2 @@ -24,7 +24,7 @@ local get_stair_param = function(node) end end -local get_stair_from_param = function(param, stairs) +local function get_stair_from_param(param, stairs) if param < 12 then if param < 4 then return {name = stairs[1], param2 = param} @@ -44,7 +44,7 @@ local get_stair_from_param = function(param, stairs) end end -local stair_param_to_connect = function(param, ceiling) +local function stair_param_to_connect(param, ceiling) local out = {false, false, false, false, false, false, false, false} if not ceiling then if param == 0 then @@ -126,7 +126,7 @@ local stair_param_to_connect = function(param, ceiling) return out end -local stair_connect_to_param = function(connect, ceiling) +local function stair_connect_to_param(connect, ceiling) local param if not ceiling then if connect[3] and connect[8] then @@ -240,7 +240,7 @@ function mcl_stairs.cornerstair.add(name, stairtiles) inner_groups.stair = 3 inner_groups.not_in_craft_guide = 1 local drop = node_def.drop or name - local after_dig_node = function(pos, oldnode) + local function after_dig_node(pos, oldnode) local param = get_stair_param(oldnode) local ceiling if param < 12 then @@ -273,7 +273,7 @@ function mcl_stairs.cornerstair.add(name, stairtiles) end end end - local swap_stair = function(index, n1, n2) + local function swap_stair(index, n1, n2) local connect = {false, false, false, false, false, false, false, false} connect[n1] = true connect[n2] = true @@ -425,13 +425,13 @@ function mcl_stairs.cornerstair.add(name, stairtiles) end end end - local reset_node = function(n1, n2) + local function reset_node(n1, n2) local connect = {false, false, false, false, false, false, false, false} connect[n1] = true connect[n2] = true node = get_stair_from_param(stair_connect_to_param(connect, ceiling), t[5].stairs) end - local swap_stair = function(index, n1, n2) + local function swap_stair(index, n1, n2) local connect = {false, false, false, false, false, false, false, false} connect[n1] = true connect[n2] = true diff --git a/mods/ITEMS/mcl_stairs/crafting.lua b/mods/ITEMS/mcl_stairs/crafting.lua index 702a78068..f31237eed 100644 --- a/mods/ITEMS/mcl_stairs/crafting.lua +++ b/mods/ITEMS/mcl_stairs/crafting.lua @@ -1,40 +1,40 @@ minetest.register_craft({ - output = 'mcl_core:sandstonecarved', + output = "mcl_core:sandstonecarved", recipe = { - {'mcl_stairs:slab_sandstone'}, - {'mcl_stairs:slab_sandstone'} + {"mcl_stairs:slab_sandstone"}, + {"mcl_stairs:slab_sandstone"} } }) minetest.register_craft({ - output = 'mcl_core:redsandstonecarved', + output = "mcl_core:redsandstonecarved", recipe = { - {'mcl_stairs:slab_redsandstone'}, - {'mcl_stairs:slab_redsandstone'} + {"mcl_stairs:slab_redsandstone"}, + {"mcl_stairs:slab_redsandstone"} } }) minetest.register_craft({ - output = 'mcl_core:stonebrickcarved', + output = "mcl_core:stonebrickcarved", recipe = { - {'mcl_stairs:slab_stonebrick'}, - {'mcl_stairs:slab_stonebrick'} + {"mcl_stairs:slab_stonebrick"}, + {"mcl_stairs:slab_stonebrick"} } }) minetest.register_craft({ - output = 'mcl_end:purpur_pillar', + output = "mcl_end:purpur_pillar", recipe = { - {'mcl_stairs:slab_purpur_block'}, - {'mcl_stairs:slab_purpur_block'} + {"mcl_stairs:slab_purpur_block"}, + {"mcl_stairs:slab_purpur_block"} } }) minetest.register_craft({ - output = 'mcl_nether:quartz_chiseled 2', + output = "mcl_nether:quartz_chiseled 2", recipe = { - {'mcl_stairs:slab_quartzblock'}, - {'mcl_stairs:slab_quartzblock'}, + {"mcl_stairs:slab_quartzblock"}, + {"mcl_stairs:slab_quartzblock"}, } }) diff --git a/mods/ITEMS/mcl_stairs/init.lua b/mods/ITEMS/mcl_stairs/init.lua index a5ca820bf..92f0640b3 100644 --- a/mods/ITEMS/mcl_stairs/init.lua +++ b/mods/ITEMS/mcl_stairs/init.lua @@ -7,8 +7,10 @@ mcl_stairs = {} -- Load other files -dofile(minetest.get_modpath("mcl_stairs").."/api.lua") -dofile(minetest.get_modpath("mcl_stairs").."/cornerstair.lua") -dofile(minetest.get_modpath("mcl_stairs").."/register.lua") -dofile(minetest.get_modpath("mcl_stairs").."/crafting.lua") -dofile(minetest.get_modpath("mcl_stairs").."/alias.lua") +local modpath = minetest.get_modpath(minetest.get_current_modname()) + +dofile(modpath.."/api.lua") +dofile(modpath.."/cornerstair.lua") +dofile(modpath.."/register.lua") +dofile(modpath.."/crafting.lua") +dofile(modpath.."/alias.lua") diff --git a/mods/ITEMS/mcl_stairs/register.lua b/mods/ITEMS/mcl_stairs/register.lua index 565f5409b..5de380585 100644 --- a/mods/ITEMS/mcl_stairs/register.lua +++ b/mods/ITEMS/mcl_stairs/register.lua @@ -3,7 +3,7 @@ -- slabs actually take slightly longer to be dug than their stair counterparts. -- Note sure if it is a good idea to preserve this oddity. -local S = minetest.get_translator("mcl_stairs") +local S = minetest.get_translator(minetest.get_current_modname()) local woods = { { "wood", "default_wood.png", S("Oak Wood Stairs"), S("Oak Wood Slab"), S("Double Oak Wood Slab") }, diff --git a/mods/ITEMS/mcl_throwing/init.lua b/mods/ITEMS/mcl_throwing/init.lua index 2d57744d0..c468946dd 100644 --- a/mods/ITEMS/mcl_throwing/init.lua +++ b/mods/ITEMS/mcl_throwing/init.lua @@ -37,7 +37,7 @@ end -- Throw item function mcl_throwing.get_player_throw_function(entity_name, velocity) - local func = function(item, player, pointed_thing) + local function func(item, player, pointed_thing) local playerpos = player:get_pos() local dir = player:get_look_dir() mcl_throwing.throw(item, {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, velocity, player:get_player_name()) diff --git a/mods/ITEMS/mcl_throwing/register.lua b/mods/ITEMS/mcl_throwing/register.lua index c2af9717f..ec11f86c7 100644 --- a/mods/ITEMS/mcl_throwing/register.lua +++ b/mods/ITEMS/mcl_throwing/register.lua @@ -1,5 +1,8 @@ local S = minetest.get_translator(minetest.get_current_modname()) +local math = math +local vector = vector + -- The snowball entity local snowball_ENTITY={ physical = false, @@ -15,6 +18,7 @@ local snowball_ENTITY={ _lastpos={}, } + local egg_ENTITY={ physical = false, timer=0, @@ -29,6 +33,7 @@ local egg_ENTITY={ _lastpos={}, } + -- Ender pearl entity local pearl_ENTITY={ physical = false, @@ -45,7 +50,7 @@ local pearl_ENTITY={ _thrower = nil, -- Player ObjectRef of the player who threw the ender pearl } -local check_object_hit = function(self, pos, dmg) +local function check_object_hit(self, pos, dmg) for _,object in pairs(minetest.get_objects_inside_radius(pos, 1.5)) do local entity = object:get_luaentity() @@ -70,7 +75,7 @@ local check_object_hit = function(self, pos, dmg) return false end -local snowball_particles = function(pos, vel) +local function snowball_particles(pos, vel) local vel = vector.normalize(vector.multiply(vel, -1)) minetest.add_particlespawner({ amount = 20, @@ -93,14 +98,13 @@ local snowball_particles = function(pos, vel) end -- Snowball on_step()--> called when snowball is moving. -local snowball_on_step = function(self, dtime) - self.timer=self.timer+dtime +local function snowball_on_step(self, dtime) + self.timer = self.timer + dtime local pos = self.object:get_pos() local vel = self.object:get_velocity() local node = minetest.get_node(pos) local def = minetest.registered_nodes[node.name] - -- Destroy when hitting a solid node if self._lastpos.x~=nil then if (def and def.walkable) or not def then @@ -110,33 +114,31 @@ local snowball_on_step = function(self, dtime) return end end - if check_object_hit(self, pos, {snowball_vulnerable = 3}) then minetest.sound_play("mcl_throwing_snowball_impact_soft", { pos = pos, max_hear_distance=16, gain=0.7 }, true) snowball_particles(pos, vel) self.object:remove() return end - self._lastpos={x=pos.x, y=pos.y, z=pos.z} -- Set _lastpos-->Node will be added at last pos outside the node end -- Movement function of egg -local egg_on_step = function(self, dtime) - self.timer=self.timer+dtime +local function egg_on_step(self, dtime) + self.timer = self.timer + dtime local pos = self.object:get_pos() local node = minetest.get_node(pos) local def = minetest.registered_nodes[node.name] -- Destroy when hitting a solid node with chance to spawn chicks - if self._lastpos.x~=nil then + if self._lastpos.x then if (def and def.walkable) or not def then -- 1/8 chance to spawn a chick -- FIXME: Chicks have a quite good chance to spawn in walls local r = math.random(1,8) -- Turn given object into a child - local make_child= function(object) + local function make_child(object) local ent = object:get_luaentity() object:set_properties({ visual_size = { x = ent.base_size.x/2, y = ent.base_size.y/2 }, @@ -185,8 +187,8 @@ local egg_on_step = function(self, dtime) end -- Movement function of ender pearl -local pearl_on_step = function(self, dtime) - self.timer=self.timer+dtime +local function pearl_on_step(self, dtime) + self.timer = self.timer + dtime local pos = self.object:get_pos() pos.y = math.floor(pos.y) local node = minetest.get_node(pos) diff --git a/mods/ITEMS/mcl_tnt/init.lua b/mods/ITEMS/mcl_tnt/init.lua index 40455f8d0..bf7b52385 100644 --- a/mods/ITEMS/mcl_tnt/init.lua +++ b/mods/ITEMS/mcl_tnt/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_tnt") +local S = minetest.get_translator(minetest.get_current_modname()) local tnt_griefing = minetest.settings:get_bool("mcl_tnt_griefing", true) local function spawn_tnt(pos, entname) @@ -9,7 +9,8 @@ local function spawn_tnt(pos, entname) end tnt = {} -tnt.ignite = function(pos) + +function tnt.ignite(pos) minetest.remove_node(pos) local e = spawn_tnt(pos, "mcl_tnt:tnt") minetest.check_for_falling(pos) @@ -18,7 +19,7 @@ end -- Add smoke particle of entity at pos. -- Intended to be called every step -tnt.smoke_step = function(pos) +function tnt.smoke_step(pos) minetest.add_particle({ pos = {x=pos.x,y=pos.y+0.5,z=pos.z}, velocity = vector.new(math.random() * 0.2 - 0.1, 1.0 + math.random(), math.random() * 0.2 - 0.1), @@ -189,9 +190,9 @@ if minetest.get_modpath("mcl_mobitems") then minetest.register_craft({ output = "mcl_tnt:tnt", recipe = { - {'mcl_mobitems:gunpowder','group:sand','mcl_mobitems:gunpowder'}, - {'group:sand','mcl_mobitems:gunpowder','group:sand'}, - {'mcl_mobitems:gunpowder','group:sand','mcl_mobitems:gunpowder'} + {"mcl_mobitems:gunpowder", "group:sand", "mcl_mobitems:gunpowder"}, + {"group:sand", "mcl_mobitems:gunpowder", "group:sand"}, + {"mcl_mobitems:gunpowder", "group:sand", "mcl_mobitems:gunpowder"} } }) end diff --git a/mods/ITEMS/mcl_tools/crafting.lua b/mods/ITEMS/mcl_tools/crafting.lua index 00d378d7c..636cb6660 100644 --- a/mods/ITEMS/mcl_tools/crafting.lua +++ b/mods/ITEMS/mcl_tools/crafting.lua @@ -1,235 +1,235 @@ minetest.register_craft({ - output = 'mcl_tools:pick_wood', + output = "mcl_tools:pick_wood", recipe = { - {'group:wood', 'group:wood', 'group:wood'}, - {'', 'mcl_core:stick', ''}, - {'', 'mcl_core:stick', ''}, + {"group:wood", "group:wood", "group:wood"}, + {"", "mcl_core:stick", ""}, + {"", "mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:pick_stone', + output = "mcl_tools:pick_stone", recipe = { - {'mcl_core:cobble', 'mcl_core:cobble', 'mcl_core:cobble'}, - {'', 'mcl_core:stick', ''}, - {'', 'mcl_core:stick', ''}, + {"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble"}, + {"", "mcl_core:stick", ""}, + {"", "mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:pick_iron', + output = "mcl_tools:pick_iron", recipe = { - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, - {'', 'mcl_core:stick', ''}, - {'', 'mcl_core:stick', ''}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"}, + {"", "mcl_core:stick", ""}, + {"", "mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:pick_gold', + output = "mcl_tools:pick_gold", recipe = { - {'mcl_core:gold_ingot', 'mcl_core:gold_ingot', 'mcl_core:gold_ingot'}, - {'', 'mcl_core:stick', ''}, - {'', 'mcl_core:stick', ''}, + {"mcl_core:gold_ingot", "mcl_core:gold_ingot", "mcl_core:gold_ingot"}, + {"", "mcl_core:stick", ""}, + {"", "mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:pick_diamond', + output = "mcl_tools:pick_diamond", recipe = { - {'mcl_core:diamond', 'mcl_core:diamond', 'mcl_core:diamond'}, - {'', 'mcl_core:stick', ''}, - {'', 'mcl_core:stick', ''}, + {"mcl_core:diamond", "mcl_core:diamond", "mcl_core:diamond"}, + {"", "mcl_core:stick", ""}, + {"", "mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:shovel_wood', + output = "mcl_tools:shovel_wood", recipe = { - {'group:wood'}, - {'mcl_core:stick'}, - {'mcl_core:stick'}, + {"group:wood"}, + {"mcl_core:stick"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:shovel_stone', + output = "mcl_tools:shovel_stone", recipe = { - {'mcl_core:cobble'}, - {'mcl_core:stick'}, - {'mcl_core:stick'}, + {"mcl_core:cobble"}, + {"mcl_core:stick"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:shovel_iron', + output = "mcl_tools:shovel_iron", recipe = { - {'mcl_core:iron_ingot'}, - {'mcl_core:stick'}, - {'mcl_core:stick'}, + {"mcl_core:iron_ingot"}, + {"mcl_core:stick"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:shovel_gold', + output = "mcl_tools:shovel_gold", recipe = { - {'mcl_core:gold_ingot'}, - {'mcl_core:stick'}, - {'mcl_core:stick'}, + {"mcl_core:gold_ingot"}, + {"mcl_core:stick"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:shovel_diamond', + output = "mcl_tools:shovel_diamond", recipe = { - {'mcl_core:diamond'}, - {'mcl_core:stick'}, - {'mcl_core:stick'}, + {"mcl_core:diamond"}, + {"mcl_core:stick"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_wood', + output = "mcl_tools:axe_wood", recipe = { - {'group:wood', 'group:wood'}, - {'group:wood', 'mcl_core:stick'}, - {'', 'mcl_core:stick'}, + {"group:wood", "group:wood"}, + {"group:wood", "mcl_core:stick"}, + {"", "mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_wood', + output = "mcl_tools:axe_wood", recipe = { - {'group:wood', 'group:wood'}, - {'mcl_core:stick', 'group:wood'}, - {'mcl_core:stick', ''}, + {"group:wood", "group:wood"}, + {"mcl_core:stick", "group:wood"}, + {"mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_stone', + output = "mcl_tools:axe_stone", recipe = { - {'mcl_core:cobble', 'mcl_core:cobble'}, - {'mcl_core:cobble', 'mcl_core:stick'}, - {'', 'mcl_core:stick'}, + {"mcl_core:cobble", "mcl_core:cobble"}, + {"mcl_core:cobble", "mcl_core:stick"}, + {"", "mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_stone', + output = "mcl_tools:axe_stone", recipe = { - {'mcl_core:cobble', 'mcl_core:cobble'}, - {'mcl_core:stick', 'mcl_core:cobble'}, - {'mcl_core:stick', ''}, + {"mcl_core:cobble", "mcl_core:cobble"}, + {"mcl_core:stick", "mcl_core:cobble"}, + {"mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_iron', + output = "mcl_tools:axe_iron", recipe = { - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, - {'mcl_core:iron_ingot', 'mcl_core:stick'}, - {'', 'mcl_core:stick'}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "mcl_core:stick"}, + {"", "mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_iron', + output = "mcl_tools:axe_iron", recipe = { - {'mcl_core:iron_ingot', 'mcl_core:iron_ingot'}, - {'mcl_core:stick', 'mcl_core:iron_ingot'}, - {'mcl_core:stick', ''}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot"}, + {"mcl_core:stick", "mcl_core:iron_ingot"}, + {"mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_gold', + output = "mcl_tools:axe_gold", recipe = { - {'mcl_core:gold_ingot', 'mcl_core:gold_ingot'}, - {'mcl_core:gold_ingot', 'mcl_core:stick'}, - {'', 'mcl_core:stick'}, + {"mcl_core:gold_ingot", "mcl_core:gold_ingot"}, + {"mcl_core:gold_ingot", "mcl_core:stick"}, + {"", "mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_gold', + output = "mcl_tools:axe_gold", recipe = { - {'mcl_core:gold_ingot', 'mcl_core:gold_ingot'}, - {'mcl_core:stick', 'mcl_core:gold_ingot'}, - {'mcl_core:stick', ''}, + {"mcl_core:gold_ingot", "mcl_core:gold_ingot"}, + {"mcl_core:stick", "mcl_core:gold_ingot"}, + {"mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_diamond', + output = "mcl_tools:axe_diamond", recipe = { - {'mcl_core:diamond', 'mcl_core:diamond'}, - {'mcl_core:diamond', 'mcl_core:stick'}, - {'', 'mcl_core:stick'}, + {"mcl_core:diamond", "mcl_core:diamond"}, + {"mcl_core:diamond", "mcl_core:stick"}, + {"", "mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:axe_diamond', + output = "mcl_tools:axe_diamond", recipe = { - {'mcl_core:diamond', 'mcl_core:diamond'}, - {'mcl_core:stick', 'mcl_core:diamond'}, - {'mcl_core:stick', ''}, + {"mcl_core:diamond", "mcl_core:diamond"}, + {"mcl_core:stick", "mcl_core:diamond"}, + {"mcl_core:stick", ""}, } }) minetest.register_craft({ - output = 'mcl_tools:sword_wood', + output = "mcl_tools:sword_wood", recipe = { - {'group:wood'}, - {'group:wood'}, - {'mcl_core:stick'}, + {"group:wood"}, + {"group:wood"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:sword_stone', + output = "mcl_tools:sword_stone", recipe = { - {'mcl_core:cobble'}, - {'mcl_core:cobble'}, - {'mcl_core:stick'}, + {"mcl_core:cobble"}, + {"mcl_core:cobble"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:sword_iron', + output = "mcl_tools:sword_iron", recipe = { - {'mcl_core:iron_ingot'}, - {'mcl_core:iron_ingot'}, - {'mcl_core:stick'}, + {"mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:sword_gold', + output = "mcl_tools:sword_gold", recipe = { - {'mcl_core:gold_ingot'}, - {'mcl_core:gold_ingot'}, - {'mcl_core:stick'}, + {"mcl_core:gold_ingot"}, + {"mcl_core:gold_ingot"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:sword_diamond', + output = "mcl_tools:sword_diamond", recipe = { - {'mcl_core:diamond'}, - {'mcl_core:diamond'}, - {'mcl_core:stick'}, + {"mcl_core:diamond"}, + {"mcl_core:diamond"}, + {"mcl_core:stick"}, } }) minetest.register_craft({ - output = 'mcl_tools:shears', + output = "mcl_tools:shears", recipe = { - { 'mcl_core:iron_ingot', '' }, - { '', 'mcl_core:iron_ingot', }, + { "mcl_core:iron_ingot", "" }, + { "", "mcl_core:iron_ingot", }, } }) minetest.register_craft({ - output = 'mcl_tools:shears', + output = "mcl_tools:shears", recipe = { - { '', 'mcl_core:iron_ingot', }, - { 'mcl_core:iron_ingot', '' }, + { "", "mcl_core:iron_ingot" }, + { "mcl_core:iron_ingot", "" }, } }) diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index 809a49279..c05aeb2da 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -1,4 +1,6 @@ -local S = minetest.get_translator("mcl_tools") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) -- mods/default/tools.lua @@ -175,7 +177,7 @@ minetest.register_tool("mcl_tools:pick_diamond", { }, }) -local make_grass_path = function(itemstack, placer, pointed_thing) +local function make_grass_path(itemstack, placer, pointed_thing) -- Use pointed node's on_rightclick function first, if present local node = minetest.get_node(pointed_thing.under) if placer and not placer:get_player_control().sneak then @@ -213,7 +215,7 @@ end local carve_pumpkin if minetest.get_modpath("mcl_farming") then - carve_pumpkin = function(itemstack, placer, pointed_thing) + function carve_pumpkin(itemstack, placer, pointed_thing) -- Use pointed node's on_rightclick function first, if present local node = minetest.get_node(pointed_thing.under) if placer and not placer:get_player_control().sneak then @@ -352,7 +354,7 @@ minetest.register_tool("mcl_tools:shovel_diamond", { }) -- Axes -local make_stripped_trunk = function(itemstack, placer, pointed_thing) +local function make_stripped_trunk(itemstack, placer, pointed_thing) if pointed_thing.type ~= "node" then return end local node = minetest.get_node(pointed_thing.under) @@ -610,5 +612,5 @@ minetest.register_tool("mcl_tools:shears", { }) -dofile(minetest.get_modpath("mcl_tools").."/crafting.lua") -dofile(minetest.get_modpath("mcl_tools").."/aliases.lua") +dofile(modpath.."/crafting.lua") +dofile(modpath.."/aliases.lua") diff --git a/mods/ITEMS/mcl_torches/api.lua b/mods/ITEMS/mcl_torches/api.lua index c98bda3d9..dab508795 100644 --- a/mods/ITEMS/mcl_torches/api.lua +++ b/mods/ITEMS/mcl_torches/api.lua @@ -9,7 +9,7 @@ local smoke_pdef = { maxrelpos = { x = 1/16, y = 0.06, z = 1/16 }, } -local spawn_flames_floor = function(pos) +local function spawn_flames_floor(pos) -- Flames mcl_particles.add_node_particlespawner(pos, { amount = 8, @@ -29,7 +29,7 @@ local spawn_flames_floor = function(pos) mcl_particles.spawn_smoke(pos, "torch", smoke_pdef) end -local spawn_flames_wall = function(pos) +local function spawn_flames_wall(pos) --local minrelpos, maxrelpos local node = minetest.get_node(pos) local dir = minetest.wallmounted_to_dir(node.param2) @@ -72,7 +72,7 @@ local spawn_flames_wall = function(pos) mcl_particles.spawn_smoke(pos, "torch", smoke_pdef) end -local remove_flames = function(pos) +local function remove_flames(pos) mcl_particles.delete_node_particlespawners(pos) end diff --git a/mods/ITEMS/mcl_torches/init.lua b/mods/ITEMS/mcl_torches/init.lua index 1102731c1..6b6ebcae9 100644 --- a/mods/ITEMS/mcl_torches/init.lua +++ b/mods/ITEMS/mcl_torches/init.lua @@ -1,6 +1,6 @@ mcl_torches = {} -local modpath = minetest.get_modpath("mcl_torches") +local modpath = minetest.get_modpath(minetest.get_current_modname()) dofile(modpath .. "/api.lua") dofile(modpath .. "/register.lua") diff --git a/mods/ITEMS/mcl_torches/register.lua b/mods/ITEMS/mcl_torches/register.lua index 4218889d9..f8c34e6b5 100644 --- a/mods/ITEMS/mcl_torches/register.lua +++ b/mods/ITEMS/mcl_torches/register.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_torches") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_torches.register_torch({ name = "torch", diff --git a/mods/ITEMS/mcl_walls/init.lua b/mods/ITEMS/mcl_walls/init.lua index de1b1760f..14b512ffd 100644 --- a/mods/ITEMS/mcl_walls/init.lua +++ b/mods/ITEMS/mcl_walls/init.lua @@ -1,4 +1,6 @@ -local S = minetest.get_translator("mcl_walls") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) mcl_walls = {} @@ -29,7 +31,7 @@ local function update_wall(pos) local colonpos = thisnode.name:find(":") local underscorepos local itemname, basename, modname - if colonpos ~= nil then + if colonpos then itemname = thisnode.name:sub(colonpos+1) modname = thisnode.name:sub(1, colonpos-1) end @@ -151,7 +153,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory minetest.register_node(nodename.."_"..i, { collision_box = { - type = 'fixed', + type = "fixed", fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} }, drawtype = "nodebox", @@ -180,7 +182,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory minetest.register_node(nodename.."_16", { drawtype = "nodebox", collision_box = { - type = 'fixed', + type = "fixed", fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} }, tiles = tiles, @@ -206,7 +208,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory minetest.register_node(nodename.."_21", { drawtype = "nodebox", collision_box = { - type = 'fixed', + type = "fixed", fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} }, tiles = tiles, @@ -247,7 +249,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory fixed = pillar }, collision_box = { - type = 'fixed', + type = "fixed", fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} }, collisionbox = {-0.2, 0, -0.2, 0.2, 1.4, 0.2}, @@ -267,7 +269,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory end end -dofile(minetest.get_modpath("mcl_walls") .. "/register.lua") +dofile(modpath.."/register.lua") minetest.register_on_placenode(update_wall_global) minetest.register_on_dignode(update_wall_global) diff --git a/mods/ITEMS/mcl_walls/register.lua b/mods/ITEMS/mcl_walls/register.lua index 0ccefd62f..483af493e 100644 --- a/mods/ITEMS/mcl_walls/register.lua +++ b/mods/ITEMS/mcl_walls/register.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_walls") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_walls.register_wall("mcl_walls:cobble", S("Cobblestone Wall"), "mcl_core:cobble", {"mcl_walls_cobble_wall_top.png", "default_cobble.png", "mcl_walls_cobble_wall_side.png"}) mcl_walls.register_wall("mcl_walls:mossycobble", S("Mossy Cobblestone Wall"), "mcl_core:mossycobble", {"mcl_walls_cobble_mossy_wall_top.png", "default_mossycobble.png", "mcl_walls_cobble_mossy_wall_side.png"}) diff --git a/mods/ITEMS/mcl_wool/init.lua b/mods/ITEMS/mcl_wool/init.lua index 22648efc9..8fb4f51ec 100644 --- a/mods/ITEMS/mcl_wool/init.lua +++ b/mods/ITEMS/mcl_wool/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_wool") +local S = minetest.get_translator(minetest.get_current_modname()) local mod_doc = minetest.get_modpath("doc") -- minetest/wool/init.lua @@ -99,13 +99,13 @@ for _, row in ipairs(wool.dyes) do -- Crafting from dye and white wool minetest.register_craft({ type = "shapeless", - output = 'mcl_wool:'..name, - recipe = {"mcl_dye:"..dye, 'mcl_wool:white'}, + output = "mcl_wool:"..name, + recipe = {"mcl_dye:"..dye, "mcl_wool:white"}, }) end minetest.register_craft({ - output = 'mcl_wool:'..name..'_carpet 3', - recipe = {{'mcl_wool:'..name, 'mcl_wool:'..name}}, + output = "mcl_wool:"..name.."_carpet 3", + recipe = {{"mcl_wool:"..name, "mcl_wool:"..name}}, }) end diff --git a/mods/ITEMS/mclx_core/init.lua b/mods/ITEMS/mclx_core/init.lua index bc17e0075..4bb40184a 100644 --- a/mods/ITEMS/mclx_core/init.lua +++ b/mods/ITEMS/mclx_core/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mclx_core") +local S = minetest.get_translator(minetest.get_current_modname()) -- Liquids: River Water diff --git a/mods/ITEMS/mclx_fences/init.lua b/mods/ITEMS/mclx_fences/init.lua index 08c3d91ac..e78c7ef7f 100644 --- a/mods/ITEMS/mclx_fences/init.lua +++ b/mods/ITEMS/mclx_fences/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mclx_fences") +local S = minetest.get_translator(minetest.get_current_modname()) -- Red Nether Brick Fence @@ -25,7 +25,7 @@ mcl_fences.register_fence_gate( -- Crafting minetest.register_craft({ - output = 'mclx_fences:red_nether_brick_fence 6', + output = "mclx_fences:red_nether_brick_fence 6", recipe = { {"mcl_nether:red_nether_brick", "mcl_nether:netherbrick", "mcl_nether:red_nether_brick"}, {"mcl_nether:red_nether_brick", "mcl_nether:netherbrick", "mcl_nether:red_nether_brick"}, @@ -33,14 +33,14 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'mclx_fences:red_nether_brick_fence_gate', + output = "mclx_fences:red_nether_brick_fence_gate", recipe = { {"mcl_nether:nether_wart_item", "mcl_nether:red_nether_brick", "mcl_nether:netherbrick"}, {"mcl_nether:netherbrick", "mcl_nether:red_nether_brick", "mcl_nether:nether_wart_item"}, } }) minetest.register_craft({ - output = 'mclx_fences:red_nether_brick_fence_gate', + output = "mclx_fences:red_nether_brick_fence_gate", recipe = { {"mcl_nether:netherbrick", "mcl_nether:red_nether_brick", "mcl_nether:nether_wart_item"}, {"mcl_nether:nether_wart_item", "mcl_nether:red_nether_brick", "mcl_nether:netherbrick"}, @@ -48,7 +48,7 @@ minetest.register_craft({ }) minetest.register_craft({ - output = 'mclx_fences:nether_brick_fence_gate 2', + output = "mclx_fences:nether_brick_fence_gate 2", recipe = { {"mcl_nether:netherbrick", "mcl_nether:nether_brick", "mcl_nether:netherbrick"}, {"mcl_nether:netherbrick", "mcl_nether:nether_brick", "mcl_nether:netherbrick"}, diff --git a/mods/ITEMS/mclx_stairs/init.lua b/mods/ITEMS/mclx_stairs/init.lua index 26ab5c4b5..effa87f13 100644 --- a/mods/ITEMS/mclx_stairs/init.lua +++ b/mods/ITEMS/mclx_stairs/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mclx_stairs") +local S = minetest.get_translator(minetest.get_current_modname()) local doc_mod = minetest.get_modpath("doc") diff --git a/mods/ITEMS/screwdriver/init.lua b/mods/ITEMS/screwdriver/init.lua index 942bccf38..baa4ff9c5 100644 --- a/mods/ITEMS/screwdriver/init.lua +++ b/mods/ITEMS/screwdriver/init.lua @@ -1,18 +1,21 @@ -local S = minetest.get_translator("screwdriver") +local S = minetest.get_translator(minetest.get_current_modname()) screwdriver = {} screwdriver.ROTATE_FACE = 1 screwdriver.ROTATE_AXIS = 2 -screwdriver.disallow = function(pos, node, user, mode, new_param2) + +function screwdriver.disallow(pos, node, user, mode, new_param2) return false end -screwdriver.rotate_simple = function(pos, node, user, mode, new_param2) + +function screwdriver.rotate_simple(pos, node, user, mode, new_param2) if mode ~= screwdriver.ROTATE_FACE then return false end end -screwdriver.rotate_3way = function(pos, node, user, mode, new_param2) + +function screwdriver.rotate_3way(pos, node, user, mode, new_param2) if mode == screwdriver.ROTATE_AXIS then if node.param2 == 0 then node.param2 = 6 @@ -71,7 +74,7 @@ local facedir_tbl = { }, } -screwdriver.rotate.facedir = function(pos, node, mode) +function screwdriver.rotate.facedir(pos, node, mode) local rotation = node.param2 % 32 -- get first 5 bits local other = node.param2 - rotation rotation = facedir_tbl[mode][rotation] or 0 @@ -82,10 +85,10 @@ screwdriver.rotate.colorfacedir = screwdriver.rotate.facedir local wallmounted_tbl = { [screwdriver.ROTATE_FACE] = {[2] = 5, [3] = 4, [4] = 2, [5] = 3, [1] = 0, [0] = 1}, - [screwdriver.ROTATE_AXIS] = {[2] = 5, [3] = 4, [4] = 2, [5] = 1, [1] = 0, [0] = 3} + [screwdriver.ROTATE_AXIS] = {[2] = 5, [3] = 4, [4] = 2, [5] = 1, [1] = 0, [0] = 3}, } -screwdriver.rotate.wallmounted = function(pos, node, mode) +function screwdriver.rotate.wallmounted(pos, node, mode) local rotation = node.param2 % 8 -- get first 3 bits local other = node.param2 - rotation rotation = wallmounted_tbl[mode][rotation] or 0 @@ -105,7 +108,7 @@ end screwdriver.rotate.colorwallmounted = screwdriver.rotate.wallmounted -- Handles rotation -screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses) +function screwdriver.handler(itemstack, user, pointed_thing, mode, uses) if pointed_thing.type ~= "node" then return end diff --git a/mods/ITEMS/xpanes/init.lua b/mods/ITEMS/xpanes/init.lua index 472b3efdf..fe67934a1 100644 --- a/mods/ITEMS/xpanes/init.lua +++ b/mods/ITEMS/xpanes/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("xpanes") +local S = minetest.get_translator(minetest.get_current_modname()) local mod_doc = minetest.get_modpath("doc") local function is_pane(pos) diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index 9108b75c1..a630dba04 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -6,8 +6,12 @@ local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superfl local generate_fallen_logs = minetest.settings:get_bool("mcl_generate_fallen_logs", false) +local mod_mcl_structures = minetest.get_modpath("mcl_structures") +local mod_mcl_core = minetest.get_modpath("mcl_core") +local mod_mcl_mushrooms = minetest.get_modpath("mcl_mushrooms") + -- Jungle bush schematic. In PC/Java Edition it's Jungle Wood + Oak Leaves -local jungle_bush_schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_jungle_bush_oak_leaves.mts" +local jungle_bush_schematic = mod_mcl_core.."/schematics/mcl_core_jungle_bush_oak_leaves.mts" local deco_id_chorus_plant @@ -2307,7 +2311,7 @@ local function register_decorations() biomes = {"IcePlainsSpikes"}, y_min = 4, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_ice_spike_large.mts", + schematic = mod_mcl_structures.."/schematics/mcl_structures_ice_spike_large.mts", rotation = "random", flags = "place_center_x, place_center_z", }) @@ -2328,7 +2332,7 @@ local function register_decorations() biomes = {"IcePlainsSpikes"}, y_min = 4, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_ice_spike_small.mts", + schematic = mod_mcl_structures.."/schematics/mcl_structures_ice_spike_small.mts", rotation = "random", flags = "place_center_x, place_center_z", }) @@ -2351,7 +2355,7 @@ local function register_decorations() biomes = {"Forest"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_large_"..i..".mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_large_"..i..".mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2371,7 +2375,7 @@ local function register_decorations() biomes = {"ExtremeHills", "ExtremeHillsM", "ExtremeHills+", "ExtremeHills+_snowtop"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_large_"..i..".mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_large_"..i..".mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2392,7 +2396,7 @@ local function register_decorations() biomes = {"Forest"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2411,7 +2415,7 @@ local function register_decorations() biomes = {"FlowerForest"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2430,7 +2434,7 @@ local function register_decorations() biomes = {"ExtremeHills", "ExtremeHillsM", "ExtremeHills+", "ExtremeHills+_snowtop"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2450,7 +2454,7 @@ local function register_decorations() biomes = {"ExtremeHills+", "ExtremeHills+_snowtop"}, y_min = 50, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2469,7 +2473,7 @@ local function register_decorations() biomes = {"MesaPlateauF_grasstop"}, y_min = 30, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2488,7 +2492,7 @@ local function register_decorations() biomes = {"MesaPlateauFM_grasstop"}, y_min = 30, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2508,7 +2512,7 @@ local function register_decorations() biomes = {"IcePlains"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2520,7 +2524,7 @@ local function register_decorations() biomes = {"Jungle", "JungleM"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2532,7 +2536,7 @@ local function register_decorations() biomes = {"JungleEdge", "JungleEdgeM", "Savanna"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_classic.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2554,7 +2558,7 @@ local function register_decorations() biomes = {"Forest"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_balloon.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_balloon.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2575,7 +2579,7 @@ local function register_decorations() biomes = {"Swampland", "Swampland_shore"}, y_min = 0, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_oak_swamp.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_oak_swamp.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2592,7 +2596,7 @@ local function register_decorations() biomes = {"Jungle"}, y_min = 4, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_jungle_tree_huge_"..i..".mts", + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree_huge_"..i..".mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2604,7 +2608,7 @@ local function register_decorations() biomes = {"JungleM"}, y_min = 4, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_jungle_tree_huge_"..i..".mts", + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree_huge_"..i..".mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2619,7 +2623,7 @@ local function register_decorations() biomes = {"Jungle"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_jungle_tree.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2631,7 +2635,7 @@ local function register_decorations() biomes = {"JungleEdge", "JungleEdgeM"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_jungle_tree.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2644,7 +2648,7 @@ local function register_decorations() biomes = {"JungleM"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_jungle_tree.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2669,7 +2673,7 @@ local function register_decorations() biomes = biomes, y_min = y, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/"..sprucename, + schematic = mod_mcl_core.."/schematics/"..sprucename, flags = "place_center_x, place_center_z", }) end @@ -2723,7 +2727,7 @@ local function register_decorations() biomes = {"Taiga", "ColdTaiga"}, y_min = 2, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_spruce_lollipop.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_spruce_lollipop.mts", flags = "place_center_x, place_center_z", }) @@ -2743,7 +2747,7 @@ local function register_decorations() biomes = {"Taiga", "ColdTaiga"}, y_min = 3, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_spruce_matchstick.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_spruce_matchstick.mts", flags = "place_center_x, place_center_z", }) @@ -2763,7 +2767,7 @@ local function register_decorations() biomes = {"IcePlains"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_spruce_5.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_spruce_5.mts", flags = "place_center_x, place_center_z", }) @@ -2777,7 +2781,7 @@ local function register_decorations() biomes = {"Savanna", "SavannaM"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_acacia_"..a..".mts", + schematic = mod_mcl_core.."/schematics/mcl_core_acacia_"..a..".mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2799,7 +2803,7 @@ local function register_decorations() biomes = {"BirchForest"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_birch.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_birch.mts", flags = "place_center_x, place_center_z", }) minetest.register_decoration({ @@ -2817,7 +2821,7 @@ local function register_decorations() biomes = {"BirchForestM"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_birch_tall.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_birch_tall.mts", flags = "place_center_x, place_center_z", }) @@ -2836,7 +2840,7 @@ local function register_decorations() biomes = {"Forest", "FlowerForest"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_birch.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_birch.mts", flags = "place_center_x, place_center_z", }) @@ -2856,7 +2860,7 @@ local function register_decorations() biomes = {"RoofedForest"}, y_min = 4, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_core").."/schematics/mcl_core_dark_oak.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_dark_oak.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -2878,7 +2882,7 @@ local function register_decorations() biomes = { "RoofedForest" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_huge_brown.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_huge_brown.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2890,7 +2894,7 @@ local function register_decorations() biomes = { "RoofedForest" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_giant_brown.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_giant_brown.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2903,7 +2907,7 @@ local function register_decorations() biomes = { "MushroomIsland", "MushroomIslandShore" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_huge_brown.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_huge_brown.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2915,7 +2919,7 @@ local function register_decorations() biomes = { "MushroomIsland", "MushroomIslandShore" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_giant_brown.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_giant_brown.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2929,7 +2933,7 @@ local function register_decorations() biomes = { "RoofedForest" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_huge_red.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_huge_red.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2941,7 +2945,7 @@ local function register_decorations() biomes = { "RoofedForest" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_giant_red.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_giant_red.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2954,7 +2958,7 @@ local function register_decorations() biomes = { "MushroomIsland", "MushroomIslandShore" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_huge_red.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_huge_red.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2966,7 +2970,7 @@ local function register_decorations() biomes = { "MushroomIsland", "MushroomIslandShore" }, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_giant_red.mts", + schematic = mod_mcl_mushrooms.."/schematics/mcl_mushrooms_giant_red.mts", flags = "place_center_x, place_center_z", rotation = "0", }) @@ -2987,7 +2991,7 @@ local function register_decorations() biomes = {"MegaTaiga", "MegaSpruceTaiga"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_boulder.mts", + schematic = mod_mcl_structures.."/schematics/mcl_structures_boulder.mts", flags = "place_center_x, place_center_z", }) @@ -3007,7 +3011,7 @@ local function register_decorations() biomes = {"MegaTaiga", "MegaSpruceTaiga"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_boulder_small.mts", + schematic = mod_mcl_structures.."/schematics/mcl_structures_boulder_small.mts", flags = "place_center_x, place_center_z", }) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index a6ceb4bf9..41bee508b 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -1599,7 +1599,7 @@ local function generate_tree_decorations(minp, maxp, seed, data, param2_data, ar if dir < 5 and data[p_pos] == c_air - and l ~= nil and l > 12 then + and l and l > 12 then local c = pr:next(1, 3) if c == 1 then data[p_pos] = c_cocoa_1 @@ -1736,7 +1736,7 @@ local function generate_underground_mushrooms(minp, maxp, seed) bpos = {x = stone[n].x, y = stone[n].y + 1, z = stone[n].z } local l = minetest.get_node_light(bpos, 0.5) - if bpos.y >= min and bpos.y <= max and l ~= nil and l <= 12 and pr_shroom:next(1,1000) < 4 then + if bpos.y >= min and bpos.y <= max and l and l <= 12 and pr_shroom:next(1,1000) < 4 then if pr_shroom:next(1,2) == 1 then minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_brown"}) else @@ -1799,7 +1799,7 @@ local function generate_nether_decorations(minp, maxp, seed) -- Note: Spawned *after* the fire because of light level checks special_deco(rack, function(bpos) local l = minetest.get_node_light(bpos, 0.5) - if bpos.y > mcl_vars.mg_lava_nether_max + 6 and l ~= nil and l <= 12 and pr_nether:next(1,1000) <= 4 then + if bpos.y > mcl_vars.mg_lava_nether_max + 6 and l and l <= 12 and pr_nether:next(1,1000) <= 4 then -- TODO: Make mushrooms appear in groups, use Perlin noise if pr_nether:next(1,2) == 1 then minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_brown"}) @@ -1890,11 +1890,9 @@ function mcl_mapgen_core.register_generator(id, lvm_function, node_function, pri } registered_generators[id] = new_record - table.sort( - registered_generators, - function(a, b) - return (a.i < b.i) or ((a.i == b.i) and (a.vf ~= nil) and (b.vf == nil)) - end) + table.sort(registered_generators, function(a, b) + return (a.i < b.i) or ((a.i == b.i) and a.vf and (b.vf == nil)) + end) end function mcl_mapgen_core.unregister_generator(id) diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index dfb7da24b..8efdd91b1 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -36,17 +36,17 @@ function mcl_structures.place_schematic(pos, schematic, rotation, replacements, end local p1 = {x=pos.x , y=pos.y , z=pos.z } local p2 = {x=pos.x+x-1, y=pos.y+s.size.y-1, z=pos.z+z-1} - minetest.log("verbose","[mcl_structures] size=" ..minetest.pos_to_string(s.size) .. ", rotation=" .. tostring(rotation) .. ", emerge from "..minetest.pos_to_string(p1) .. " to " .. minetest.pos_to_string(p2)) + minetest.log("verbose", "[mcl_structures] size=" ..minetest.pos_to_string(s.size) .. ", rotation=" .. tostring(rotation) .. ", emerge from "..minetest.pos_to_string(p1) .. " to " .. minetest.pos_to_string(p2)) local param = {pos=vector.new(pos), schematic=s, rotation=rotation, replacements=replacements, force_placement=force_placement, flags=flags, p1=p1, p2=p2, after_placement_callback = after_placement_callback, size=vector.new(s.size), pr=pr, callback_param=callback_param} minetest.emerge_area(p1, p2, ecb_place, param) end end function mcl_structures.get_struct(file) - local localfile = minetest.get_modpath("mcl_structures").."/schematics/"..file + local localfile = modpath.."/schematics/"..file local file, errorload = io.open(localfile, "rb") - if errorload ~= nil then - minetest.log("error", '[mcl_structures] Could not open this struct: ' .. localfile) + if errorload then + minetest.log("error", "[mcl_structures] Could not open this struct: "..localfile) return nil end @@ -290,17 +290,17 @@ local function hut_placement_callback(p1, p2, size, orientation, pr) end function mcl_structures.generate_witch_hut(pos, rotation, pr) - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_witch_hut.mts" + local path = modpath.."/schematics/mcl_structures_witch_hut.mts" mcl_structures.place_schematic(pos, path, rotation, nil, true, nil, hut_placement_callback, pr) end function mcl_structures.generate_ice_spike_small(pos, rotation) - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_ice_spike_small.mts" + local path = modpath.."/schematics/mcl_structures_ice_spike_small.mts" return minetest.place_schematic(pos, path, rotation or "random", nil, false) -- don't serialize schematics for registered biome decorations, for MT 5.4.0 end function mcl_structures.generate_ice_spike_large(pos, rotation) - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_ice_spike_large.mts" + local path = modpath.."/schematics/mcl_structures_ice_spike_large.mts" return minetest.place_schematic(pos, path, rotation or "random", nil, false) -- don't serialize schematics for registered biome decorations, for MT 5.4.0 end @@ -318,22 +318,22 @@ function mcl_structures.generate_fossil(pos, rotation, pr) "mcl_structures_fossil_spine_4.mts", -- 8×5×13 } local r = pr:next(1, #fossils) - local path = minetest.get_modpath("mcl_structures").."/schematics/"..fossils[r] + local path = modpath.."/schematics/"..fossils[r] return mcl_structures.place_schematic(newpos, path, rotation or "random", nil, true) end function mcl_structures.generate_end_exit_portal(pos, rot) - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts" + local path = modpath.."/schematics/mcl_structures_end_exit_portal.mts" return mcl_structures.place_schematic(pos, path, rot or "0", {["mcl_portals:portal_end"] = "air"}, true) end function mcl_structures.generate_end_exit_portal_open(pos, rot) - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts" + local path = modpath.."/schematics/mcl_structures_end_exit_portal.mts" return mcl_structures.place_schematic(pos, path, rot or "0", nil, true) end function mcl_structures.generate_end_gateway_portal(pos, rot) - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_gateway_portal.mts" + local path = modpath.."/schematics/mcl_structures_end_gateway_portal.mts" return mcl_structures.place_schematic(pos, path, rot or "0", nil, true) end @@ -367,7 +367,7 @@ local function shrine_placement_callback(p1, p2, size, rotation, pr) end -- 50% stonebrick (no change necessary) end - if bricktype ~= nil then + if bricktype then minetest.set_node(bricks[b], { name = bricktype }) end end @@ -420,7 +420,7 @@ function mcl_structures.generate_end_portal_shrine(pos, rotation, pr) --local size = {x=13, y=8, z=13} local newpos = { x = pos.x - offset.x, y = pos.y, z = pos.z - offset.z } - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_portal_room_simple.mts" + local path = modpath.."/schematics/mcl_structures_end_portal_room_simple.mts" mcl_structures.place_schematic(newpos, path, rotation or "0", nil, true, nil, shrine_placement_callback, pr) end @@ -500,7 +500,7 @@ end function mcl_structures.generate_desert_temple(pos, rotation, pr) -- No Generating for the temple ... Why using it ? No Change - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_desert_temple.mts" + local path = modpath.."/schematics/mcl_structures_desert_temple.mts" local newpos = {x=pos.x,y=pos.y-12,z=pos.z} --local size = {x=22, y=24, z=22} if newpos == nil then diff --git a/mods/MAPGEN/mcl_villages/buildings.lua b/mods/MAPGEN/mcl_villages/buildings.lua index 3f4490bf9..a69029063 100644 --- a/mods/MAPGEN/mcl_villages/buildings.lua +++ b/mods/MAPGEN/mcl_villages/buildings.lua @@ -187,10 +187,10 @@ local function construct_node(p1, p2, name) end return nodes end - minetest.log("warning","[mcl_villages] No on_construct defined for node name " .. name) + minetest.log("warning", "[mcl_villages] No on_construct defined for node name " .. name) return end - minetest.log("warning","[mcl_villages] Attempt to 'construct' inexistant nodes: " .. name) + minetest.log("warning", "[mcl_villages] Attempt to 'construct' inexistant nodes: " .. name) end local function init_nodes(p1, p2, size, rotation, pr) construct_node(p1, p2, "mcl_itemframes:item_frame") diff --git a/mods/MAPGEN/mcl_villages/init.lua b/mods/MAPGEN/mcl_villages/init.lua index ccc3f585d..7e460990e 100644 --- a/mods/MAPGEN/mcl_villages/init.lua +++ b/mods/MAPGEN/mcl_villages/init.lua @@ -1,5 +1,5 @@ settlements = {} -settlements.modpath = minetest.get_modpath("mcl_villages") +settlements.modpath = minetest.get_modpath(minetest.get_current_modname()) dofile(settlements.modpath.."/const.lua") dofile(settlements.modpath.."/utils.lua") @@ -37,7 +37,7 @@ minetest.register_node("mcl_villages:stonebrickcarved", { -- -- register inhabitants -- -if minetest.get_modpath("mobs_mc") ~= nil then +if minetest.get_modpath("mobs_mc") then mobs:register_spawn("mobs_mc:villager", --name {"mcl_core:stonebrickcarved"}, --nodes 15, --max_light diff --git a/mods/MAPGEN/tsm_railcorridors/init.lua b/mods/MAPGEN/tsm_railcorridors/init.lua index d7a074a00..65a7d6a69 100644 --- a/mods/MAPGEN/tsm_railcorridors/init.lua +++ b/mods/MAPGEN/tsm_railcorridors/init.lua @@ -1,3 +1,6 @@ +local pairs = pairs +local tonumber = tonumber + tsm_railcorridors = {} -- Load node names @@ -8,7 +11,7 @@ local setting -- Probability function -- TODO: Check if this is correct -local P = function (float) +local function P(float) return math.floor(32767 * float) end @@ -80,14 +83,14 @@ end -- Enable cobwebs local place_cobwebs = true setting = minetest.settings:get_bool("tsm_railcorridors_place_cobwebs") -if setting ~= nil then +if setting then place_cobwebs = setting end -- Enable mob spawners local place_mob_spawners = true setting = minetest.settings:get_bool("tsm_railcorridors_place_mob_spawners") -if setting ~= nil then +if setting then place_mob_spawners = setting end @@ -175,7 +178,7 @@ end -- Tries to place a rail, taking the damage chance into account local function PlaceRail(pos, damage_chance) - if damage_chance ~= nil and damage_chance > 0 then + if damage_chance and damage_chance > 0 then local x = pr:next(0,100) if x <= damage_chance then return false @@ -395,7 +398,7 @@ local function RecheckCartHack(params) local cart_id = params[2] -- Find cart for _, obj in pairs(minetest.get_objects_inside_radius(pos, 1)) do - if obj ~= nil and obj:get_luaentity().name == cart_id then + if obj and obj:get_luaentity().name == cart_id then -- Cart found! We can now safely call the callback func. -- (calling it earlier has the danger of failing) minetest.log("info", "[tsm_railcorridors] Cart spawn succeeded: "..minetest.pos_to_string(pos)) diff --git a/mods/MISC/findbiome/init.lua b/mods/MISC/findbiome/init.lua index 5f55da493..8560d1607 100644 --- a/mods/MISC/findbiome/init.lua +++ b/mods/MISC/findbiome/init.lua @@ -1,6 +1,6 @@ -local S = minetest.get_translator("findbiome") +local S = minetest.get_translator(minetest.get_current_modname()) -local mod_biomeinfo = minetest.get_modpath("biomeinfo") ~= nil +local mod_biomeinfo = minetest.get_modpath("biomeinfo") local mg_name = minetest.get_mapgen_setting("mg_name") local water_level = tonumber(minetest.get_mapgen_setting("water_level")) diff --git a/mods/MISC/mcl_commands/alias.lua b/mods/MISC/mcl_commands/alias.lua index 2989b7b37..5c9ee9f3c 100644 --- a/mods/MISC/mcl_commands/alias.lua +++ b/mods/MISC/mcl_commands/alias.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) local function register_chatcommand_alias(alias, cmd) local def = minetest.chatcommands[cmd] diff --git a/mods/MISC/mcl_commands/kill.lua b/mods/MISC/mcl_commands/kill.lua index 85754a0ec..becd42917 100644 --- a/mods/MISC/mcl_commands/kill.lua +++ b/mods/MISC/mcl_commands/kill.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) local function handle_kill_command(suspect, victim) if minetest.settings:get_bool("enable_damage") == false then diff --git a/mods/MISC/mcl_commands/list.lua b/mods/MISC/mcl_commands/list.lua index 0257e2837..5661454b4 100644 --- a/mods/MISC/mcl_commands/list.lua +++ b/mods/MISC/mcl_commands/list.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_chatcommand("list", { description = S("Show who is logged on"), diff --git a/mods/MISC/mcl_commands/say.lua b/mods/MISC/mcl_commands/say.lua index 2b01a7e93..9fd53c174 100644 --- a/mods/MISC/mcl_commands/say.lua +++ b/mods/MISC/mcl_commands/say.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_privilege("announce", { description = S("Can use /say"), diff --git a/mods/MISC/mcl_commands/seed.lua b/mods/MISC/mcl_commands/seed.lua index da5f6a303..6a99d53cb 100644 --- a/mods/MISC/mcl_commands/seed.lua +++ b/mods/MISC/mcl_commands/seed.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_chatcommand("seed", { description = S("Displays the world seed"), diff --git a/mods/MISC/mcl_commands/setblock.lua b/mods/MISC/mcl_commands/setblock.lua index dc834e1e8..95acdd35d 100644 --- a/mods/MISC/mcl_commands/setblock.lua +++ b/mods/MISC/mcl_commands/setblock.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_chatcommand("setblock", { params = S(",, "), diff --git a/mods/MISC/mcl_commands/sound.lua b/mods/MISC/mcl_commands/sound.lua index 06225271d..5833676f3 100644 --- a/mods/MISC/mcl_commands/sound.lua +++ b/mods/MISC/mcl_commands/sound.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_chatcommand("playsound",{ params = S(" "), --TODO:add source diff --git a/mods/MISC/mcl_commands/summon.lua b/mods/MISC/mcl_commands/summon.lua index eb6066ff8..69da0a66c 100644 --- a/mods/MISC/mcl_commands/summon.lua +++ b/mods/MISC/mcl_commands/summon.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_commands") +local S = minetest.get_translator(minetest.get_current_modname()) local orig_func = minetest.registered_chatcommands["spawnentity"].func local cmd = table.copy(minetest.registered_chatcommands["spawnentity"]) diff --git a/mods/MISC/mcl_privs/init.lua b/mods/MISC/mcl_privs/init.lua index 00670db1c..63694ab11 100644 --- a/mods/MISC/mcl_privs/init.lua +++ b/mods/MISC/mcl_privs/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_privs") +local S = minetest.get_translator(minetest.get_current_modname()) minetest.register_privilege("maphack", { description = S("Can place and use advanced blocks like mob spawners, command blocks and barriers."), diff --git a/mods/MISC/mcl_temp_helper_recipes/init.lua b/mods/MISC/mcl_temp_helper_recipes/init.lua index ff9f541f3..420cd6c2e 100644 --- a/mods/MISC/mcl_temp_helper_recipes/init.lua +++ b/mods/MISC/mcl_temp_helper_recipes/init.lua @@ -4,7 +4,7 @@ minetest.register_craft({ type = "shapeless", - output = 'mcl_chests:trapped_chest', + output = "mcl_chests:trapped_chest", recipe = {"mcl_core:iron_ingot", "mcl_core:stick", "group:wood", "mcl_chests:chest"}, }) diff --git a/mods/MISC/mcl_wip/init.lua b/mods/MISC/mcl_wip/init.lua index 0eb56dd84..54fd81c1d 100644 --- a/mods/MISC/mcl_wip/init.lua +++ b/mods/MISC/mcl_wip/init.lua @@ -1,6 +1,6 @@ --- Mod to mark WIP (Work In Progress) content +-- Allow items or nodes to be marked as WIP (Work In Progress) or Experimental -local S = minetest.get_translator("mcl_wip") +local S = minetest.get_translator(minetest.get_current_modname()) mcl_wip = {} mcl_wip.registered_wip_items = {} diff --git a/mods/PLAYER/mcl_death_drop/init.lua b/mods/PLAYER/mcl_death_drop/init.lua index fca566a37..bfeee0c3e 100644 --- a/mods/PLAYER/mcl_death_drop/init.lua +++ b/mods/PLAYER/mcl_death_drop/init.lua @@ -1,11 +1,13 @@ local random = math.random +local ipairs = ipairs + mcl_death_drop = {} mcl_death_drop.registered_dropped_lists = {} function mcl_death_drop.register_dropped_list(inv, listname, drop) - table.insert(mcl_death_drop.registered_dropped_lists, {inv=inv, listname=listname, drop=drop}) + table.insert(mcl_death_drop.registered_dropped_lists, {inv = inv, listname = listname, drop = drop}) end mcl_death_drop.register_dropped_list("PLAYER", "main", true) @@ -30,7 +32,7 @@ minetest.register_on_dieplayer(function(player) end local listname = mcl_death_drop.registered_dropped_lists[l].listname local drop = mcl_death_drop.registered_dropped_lists[l].drop - if inv ~= nil then + if inv then for i, stack in ipairs(inv:get_list(listname)) do local x = random(0, 9)/3 local z = random(0, 9)/3 diff --git a/mods/PLAYER/mcl_hunger/api.lua b/mods/PLAYER/mcl_hunger/api.lua index 4fea9b04e..20937023a 100644 --- a/mods/PLAYER/mcl_hunger/api.lua +++ b/mods/PLAYER/mcl_hunger/api.lua @@ -76,7 +76,7 @@ if mcl_hunger.active then satuchanged = true end if satuchanged then - if h ~= nil then h = h end + if h then h = h end mcl_hunger.update_saturation_hud(player, mcl_hunger.get_saturation(player), h) end end diff --git a/mods/PLAYER/mcl_hunger/hunger.lua b/mods/PLAYER/mcl_hunger/hunger.lua index cf422dbf0..5dec8b1b0 100644 --- a/mods/PLAYER/mcl_hunger/hunger.lua +++ b/mods/PLAYER/mcl_hunger/hunger.lua @@ -1,8 +1,7 @@ ---local S = minetest.get_translator("mcl_hunger") +--local S = minetest.get_translator(minetest.get_current_modname()) -- wrapper for minetest.item_eat (this way we make sure other mods can't break this one) -minetest.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing) - +function minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing) if not user or user:is_player() == false then return itemstack end @@ -122,7 +121,7 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poiso return function(itemstack, user, pointed_thing) local itemname = itemstack:get_name() local creative = minetest.is_creative_enabled(user:get_player_name()) - if itemstack:peek_item() ~= nil and user ~= nil then + if itemstack:peek_item() and user then if not creative then itemstack:take_item() end diff --git a/mods/PLAYER/mcl_hunger/init.lua b/mods/PLAYER/mcl_hunger/init.lua index d212e631a..8c154700a 100644 --- a/mods/PLAYER/mcl_hunger/init.lua +++ b/mods/PLAYER/mcl_hunger/init.lua @@ -1,4 +1,7 @@ -local S = minetest.get_translator("mcl_hunger") +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) + +local S = minetest.get_translator(modname) mcl_hunger = {} @@ -36,9 +39,9 @@ mcl_hunger.debug = false -- Cooldown timers for each player, to force a short delay between consuming 2 food items mcl_hunger.last_eat = {} -dofile(minetest.get_modpath("mcl_hunger").."/api.lua") -dofile(minetest.get_modpath("mcl_hunger").."/hunger.lua") -dofile(minetest.get_modpath("mcl_hunger").."/register_foods.lua") +dofile(modpath.."/api.lua") +dofile(modpath.."/hunger.lua") +dofile(modpath.."/register_foods.lua") --[[ IF HUNGER IS ENABLED ]] if mcl_hunger.active == true then diff --git a/mods/PLAYER/mcl_skins/init.lua b/mods/PLAYER/mcl_skins/init.lua index fb91d74d3..6d5461a98 100644 --- a/mods/PLAYER/mcl_skins/init.lua +++ b/mods/PLAYER/mcl_skins/init.lua @@ -1,12 +1,14 @@ -- Skins for MineClone 2 +local modname = minetest.get_current_modname() + mcl_skins = { skins = {}, list = {}, previews = {}, meta = {}, has_preview = {}, - modpath = minetest.get_modpath("mcl_skins"), + modpath = minetest.get_modpath(modname), skin_count = 0, -- counter of _custom_ skins (all skins except character.png) } -local S = minetest.get_translator("mcl_skins") +local S = minetest.get_translator(modname) local has_mcl_inventory = minetest.get_modpath("mcl_inventory") -- load skin list and metadata @@ -53,7 +55,7 @@ while true do data = nil if f then - data = minetest.deserialize("return {" .. f:read('*all') .. "}") + data = minetest.deserialize("return {" .. f:read("*all") .. "}") f:close() end @@ -138,7 +140,7 @@ minetest.register_on_joinplayer(function(player) local skin_id = player:get_meta():get_string("mcl_skins:skin_id") local set_skin -- do we already have a skin in player attributes? - if skin_id ~= nil and skin_id ~= "" then + if skin_id and skin_id ~= "" then set_skin = tonumber(skin_id) -- otherwise use random skin if not set end @@ -220,7 +222,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if mcl_skins.skin_count <= 6 then -- Change skin immediately if there are not many skins mcl_skins.cycle_skin(player) - if player:get_attach() ~= nil then + if player:get_attach() then mcl_player.player_set_animation(player, "sit") end else diff --git a/mods/PLAYER/mcl_spawn/init.lua b/mods/PLAYER/mcl_spawn/init.lua index b8c746d1f..113a4d27f 100644 --- a/mods/PLAYER/mcl_spawn/init.lua +++ b/mods/PLAYER/mcl_spawn/init.lua @@ -1,6 +1,6 @@ mcl_spawn = {} -local S = minetest.get_translator("mcl_spawn") +local S = minetest.get_translator(minetest.get_current_modname()) local mg_name = minetest.get_mapgen_setting("mg_name") local storage = minetest.get_mod_storage() @@ -379,7 +379,7 @@ function mcl_spawn.search() end -mcl_spawn.get_world_spawn_pos = function() +function mcl_spawn.get_world_spawn_pos() local ssp = minetest.setting_get_pos("static_spawnpoint") if ssp then return ssp @@ -395,7 +395,7 @@ end -- If player is nil or not a player, a world spawn point is returned. -- The second return value is true if returned spawn point is player-chosen, -- false otherwise. -mcl_spawn.get_bed_spawn_pos = function(player) +function mcl_spawn.get_bed_spawn_pos(player) local spawn, custom_spawn = nil, false if player and player:is_player() then local attr = player:get_meta():get_string("mcl_beds:spawn") @@ -415,7 +415,7 @@ end -- Set pos to nil to clear the spawn position. -- If message is set, informs the player with a chat message when the spawn position -- changed. -mcl_spawn.set_spawn_pos = function(player, pos, message) +function mcl_spawn.set_spawn_pos(player, pos, message) local spawn_changed = false local meta = player:get_meta() if pos == nil then @@ -443,7 +443,7 @@ mcl_spawn.set_spawn_pos = function(player, pos, message) return spawn_changed end -mcl_spawn.get_player_spawn_pos = function(player) +function mcl_spawn.get_player_spawn_pos(player) local pos, custom_spawn = mcl_spawn.get_bed_spawn_pos(player) if pos and custom_spawn then -- Check if bed is still there @@ -451,7 +451,7 @@ mcl_spawn.get_player_spawn_pos = function(player) local bgroup = minetest.get_item_group(node_bed.name, "bed") if bgroup ~= 1 and bgroup ~= 2 then -- Bed is destroyed: - if player ~= nil and player:is_player() then + if player and player:is_player() then player:get_meta():set_string("mcl_beds:spawn", "") end minetest.chat_send_player(player:get_player_name(), S("Your spawn bed was missing or blocked.")) @@ -482,7 +482,7 @@ mcl_spawn.get_player_spawn_pos = function(player) return mcl_spawn.get_world_spawn_pos(), false end -mcl_spawn.spawn = function(player) +function mcl_spawn.spawn(player) local pos, in_bed = mcl_spawn.get_player_spawn_pos(player) player:set_pos(pos) return in_bed or success diff --git a/mods/PLAYER/mcl_sprint/init.lua b/mods/PLAYER/mcl_sprint/init.lua index 546a5f4f0..73a518c42 100644 --- a/mods/PLAYER/mcl_sprint/init.lua +++ b/mods/PLAYER/mcl_sprint/init.lua @@ -7,6 +7,22 @@ to this software to the public domain worldwide. This software is distributed without any warranty. ]] +local math = math +local vector = vector + +local pairs = pairs + +local get_node = minetest.get_node +local get_gametime = minetest.get_gametime +local add_particlespawner = minetest.add_particlespawner +local get_player_by_name = minetest.get_player_by_name + +local registered_nodes = minetest.registered_nodes + +local get_hunger = mcl_hunger.get_hunger +local exhaust = mcl_hunger.exhaust + + --Configuration variables, these are all explained in README.md mcl_sprint = {} @@ -133,12 +149,12 @@ end) minetest.register_globalstep(function(dtime) --Get the gametime - local gameTime = minetest.get_gametime() + local gameTime = get_gametime() --Loop through all connected players - for playerName,playerInfo in pairs(players) do - local player = minetest.get_player_by_name(playerName) - if player ~= nil then + for playerName, playerInfo in pairs(players) do + local player = get_player_by_name(playerName) + if player then local ctrl = player:get_player_control() --Check if the player should be sprinting if players[playerName]["clientSprint"] or ctrl.aux1 and ctrl.up and not ctrl.sneak then @@ -150,22 +166,21 @@ minetest.register_globalstep(function(dtime) local playerPos = player:get_pos() --If the player is sprinting, create particles behind and cause exhaustion if playerInfo["sprinting"] == true and not player:get_attach() and gameTime % 0.1 == 0 then - -- Exhaust player for sprinting local lastPos = players[playerName].lastPos local dist = vector.distance({x=lastPos.x, y=0, z=lastPos.z}, {x=playerPos.x, y=0, z=playerPos.z}) players[playerName].sprintDistance = players[playerName].sprintDistance + dist if players[playerName].sprintDistance >= 1 then local superficial = math.floor(players[playerName].sprintDistance) - mcl_hunger.exhaust(playerName, mcl_hunger.EXHAUST_SPRINT * superficial) + exhaust(playerName, mcl_hunger.EXHAUST_SPRINT * superficial) players[playerName].sprintDistance = players[playerName].sprintDistance - superficial end -- Sprint node particles - local playerNode = minetest.get_node({x=playerPos["x"], y=playerPos["y"]-1, z=playerPos["z"]}) - local def = minetest.registered_nodes[playerNode.name] + local playerNode = get_node({x=playerPos["x"], y=playerPos["y"]-1, z=playerPos["z"]}) + local def = registered_nodes[playerNode.name] if def and def.walkable then - minetest.add_particlespawner({ + add_particlespawner({ amount = math.random(1, 2), time = 1, minpos = {x=-0.5, y=0.1, z=-0.5}, @@ -192,7 +207,7 @@ 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) + if (mcl_hunger.active and get_hunger(player) <= 6) or (player:get_meta():get_string("mcl_beds:sleeping") == "true") then sprinting = false cancelClientSprinting(playerName) diff --git a/mods/PLAYER/mcl_wieldview/init.lua b/mods/PLAYER/mcl_wieldview/init.lua index fc9ebc074..7200f6186 100644 --- a/mods/PLAYER/mcl_wieldview/init.lua +++ b/mods/PLAYER/mcl_wieldview/init.lua @@ -1,3 +1,6 @@ +local get_connected_players = minetest.get_connected_players +local get_item_group = minetest.get_item_group + mcl_wieldview = { players = {} } @@ -19,7 +22,7 @@ function mcl_wieldview.get_item_texture(itemname) local texture = inv_image - local transform = minetest.get_item_group(itemname, "wieldview_transform") + local transform = get_item_group(itemname, "wieldview_transform") if transform then -- This actually works with groups ratings because transform1, transform2, etc. -- have meaning and transform0 is used for identidy, so it can be ignored @@ -69,8 +72,9 @@ minetest.register_on_leaveplayer(function(player) end) minetest.register_globalstep(function() - for _, player in pairs(minetest.get_connected_players()) do - mcl_wieldview.update_wielded_item(player) + local players = get_connected_players() + for i = 1, #players do + mcl_wieldview.update_wielded_item(players[i]) end end)