diff --git a/.luacheckrc b/.luacheckrc index 556b2e8f0..9d0b8cb2a 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -40,4 +40,16 @@ read_globals = { "factorial" } }, + ------ + --MODS + ------ + + --GENERAL + "default", + + --ENTITIES + "cmi", + + --HUD + "sfinv", "sfinv_buttons", "unified_inventory", "cmsg", "inventory_plus", } \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 21facbd1b..1b5098a4f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ # Contributing to MineClone 2 -So you want to MineClone 2? +So you want to contribute to MineClone 2? Wow, thank you! :-) But first, some things to note: @@ -46,6 +46,28 @@ Your commit names should be relatively descriptive, e.g. when saying "Fix #issue Contributors will be credited in `CREDITS.md`. +## Code Style + +Each mod must provide `mod.conf`. +Each mod which add API functions should store functions inside a global table named like the mod. +Public functions should not use self references but rather just access the table directly. +Functions should be defined in this way: +``` +function mcl_xyz.stuff(param) end +``` +Insteed of this way: +``` +mcl_xyz.stuff = function(param) end +``` +Indentation must be unified, more likely with tabs. + +Time sensitive mods should make a local copy of most used API functions to improve performances. +``` +local vector = vector +local get_node = minetest.get_node +``` + + ## Features > 1.12 If you want to make a feature that was added in a Minecraft version later than 1.12, you should fork MineClone5 (mineclone5 branch in the repository) and add your changes to this. diff --git a/menu/Header.blend b/menu/Header.blend new file mode 100644 index 000000000..78a9f6158 Binary files /dev/null and b/menu/Header.blend differ diff --git a/mods/CORE/_mcl_autogroup/init.lua b/mods/CORE/_mcl_autogroup/init.lua index c8475d0bd..76c68122b 100644 --- a/mods/CORE/_mcl_autogroup/init.lua +++ b/mods/CORE/_mcl_autogroup/init.lua @@ -121,7 +121,7 @@ local hardness_values = get_hardness_values_for_groups() -- hardness_value. Used for quick lookup. local hardness_lookup = get_hardness_lookup_for_groups(hardness_values) -local function compute_creativetimes(group) +--[[local function compute_creativetimes(group) local creativetimes = {} for index, hardness in pairs(hardness_values[group]) do @@ -129,7 +129,7 @@ local function compute_creativetimes(group) end return creativetimes -end +end]] -- Get the list of digging times for using a specific tool on a specific -- diggroup. @@ -239,13 +239,13 @@ function mcl_autogroup.can_harvest(nodename, toolname) end -- Get one groupcap field for using a specific tool on a specific group. -local function get_groupcap(group, can_harvest, multiplier, efficiency, uses) +--[[local function get_groupcap(group, can_harvest, multiplier, efficiency, uses) return { times = get_digtimes(group, can_harvest, multiplier, efficiency), uses = uses, maxlevel = 0, } -end +end]] -- Returns the tool_capabilities from a tool definition or a default set of -- tool_capabilities @@ -271,7 +271,7 @@ end -- toolname - Name of the tool being enchanted (like "mcl_tools:diamond_pickaxe") -- efficiency - The efficiency level the tool is enchanted with (default 0) -- --- NOTE: +-- NOTE: -- This function can only be called after mod initialization. Otherwise a mod -- would have to add _mcl_autogroup as a dependency which would break the mod -- loading order. @@ -288,7 +288,7 @@ end -- toolname - Name of the tool used -- diggroup - The name of the diggroup the tool is used on -- --- NOTE: +-- NOTE: -- This function can only be called after mod initialization. Otherwise a mod -- would have to add _mcl_autogroup as a dependency which would break the mod -- loading order. @@ -298,7 +298,7 @@ function mcl_autogroup.get_wear(toolname, diggroup) return math.ceil(65535 / uses) end -local overwrite = function() +local function overwrite() for nname, ndef in pairs(minetest.registered_nodes) do local newgroups = table.copy(ndef.groups) if (nname ~= "ignore" and ndef.diggable) then @@ -315,12 +315,12 @@ local overwrite = function() newgroups.opaque = 1 end - local creative_breakable = false + --local creative_breakable = false -- Assign groups used for digging this node depending on -- the registered digging groups for g, gdef in pairs(mcl_autogroup.registered_diggroups) do - creative_breakable = true + --creative_breakable = true local index = hardness_lookup[g][ndef._mcl_hardness or 0] if ndef.groups[g] then if gdef.levels then diff --git a/mods/CORE/biomeinfo/init.lua b/mods/CORE/biomeinfo/init.lua index 5013647ed..950925f9d 100644 --- a/mods/CORE/biomeinfo/init.lua +++ b/mods/CORE/biomeinfo/init.lua @@ -81,11 +81,11 @@ if v6_use_snow_biomes then end local v6_freq_desert = tonumber(minetest.get_mapgen_setting("mgv6_freq_desert") or 0.45) -local NOISE_MAGIC_X = 1619 -local NOISE_MAGIC_Y = 31337 -local NOISE_MAGIC_Z = 52591 -local NOISE_MAGIC_SEED = 1013 -local noise2d = function(x, y, seed) +--local NOISE_MAGIC_X = 1619 +--local NOISE_MAGIC_Y = 31337 +--local NOISE_MAGIC_Z = 52591 +--local NOISE_MAGIC_SEED = 1013 +local function noise2d(x, y, seed) -- TODO: implement noise2d function for biome blend return 0 --[[ diff --git a/mods/CORE/flowlib/init.lua b/mods/CORE/flowlib/init.lua index e4e22a20e..ab710e476 100644 --- a/mods/CORE/flowlib/init.lua +++ b/mods/CORE/flowlib/init.lua @@ -1,95 +1,100 @@ +local math = math + +local get_node = minetest.get_node +local get_item_group = minetest.get_item_group + +local registered_nodes = minetest.registered_nodes + flowlib = {} --sum of direction vectors must match an array index + +--(sum,root) +--(0,1), (1,1+0=1), (2,1+1=2), (3,1+2^2=5), (4,2^2+2^2=8) + +local inv_roots = { + [0] = 1, + [1] = 1, + [2] = 0.70710678118655, + [4] = 0.5, + [5] = 0.44721359549996, + [8] = 0.35355339059327, +} + local function to_unit_vector(dir_vector) - --(sum,root) - -- (0,1), (1,1+0=1), (2,1+1=2), (3,1+2^2=5), (4,2^2+2^2=8) - local inv_roots = {[0] = 1, [1] = 1, [2] = 0.70710678118655, [4] = 0.5 - , [5] = 0.44721359549996, [8] = 0.35355339059327} - local sum = dir_vector.x*dir_vector.x + dir_vector.z*dir_vector.z - return {x=dir_vector.x*inv_roots[sum],y=dir_vector.y - ,z=dir_vector.z*inv_roots[sum]} + local sum = dir_vector.x * dir_vector.x + dir_vector.z * dir_vector.z + return {x = dir_vector.x * inv_roots[sum], y = dir_vector.y, z = dir_vector.z * inv_roots[sum]} end -local is_touching = function(realpos,nodepos,radius) +local function is_touching(realpos,nodepos,radius) local boarder = 0.5 - radius - return (math.abs(realpos - nodepos) > (boarder)) + return math.abs(realpos - nodepos) > (boarder) end flowlib.is_touching = is_touching -local is_water = function(pos) - return (minetest.get_item_group(minetest.get_node( - {x=pos.x,y=pos.y,z=pos.z}).name - , "water") ~= 0) +local function is_water(pos) + return get_item_group(get_node(pos).name, "water") ~= 0 end flowlib.is_water = is_water -local node_is_water = function(node) - return (minetest.get_item_group(node.name, "water") ~= 0) +local function node_is_water(node) + return get_item_group(node.name, "water") ~= 0 end flowlib.node_is_water = node_is_water -local is_lava = function(pos) - return (minetest.get_item_group(minetest.get_node( - {x=pos.x,y=pos.y,z=pos.z}).name - , "lava") ~= 0) +local function is_lava(pos) + return get_item_group(get_node(pos).name, "lava") ~= 0 end flowlib.is_lava = is_lava -local node_is_lava = function(node) - return (minetest.get_item_group(node.name, "lava") ~= 0) +local function node_is_lava(node) + return get_item_group(node.name, "lava") ~= 0 end flowlib.node_is_lava = node_is_lava -local is_liquid = function(pos) - return (minetest.get_item_group(minetest.get_node( - {x=pos.x,y=pos.y,z=pos.z}).name - , "liquid") ~= 0) +local function is_liquid(pos) + return get_item_group(get_node(pos).name, "liquid") ~= 0 end flowlib.is_liquid = is_liquid -local node_is_liquid = function(node) - return (minetest.get_item_group(node.name, "liquid") ~= 0) +local function node_is_liquid(node) + return minetest.get_item_group(node.name, "liquid") ~= 0 end flowlib.node_is_liquid = node_is_liquid --This code is more efficient -local function quick_flow_logic(node,pos_testing,direction) +local function quick_flow_logic(node, pos_testing, direction) local name = node.name - if not minetest.registered_nodes[name] then + if not registered_nodes[name] then return 0 end - if minetest.registered_nodes[name].liquidtype == "source" then - local node_testing = minetest.get_node(pos_testing) - local param2_testing = node_testing.param2 - if not minetest.registered_nodes[node_testing.name] then + if registered_nodes[name].liquidtype == "source" then + local node_testing = get_node(pos_testing) + if not registered_nodes[node_testing.name] then return 0 end - if minetest.registered_nodes[node_testing.name].liquidtype - ~= "flowing" then + if registered_nodes[node_testing.name].liquidtype ~= "flowing" then return 0 else return direction end - elseif minetest.registered_nodes[name].liquidtype == "flowing" then - local node_testing = minetest.get_node(pos_testing) + elseif registered_nodes[name].liquidtype == "flowing" then + local node_testing = get_node(pos_testing) local param2_testing = node_testing.param2 - if not minetest.registered_nodes[node_testing.name] then + if not registered_nodes[node_testing.name] then return 0 end - if minetest.registered_nodes[node_testing.name].liquidtype - == "source" then + if registered_nodes[node_testing.name].liquidtype == "source" then return -direction - elseif minetest.registered_nodes[node_testing.name].liquidtype - == "flowing" then + elseif registered_nodes[node_testing.name].liquidtype == "flowing" then if param2_testing < node.param2 then if (node.param2 - param2_testing) > 6 then return -direction @@ -108,48 +113,41 @@ local function quick_flow_logic(node,pos_testing,direction) return 0 end -local quick_flow = function(pos,node) - local x = 0 - local z = 0 - +local function quick_flow(pos, node) if not node_is_liquid(node) then - return {x=0,y=0,z=0} + return {x = 0, y = 0, z = 0} end - - x = x + quick_flow_logic(node,{x=pos.x-1,y=pos.y,z=pos.z},-1) - x = x + quick_flow_logic(node,{x=pos.x+1,y=pos.y,z=pos.z}, 1) - z = z + quick_flow_logic(node,{x=pos.x,y=pos.y,z=pos.z-1},-1) - z = z + quick_flow_logic(node,{x=pos.x,y=pos.y,z=pos.z+1}, 1) - - return to_unit_vector({x=x,y=0,z=z}) + local x = quick_flow_logic(node,{x = pos.x-1, y = pos.y, z = pos.z},-1) + quick_flow_logic(node,{x = pos.x+1, y = pos.y, z = pos.z}, 1) + local z = quick_flow_logic(node,{x = pos.x, y = pos.y, z = pos.z-1},-1) + quick_flow_logic(node,{x = pos.x, y = pos.y, z = pos.z+1}, 1) + return to_unit_vector({x = x, y = 0, z = z}) end flowlib.quick_flow = quick_flow +--if not in water but touching, move centre to touching block +--x has higher precedence than z +--if pos changes with x, it affects z - --if not in water but touching, move centre to touching block - --x has higher precedence than z - --if pos changes with x, it affects z -local move_centre = function(pos,realpos,node,radius) - if is_touching(realpos.x,pos.x,radius) then - if is_liquid({x=pos.x-1,y=pos.y,z=pos.z}) then - node = minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}) - pos = {x=pos.x-1,y=pos.y,z=pos.z} - elseif is_liquid({x=pos.x+1,y=pos.y,z=pos.z}) then - node = minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}) - pos = {x=pos.x+1,y=pos.y,z=pos.z} +local function move_centre(pos, realpos, node, radius) + if is_touching(realpos.x, pos.x, radius) then + if is_liquid({x = pos.x-1, y = pos.y, z = pos.z}) then + node = get_node({x=pos.x-1, y = pos.y, z = pos.z}) + pos = {x = pos.x-1, y = pos.y, z = pos.z} + elseif is_liquid({x = pos.x+1, y = pos.y, z = pos.z}) then + node = get_node({x = pos.x+1, y = pos.y, z = pos.z}) + pos = {x = pos.x+1, y = pos.y, z = pos.z} end end - if is_touching(realpos.z,pos.z,radius) then - if is_liquid({x=pos.x,y=pos.y,z=pos.z-1}) then - node = minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}) - pos = {x=pos.x,y=pos.y,z=pos.z-1} - elseif is_liquid({x=pos.x,y=pos.y,z=pos.z+1}) then - node = minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}) - pos = {x=pos.x,y=pos.y,z=pos.z+1} + if is_touching(realpos.z, pos.z, radius) then + if is_liquid({x = pos.x, y = pos.y, z = pos.z - 1}) then + node = get_node({x = pos.x, y = pos.y, z = pos.z - 1}) + pos = {x = pos.x, y = pos.y, z = pos.z - 1} + elseif is_liquid({x = pos.x, y = pos.y, z = pos.z + 1}) then + node = get_node({x = pos.x, y = pos.y, z = pos.z + 1}) + pos = {x = pos.x, y = pos.y, z = pos.z + 1} end end - return pos,node + return pos, node end flowlib.move_centre = move_centre diff --git a/mods/CORE/mcl_attached/init.lua b/mods/CORE/mcl_attached/init.lua index 146cb2251..4f538e104 100644 --- a/mods/CORE/mcl_attached/init.lua +++ b/mods/CORE/mcl_attached/init.lua @@ -1,17 +1,21 @@ +local vector = vector + +local facedir_to_dir = minetest.facedir_to_dir +local get_item_group = minetest.get_item_group +local remove_node = minetest.remove_node +local get_node = minetest.get_node + local original_function = minetest.check_single_for_falling -minetest.check_single_for_falling = function(pos) +function minetest.check_single_for_falling(pos) local ret_o = original_function(pos) - local ret = false local node = minetest.get_node(pos) - if minetest.get_item_group(node.name, "attached_node_facedir") ~= 0 then - local dir = minetest.facedir_to_dir(node.param2) + if get_item_group(node.name, "attached_node_facedir") ~= 0 then + local dir = facedir_to_dir(node.param2) if dir then - local cpos = vector.add(pos, dir) - local cnode = minetest.get_node(cpos) - if minetest.get_item_group(cnode.name, "solid") == 0 then - minetest.remove_node(pos) + if get_item_group(get_node(vector.add(pos, dir)).name, "solid") == 0 then + remove_node(pos) local drops = minetest.get_node_drops(node.name, "") for dr=1, #drops do minetest.add_item(pos, drops[dr]) @@ -20,7 +24,6 @@ minetest.check_single_for_falling = function(pos) end end end - return ret_o or ret end diff --git a/mods/CORE/mcl_explosions/init.lua b/mods/CORE/mcl_explosions/init.lua index dfae884cd..3a60f2f37 100644 --- a/mods/CORE/mcl_explosions/init.lua +++ b/mods/CORE/mcl_explosions/init.lua @@ -13,9 +13,7 @@ under the LGPLv2.1 license. mcl_explosions = {} local mod_fire = minetest.get_modpath("mcl_fire") ~= nil -local CONTENT_FIRE = minetest.get_content_id("mcl_fire:fire") - -local S = minetest.get_translator("mcl_explosions") +--local CONTENT_FIRE = minetest.get_content_id("mcl_fire:fire") local hash_node_position = minetest.hash_node_position local get_objects_inside_radius = minetest.get_objects_inside_radius @@ -174,14 +172,11 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc local ystride = (emax.x - emin_x + 1) local zstride = ystride * (emax.y - emin_y + 1) - local pos_x = pos.x - local pos_y = pos.y - local pos_z = pos.z - local area = VoxelArea:new { + --[[local area = VoxelArea:new { MinEdge = emin, MaxEdge = emax - } + }]] local data = vm:get_data() local destroy = {} diff --git a/mods/CORE/mcl_explosions/locale/mcl_explosions.de.tr b/mods/CORE/mcl_explosions/locale/mcl_explosions.de.tr deleted file mode 100644 index 4abbc64bf..000000000 --- a/mods/CORE/mcl_explosions/locale/mcl_explosions.de.tr +++ /dev/null @@ -1,2 +0,0 @@ -# textdomain:mcl_explosions -@1 was caught in an explosion.=@1 wurde Opfer einer Explosion. diff --git a/mods/CORE/mcl_explosions/locale/mcl_explosions.fr.tr b/mods/CORE/mcl_explosions/locale/mcl_explosions.fr.tr deleted file mode 100644 index cb9a0f38e..000000000 --- a/mods/CORE/mcl_explosions/locale/mcl_explosions.fr.tr +++ /dev/null @@ -1,2 +0,0 @@ -# textdomain:mcl_explosions -@1 was caught in an explosion.=@1 a été pris dans une explosion. \ No newline at end of file diff --git a/mods/CORE/mcl_explosions/locale/mcl_explosions.ru.tr b/mods/CORE/mcl_explosions/locale/mcl_explosions.ru.tr deleted file mode 100644 index 2c885845f..000000000 --- a/mods/CORE/mcl_explosions/locale/mcl_explosions.ru.tr +++ /dev/null @@ -1,2 +0,0 @@ -# textdomain:mcl_explosions -@1 was caught in an explosion.=@1 не удалось пережить взрыва. diff --git a/mods/CORE/mcl_explosions/locale/template.txt b/mods/CORE/mcl_explosions/locale/template.txt deleted file mode 100644 index 6a9348ddf..000000000 --- a/mods/CORE/mcl_explosions/locale/template.txt +++ /dev/null @@ -1,2 +0,0 @@ -# textdomain:mcl_explosions -@1 was caught in an explosion.= diff --git a/mods/CORE/mcl_loot/init.lua b/mods/CORE/mcl_loot/init.lua index 6db743740..1b2c50807 100644 --- a/mods/CORE/mcl_loot/init.lua +++ b/mods/CORE/mcl_loot/init.lua @@ -40,10 +40,9 @@ function mcl_loot.get_loot(loot_definitions, pr) total_weight = total_weight + (loot_definitions.items[i].weight or 1) end - local stacks_min = loot_definitions.stacks_min - local stacks_max = loot_definitions.stacks_max - if not stacks_min then stacks_min = 1 end - if not stacks_max then stacks_max = 1 end + --local stacks_min = loot_definitions.stacks_min or 1 + --local stacks_max = loot_definitions.stacks_max or 1 + local stacks = pr:next(loot_definitions.stacks_min, loot_definitions.stacks_max) for s=1, stacks do local r = pr:next(1, total_weight) diff --git a/mods/CORE/mcl_particles/init.lua b/mods/CORE/mcl_particles/init.lua index 48e9db8df..4854afd54 100644 --- a/mods/CORE/mcl_particles/init.lua +++ b/mods/CORE/mcl_particles/init.lua @@ -1,3 +1,12 @@ +local vector = vector +local table = table + +local hash_node_position = minetest.hash_node_position +local add_particlespawner = minetest.add_particlespawner +local delete_particlespawner = minetest.delete_particlespawner + +local ipairs = ipairs + mcl_particles = {} -- Table of particlespawner IDs on a per-node hash basis @@ -32,11 +41,11 @@ function mcl_particles.add_node_particlespawner(pos, particlespawner_definition, if allowed_level == 0 or levels[level] > allowed_level then return end - local poshash = minetest.hash_node_position(pos) + local poshash = hash_node_position(pos) if not poshash then return end - local id = minetest.add_particlespawner(particlespawner_definition) + local id = add_particlespawner(particlespawner_definition) if id == -1 then return end @@ -47,6 +56,8 @@ function mcl_particles.add_node_particlespawner(pos, particlespawner_definition, return id end +local add_node_particlespawner = mcl_particles.add_node_particlespawner + -- Deletes all particlespawners that are assigned to a node position. -- If no particlespawners exist for this position, nothing happens. -- pos: Node positon. MUST use integer values! @@ -55,11 +66,11 @@ function mcl_particles.delete_node_particlespawners(pos) if allowed_level == 0 then return false end - local poshash = minetest.hash_node_position(pos) + local poshash = hash_node_position(pos) local ids = particle_nodes[poshash] if ids then for i=1, #ids do - minetest.delete_particlespawner(ids[i]) + delete_particlespawner(ids[i]) end particle_nodes[poshash] = nil return true @@ -72,7 +83,6 @@ end local smoke_pdef_cached = {} function mcl_particles.spawn_smoke(pos, name, smoke_pdef_base) - local min = math.min local new_minpos = vector.add(pos, smoke_pdef_base.minrelpos) local new_maxpos = vector.add(pos, smoke_pdef_base.maxrelpos) @@ -81,7 +91,7 @@ function mcl_particles.spawn_smoke(pos, name, smoke_pdef_base) for i, smoke_pdef in ipairs(smoke_pdef_cached[name]) do smoke_pdef.minpos = new_minpos smoke_pdef.maxpos = new_maxpos - mcl_particles.add_node_particlespawner(pos, smoke_pdef, "high") + add_node_particlespawner(pos, smoke_pdef, "high") end -- cache already populated else @@ -111,13 +121,11 @@ function mcl_particles.spawn_smoke(pos, name, smoke_pdef_base) smoke_pdef.animation.length = exptime + 0.1 -- minexptime must be set such that the last frame is actully rendered, -- even if its very short. Larger exptime -> larger range - smoke_pdef.minexptime = min(exptime, (7.0/8.0 * (exptime + 0.1) + 0.1)) + smoke_pdef.minexptime = math.min(exptime, (7.0/8.0 * (exptime + 0.1) + 0.1)) smoke_pdef.texture = "mcl_particles_smoke_anim.png^[colorize:#000000:" ..colorize - - mcl_particles.add_node_particlespawner(pos, smoke_pdef, "high") - + add_node_particlespawner(pos, smoke_pdef, "high") table.insert(smoke_pdef_cached[name], table.copy(smoke_pdef)) end end end -end +end \ No newline at end of file diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 3af66867b..f5a3ed9e8 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -152,7 +152,7 @@ function mcl_util.get_eligible_transfer_item_slot(src_inventory, src_list, dst_i end -- Returns true if itemstack is a shulker box -local is_not_shulker_box = function(itemstack) +local function is_not_shulker_box(itemstack) local g = minetest.get_item_group(itemstack:get_name(), "shulker_box") return g == 0 or g == nil end @@ -214,7 +214,7 @@ function mcl_util.move_item_container(source_pos, destination_pos, source_list, end -- Normalize double container by forcing to always use the left segment first - local normalize_double_container = function(pos, node, ctype) + local function normalize_double_container(pos, node, ctype) if ctype == 6 then pos = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right") if not pos then @@ -458,14 +458,7 @@ function mcl_util.calculate_durability(itemstack) end end end - if not uses then - local toolcaps = itemstack:get_tool_capabilities() - local groupcaps = toolcaps.groupcaps - for _, v in pairs(groupcaps) do - uses = v.uses - break - end - end + uses = uses or (next(itemstack:get_tool_capabilities().groupcaps) or {}).uses end return uses or 0 diff --git a/mods/CORE/mcl_worlds/init.lua b/mods/CORE/mcl_worlds/init.lua index 435ce51c7..ec8144794 100644 --- a/mods/CORE/mcl_worlds/init.lua +++ b/mods/CORE/mcl_worlds/init.lua @@ -33,15 +33,15 @@ end -- If the Y coordinate is not located in any dimension, it will return: -- nil, "void" function mcl_worlds.y_to_layer(y) - if y >= mcl_vars.mg_overworld_min then - return y - mcl_vars.mg_overworld_min, "overworld" - elseif y >= mcl_vars.mg_nether_min and y <= mcl_vars.mg_nether_max+128 then - return y - mcl_vars.mg_nether_min, "nether" - elseif y >= mcl_vars.mg_end_min and y <= mcl_vars.mg_end_max then - return y - mcl_vars.mg_end_min, "end" - else - return nil, "void" - end + if y >= mcl_vars.mg_overworld_min then + return y - mcl_vars.mg_overworld_min, "overworld" + elseif y >= mcl_vars.mg_nether_min and y <= mcl_vars.mg_nether_max+128 then + return y - mcl_vars.mg_nether_min, "nether" + elseif y >= mcl_vars.mg_end_min and y <= mcl_vars.mg_end_max then + return y - mcl_vars.mg_end_min, "end" + else + return nil, "void" + end end -- Takes a pos and returns the dimension it belongs to (same as above) @@ -55,38 +55,38 @@ end -- MineClone 2. -- mc_dimension is one of "overworld", "nether", "end" (default: "overworld"). function mcl_worlds.layer_to_y(layer, mc_dimension) - if mc_dimension == "overworld" or mc_dimension == nil then - return layer + mcl_vars.mg_overworld_min - elseif mc_dimension == "nether" then - return layer + mcl_vars.mg_nether_min - elseif mc_dimension == "end" then - return layer + mcl_vars.mg_end_min - end + if mc_dimension == "overworld" or mc_dimension == nil then + return layer + mcl_vars.mg_overworld_min + elseif mc_dimension == "nether" then + return layer + mcl_vars.mg_nether_min + elseif mc_dimension == "end" then + return layer + mcl_vars.mg_end_min + end end -- Takes a position and returns true if this position can have weather function mcl_worlds.has_weather(pos) - -- Weather in the Overworld and the high part of the void below - return pos.y <= mcl_vars.mg_overworld_max and pos.y >= mcl_vars.mg_overworld_min - 64 + -- Weather in the Overworld and the high part of the void below + return pos.y <= mcl_vars.mg_overworld_max and pos.y >= mcl_vars.mg_overworld_min - 64 end -- Takes a position and returns true if this position can have Nether dust function mcl_worlds.has_dust(pos) - -- Weather in the Overworld and the high part of the void below - return pos.y <= mcl_vars.mg_nether_max + 138 and pos.y >= mcl_vars.mg_nether_min - 10 + -- Weather in the Overworld and the high part of the void below + return pos.y <= mcl_vars.mg_nether_max + 138 and pos.y >= mcl_vars.mg_nether_min - 10 end -- Takes a position (pos) and returns true if compasses are working here function mcl_worlds.compass_works(pos) - -- It doesn't work in Nether and the End, but it works in the Overworld and in the high part of the void below - local _, dim = mcl_worlds.y_to_layer(pos.y) - if dim == "nether" or dim == "end" then - return false - elseif dim == "void" then - return pos.y <= mcl_vars.mg_overworld_max and pos.y >= mcl_vars.mg_overworld_min - 64 - else - return true - end + -- It doesn't work in Nether and the End, but it works in the Overworld and in the high part of the void below + local _, dim = mcl_worlds.y_to_layer(pos.y) + if dim == "nether" or dim == "end" then + return false + elseif dim == "void" then + return pos.y <= mcl_vars.mg_overworld_max and pos.y >= mcl_vars.mg_overworld_min - 64 + else + return true + end end -- Takes a position (pos) and returns true if clocks are working here @@ -112,11 +112,11 @@ local last_dimension = {} -- * player: Player who changed the dimension -- * dimension: New dimension ("overworld", "nether", "end", "void") function mcl_worlds.dimension_change(player, dimension) - local playername = player:get_player_name() + local playername = player:get_player_name() for i=1, #mcl_worlds.registered_on_dimension_change do mcl_worlds.registered_on_dimension_change[i](player, dimension, last_dimension[playername]) end - last_dimension[playername] = dimension + last_dimension[playername] = dimension end ----------------------- INTERNAL STUFF ---------------------- diff --git a/mods/CORE/walkover/init.lua b/mods/CORE/walkover/init.lua index e57abb8c9..195780ee8 100644 --- a/mods/CORE/walkover/init.lua +++ b/mods/CORE/walkover/init.lua @@ -31,24 +31,21 @@ minetest.register_globalstep(function(dtime) timer = timer + dtime; if timer >= 0.3 then for _,player in pairs(get_connected_players()) do - 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 - - local nodeiamon = get_node(loc) - - if nodeiamon ~= nil then - if on_walk[nodeiamon.name] then - on_walk[nodeiamon.name](loc, nodeiamon, player) - end - for i = 1, #registered_globals do + 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 + local nodeiamon = get_node(loc) + if nodeiamon ~= nil then + if on_walk[nodeiamon.name] then + on_walk[nodeiamon.name](loc, nodeiamon, player) + end + for i = 1, #registered_globals do registered_globals[i](loc, nodeiamon, player) - end - end - end - end - + end + end + end + end timer = 0 end end) diff --git a/mods/ENTITIES/drippingwater/init.lua b/mods/ENTITIES/drippingwater/init.lua index 730cb7b77..e17bdda40 100644 --- a/mods/ENTITIES/drippingwater/init.lua +++ b/mods/ENTITIES/drippingwater/init.lua @@ -1,6 +1,8 @@ --Dripping Water Mod --by kddekadenz +local math = math + -- License of code, textures & sounds: CC0 --Drop entities @@ -20,26 +22,21 @@ minetest.register_entity("drippingwater:drop_water", { spritediv = {x=1, y=1}, initial_sprite_basepos = {x=0, y=0}, static_save = false, - on_activate = function(self, staticdata) self.object:set_sprite({x=0,y=0}, 1, 1, true) end, - on_step = function(self, dtime) - local k = math.random(1,222) - local ownpos = self.object:get_pos() - - if k==1 then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - - if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - + local k = math.random(1,222) + local ownpos = self.object:get_pos() + if k==1 then + self.object:set_acceleration({x=0, y=-5, z=0}) + end + if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then + self.object:set_acceleration({x=0, y=-5, z=0}) + end if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then - self.object:remove() - minetest.sound_play({name="drippingwater_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) + self.object:remove() + minetest.sound_play({name="drippingwater_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) end end, }) @@ -61,27 +58,21 @@ minetest.register_entity("drippingwater:drop_lava", { spritediv = {x=1, y=1}, initial_sprite_basepos = {x=0, y=0}, static_save = false, - on_activate = function(self, staticdata) self.object:set_sprite({x=0,y=0}, 1, 0, true) end, - on_step = function(self, dtime) - local k = math.random(1,222) - local ownpos = self.object:get_pos() - - if k==1 then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - - if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - - + local k = math.random(1,222) + local ownpos = self.object:get_pos() + if k == 1 then + self.object:set_acceleration({x=0, y=-5, z=0}) + end + if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then + self.object:set_acceleration({x=0, y=-5, z=0}) + end if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then - self.object:remove() - minetest.sound_play({name="drippingwater_lavadrip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) + self.object:remove() + minetest.sound_play({name="drippingwater_lavadrip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) end end, }) @@ -90,36 +81,34 @@ minetest.register_entity("drippingwater:drop_lava", { --Create drop -minetest.register_abm( - { +minetest.register_abm({ label = "Create water drops", nodenames = {"group:opaque", "group:leaves"}, neighbors = {"group:water"}, - interval = 2, - chance = 22, - action = function(pos) - if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "water") ~= 0 and - minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then + interval = 2, + chance = 22, + action = function(pos) + if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "water") ~= 0 + and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then local i = math.random(-45,45) / 100 minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_water") end - end, + end, }) --Create lava drop -minetest.register_abm( - { +minetest.register_abm({ label = "Create lava drops", nodenames = {"group:opaque"}, neighbors = {"group:lava"}, - interval = 2, - chance = 22, - action = function(pos) - if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "lava") ~= 0 and - minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then + interval = 2, + chance = 22, + action = function(pos) + if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "lava") ~= 0 + and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then local i = math.random(-45,45) / 100 minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_lava") end - end, -}) + end, +}) \ No newline at end of file diff --git a/mods/ENTITIES/mcl_boats/init.lua b/mods/ENTITIES/mcl_boats/init.lua index 5facec28a..8c187617c 100644 --- a/mods/ENTITIES/mcl_boats/init.lua +++ b/mods/ENTITIES/mcl_boats/init.lua @@ -328,10 +328,10 @@ function boat.on_step(self, dtime, moveresult) p.y = p.y - boat_y_offset local new_velo - local new_acce = {x = 0, y = 0, z = 0} + local new_acce if not is_water(p) and not on_ice then -- Not on water or inside water: Free fall - local nodedef = minetest.registered_nodes[minetest.get_node(p).name] + --local nodedef = minetest.registered_nodes[minetest.get_node(p).name] new_acce = {x = 0, y = -9.8, z = 0} new_velo = get_velocity(self._v, self.object:get_yaw(), self.object:get_velocity().y) diff --git a/mods/ENTITIES/mcl_burning/api.lua b/mods/ENTITIES/mcl_burning/api.lua index 78814a2c7..4cb19cca1 100644 --- a/mods/ENTITIES/mcl_burning/api.lua +++ b/mods/ENTITIES/mcl_burning/api.lua @@ -1,5 +1,3 @@ -local S = minetest.get_translator("mcl_burning") - function mcl_burning.get_storage(obj) return obj:is_player() and mcl_burning.storage[obj] or obj:get_luaentity() end @@ -145,4 +143,4 @@ function mcl_burning.tick(obj, dtime, storage) end end end -end +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_burning/init.lua b/mods/ENTITIES/mcl_burning/init.lua index e223b3566..5cf0d85fe 100644 --- a/mods/ENTITIES/mcl_burning/init.lua +++ b/mods/ENTITIES/mcl_burning/init.lua @@ -1,5 +1,4 @@ -local S = minetest.get_translator("mcl_burning") -local modpath = minetest.get_modpath("mcl_burning") +local modpath = minetest.get_modpath(minetest.get_current_modname()) mcl_burning = { storage = {}, @@ -56,7 +55,6 @@ minetest.register_on_leaveplayer(function(player) local storage = mcl_burning.storage[player] storage.fire_hud_id = nil player:get_meta():set_string("mcl_burning:data", minetest.serialize(storage)) - mcl_burning.storage[player] = nil end) @@ -68,11 +66,10 @@ minetest.register_entity("mcl_burning:fire", { visual = "cube", pointable = false, glow = -1, + backface_culling = false, }, - animation_frame = 0, animation_timer = 0, - on_step = function(self, dtime) local parent, storage = self:sanity_check() diff --git a/mods/ENTITIES/mcl_falling_nodes/init.lua b/mods/ENTITIES/mcl_falling_nodes/init.lua index af2c06703..01681a159 100644 --- a/mods/ENTITIES/mcl_falling_nodes/init.lua +++ b/mods/ENTITIES/mcl_falling_nodes/init.lua @@ -1,7 +1,4 @@ -local S = minetest.get_translator("mcl_falling_nodes") -local has_mcl_armor = minetest.get_modpath("mcl_armor") - -local get_falling_depth = function(self) +local function get_falling_depth(self) if not self._startpos then -- Fallback self._startpos = self.object:get_pos() @@ -9,7 +6,7 @@ local get_falling_depth = function(self) return self._startpos.y - vector.round(self.object:get_pos()).y end -local deal_falling_damage = function(self, dtime) +local function deal_falling_damage(self, dtime) if minetest.get_item_group(self.node.name, "falling_node_damage") == 0 then return end @@ -38,7 +35,7 @@ local deal_falling_damage = function(self, dtime) inv:set_stack("armor", 2, helmet) end end - local deathmsg, dmg_type + local dmg_type if minetest.get_item_group(self.node.name, "anvil") ~= 0 then dmg_type = "anvil" else @@ -60,10 +57,8 @@ minetest.register_entity(":__builtin:falling_node", { collide_with_objects = false, collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, }, - node = {}, meta = {}, - set_node = function(self, node, meta) local def = minetest.registered_nodes[node.name] -- Change falling node if definition tells us to @@ -90,7 +85,6 @@ minetest.register_entity(":__builtin:falling_node", { glow = glow, }) end, - get_staticdata = function(self) local meta = self.meta -- Workaround: Save inventory seperately from metadata. @@ -111,7 +105,6 @@ minetest.register_entity(":__builtin:falling_node", { } return minetest.serialize(ds) end, - on_activate = function(self, staticdata) self.object:set_armor_groups({immortal = 1}) @@ -134,7 +127,6 @@ minetest.register_entity(":__builtin:falling_node", { end self._startpos = vector.round(self._startpos) end, - on_step = function(self, dtime) -- Set gravity local acceleration = self.object:get_acceleration() @@ -186,10 +178,9 @@ minetest.register_entity(":__builtin:falling_node", { return end local nd = minetest.registered_nodes[n2.name] - if n2.name == "mcl_portals:portal_end" then - -- TODO: Teleport falling node. - - elseif (nd and nd.buildable_to == true) or minetest.get_item_group(self.node.name, "crush_after_fall") ~= 0 then + --if n2.name == "mcl_portals:portal_end" then + -- TODO: Teleport falling node. + if (nd and nd.buildable_to == true) or minetest.get_item_group(self.node.name, "crush_after_fall") ~= 0 then -- Replace destination node if it's buildable to minetest.remove_node(np) -- Run script hook @@ -256,7 +247,6 @@ minetest.register_entity(":__builtin:falling_node", { self.object:set_pos(npos) end end - deal_falling_damage(self, dtime) end }) diff --git a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.de.tr b/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.de.tr deleted file mode 100644 index 71dfa4be9..000000000 --- a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.de.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_falling_nodes -@1 was smashed by a falling anvil.=@1 wurde von einem fallenden Amboss zerschmettert. -@1 was smashed by a falling block.=@1 wurde von einem fallenden Block zerschmettert. diff --git a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.es.tr b/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.es.tr deleted file mode 100644 index 41cbf61b4..000000000 --- a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.es.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_falling_nodes -@1 was smashed by a falling anvil.=@1 fue aplastado por la caída de un yunque. -@1 was smashed by a falling block.=@1 fue aplastado por la caída de un bloque. diff --git a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.fr.tr b/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.fr.tr deleted file mode 100644 index 781cd7048..000000000 --- a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.fr.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_falling_nodes -@1 was smashed by a falling anvil.=@1 a été écrasé par une enclume qui tombait. -@1 was smashed by a falling block.=@1 a été écrasé par un bloc qui tombait. diff --git a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.ru.tr b/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.ru.tr deleted file mode 100644 index 6c8b9375a..000000000 --- a/mods/ENTITIES/mcl_falling_nodes/locale/mcl_falling_nodes.ru.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_falling_nodes -@1 was smashed by a falling anvil.=@1 придавило падающей наковальней. -@1 was smashed by a falling block.=@1 раздавило падающим блоком. diff --git a/mods/ENTITIES/mcl_falling_nodes/locale/template.txt b/mods/ENTITIES/mcl_falling_nodes/locale/template.txt deleted file mode 100644 index 4adabaf01..000000000 --- a/mods/ENTITIES/mcl_falling_nodes/locale/template.txt +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_falling_nodes -@1 was smashed by a falling anvil.= -@1 was smashed by a falling block.= diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 895bfc892..a73f586e9 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 = minetest, math, vector, ipairs --this is used for the player pool in the sound buffer local pool = {} @@ -38,7 +38,7 @@ item_drop_settings.drop_single_item = false --if true, the drop control dro item_drop_settings.magnet_time = 0.75 -- how many seconds an item follows the player before giving up -local get_gravity = function() +local function get_gravity() return tonumber(minetest.settings:get("movement_gravity")) or 9.81 end @@ -60,7 +60,7 @@ mcl_item_entity.register_pickup_achievement("mcl_mobitems:blaze_rod", "mcl:blaze mcl_item_entity.register_pickup_achievement("mcl_mobitems:leather", "mcl:killCow") mcl_item_entity.register_pickup_achievement("mcl_core:diamond", "mcl:diamonds") -local check_pickup_achievements = function(object, player) +local function check_pickup_achievements(object, player) if has_awards then local itemname = ItemStack(object:get_luaentity().itemstring):get_name() local playername = player:get_player_name() @@ -72,7 +72,7 @@ local check_pickup_achievements = function(object, player) end end -local enable_physics = function(object, luaentity, ignore_check) +local function enable_physics(object, luaentity, ignore_check) if luaentity.physical_state == false or ignore_check == true then luaentity.physical_state = true object:set_properties({ @@ -83,7 +83,7 @@ local enable_physics = function(object, luaentity, ignore_check) end end -local disable_physics = function(object, luaentity, ignore_check, reset_movement) +local function disable_physics(object, luaentity, ignore_check, reset_movement) if luaentity.physical_state == true or ignore_check == true then luaentity.physical_state = false object:set_properties({ @@ -98,13 +98,11 @@ end minetest.register_globalstep(function(dtime) - tick = not tick for _,player in pairs(minetest.get_connected_players()) do if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then - local name = player:get_player_name() local pos = player:get_pos() @@ -426,13 +424,9 @@ minetest.register_entity(":__builtin:item", { if itemtable then itemname = stack:to_table().name end - local item_texture = nil - local item_type = "" local glow local def = minetest.registered_items[itemname] if def then - item_texture = def.inventory_image - item_type = def.type description = def.description glow = def.light_source end diff --git a/mods/ENTITIES/mcl_minecarts/functions.lua b/mods/ENTITIES/mcl_minecarts/functions.lua index 42cdecd12..2f0dfe0ae 100644 --- a/mods/ENTITIES/mcl_minecarts/functions.lua +++ b/mods/ENTITIES/mcl_minecarts/functions.lua @@ -1,3 +1,5 @@ +local vector = vector + function mcl_minecarts:get_sign(z) if z == 0 then return 0 @@ -38,11 +40,9 @@ end function mcl_minecarts:check_front_up_down(pos, dir_, check_down, railtype) local dir = vector.new(dir_) - local cur = nil - -- Front dir.y = 0 - cur = vector.add(pos, dir) + local cur = vector.add(pos, dir) if mcl_minecarts:is_rail(cur, railtype) then return dir end @@ -65,9 +65,9 @@ end function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype) local pos = vector.round(pos_) - local cur = nil + local cur local left_check, right_check = true, true - + -- Check left and right local left = {x=0, y=0, z=0} local right = {x=0, y=0, z=0} @@ -78,7 +78,7 @@ function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype) left.z = dir.x right.z = -dir.x end - + if ctrl then if old_switch == 1 then left_check = false @@ -100,13 +100,13 @@ function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype) right_check = true end end - + -- Normal cur = mcl_minecarts:check_front_up_down(pos, dir, true, railtype) if cur then return cur end - + -- Left, if not already checked if left_check then cur = mcl_minecarts:check_front_up_down(pos, left, false, railtype) @@ -114,7 +114,7 @@ function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype) return cur end end - + -- Right, if not already checked if right_check then cur = mcl_minecarts:check_front_up_down(pos, right, false, railtype) @@ -122,7 +122,6 @@ function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype) return cur end end - -- Backwards if not old_switch then cur = mcl_minecarts:check_front_up_down(pos, { @@ -134,7 +133,5 @@ function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype) return cur end end - return {x=0, y=0, z=0} -end - +end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_minecarts/init.lua b/mods/ENTITIES/mcl_minecarts/init.lua index 70bf16477..6fd98f550 100644 --- a/mods/ENTITIES/mcl_minecarts/init.lua +++ b/mods/ENTITIES/mcl_minecarts/init.lua @@ -486,7 +486,6 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o if update.pos then self.object:set_pos(pos) end - update = nil end function cart:get_staticdata() @@ -497,7 +496,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o end -- Place a minecart at pointed_thing -mcl_minecarts.place_minecart = function(itemstack, pointed_thing, placer) +function mcl_minecarts.place_minecart(itemstack, pointed_thing, placer) if not pointed_thing.type == "node" then return end @@ -541,7 +540,7 @@ mcl_minecarts.place_minecart = function(itemstack, pointed_thing, placer) end -local register_craftitem = function(itemstring, entity_id, description, tt_help, longdesc, usagehelp, icon, creative) +local function register_craftitem(itemstring, entity_id, description, tt_help, longdesc, usagehelp, icon, creative) entity_mapping[itemstring] = entity_id local groups = { minecart = 1, transport = 1 } @@ -817,31 +816,30 @@ minetest.register_craft({ }) -- TODO: Re-enable crafting of special minecarts when they have been implemented -if false then - minetest.register_craft({ - output = "mcl_minecarts:furnace_minecart", - recipe = { - {"mcl_furnaces:furnace"}, - {"mcl_minecarts:minecart"}, - }, - }) +--[[minetest.register_craft({ + output = "mcl_minecarts:furnace_minecart", + recipe = { + {"mcl_furnaces:furnace"}, + {"mcl_minecarts:minecart"}, + }, +}) - minetest.register_craft({ - output = "mcl_minecarts:hopper_minecart", - recipe = { - {"mcl_hoppers:hopper"}, - {"mcl_minecarts:minecart"}, - }, - }) +minetest.register_craft({ + output = "mcl_minecarts:hopper_minecart", + recipe = { + {"mcl_hoppers:hopper"}, + {"mcl_minecarts:minecart"}, + }, +}) + +minetest.register_craft({ + output = "mcl_minecarts:chest_minecart", + recipe = { + {"mcl_chests:chest"}, + {"mcl_minecarts:minecart"}, + }, +})]] - minetest.register_craft({ - output = "mcl_minecarts:chest_minecart", - recipe = { - {"mcl_chests:chest"}, - {"mcl_minecarts:minecart"}, - }, - }) -end if has_mcl_wip then mcl_wip.register_wip_item("mcl_minecarts:chest_minecart") diff --git a/mods/ENTITIES/mcl_minecarts/rails.lua b/mods/ENTITIES/mcl_minecarts/rails.lua index 4c26aea8c..53ec86d94 100644 --- a/mods/ENTITIES/mcl_minecarts/rails.lua +++ b/mods/ENTITIES/mcl_minecarts/rails.lua @@ -1,7 +1,7 @@ local S = minetest.get_translator("mcl_minecarts") -- Template rail function -local register_rail = function(itemstring, tiles, def_extras, creative) +local function register_rail(itemstring, tiles, def_extras, creative) local groups = {handy=1,pickaxey=1, attached_node=1,rail=1,connect_to_raillike=minetest.raillike_group("rail"),dig_by_water=1,destroy_by_lava_flow=1, transport=1} if creative == false then groups.not_in_creative_inventory = 1 diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index d413bae72..41b522fef 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -11,133 +11,111 @@ local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius local minetest_get_modpath = minetest.get_modpath local minetest_registered_nodes = minetest.registered_nodes local minetest_get_node = minetest.get_node -local minetest_get_item_group = minetest.get_item_group +--local minetest_get_item_group = minetest.get_item_group local minetest_registered_entities = minetest.registered_entities -local minetest_line_of_sight = minetest.line_of_sight -local minetest_after = minetest.after -local minetest_sound_play = minetest.sound_play -local minetest_add_particlespawner = minetest.add_particlespawner -local minetest_registered_items = minetest.registered_items -local minetest_set_node = minetest.set_node +--local minetest_line_of_sight = minetest.line_of_sight +--local minetest_after = minetest.after +--local minetest_sound_play = minetest.sound_play +--local minetest_add_particlespawner = minetest.add_particlespawner +--local minetest_registered_items = minetest.registered_items +--local minetest_set_node = minetest.set_node local minetest_add_item = minetest.add_item -local minetest_get_craft_result = minetest.get_craft_result -local minetest_find_path = minetest.find_path -local minetest_is_protected = minetest.is_protected +--local minetest_get_craft_result = minetest.get_craft_result +--local minetest_find_path = minetest.find_path local minetest_is_creative_enabled = minetest.is_creative_enabled -local minetest_find_node_near = minetest.find_node_near -local minetest_find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air -local minetest_raycast = minetest.raycast -local minetest_get_us_time = minetest.get_us_time +--local minetest_find_node_near = minetest.find_node_near +--local minetest_find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air +--local minetest_raycast = minetest.raycast +--local minetest_get_us_time = minetest.get_us_time local minetest_add_entity = minetest.add_entity -local minetest_get_natural_light = minetest.get_natural_light -local minetest_get_node_or_nil = minetest.get_node_or_nil +--local minetest_get_natural_light = minetest.get_natural_light +--local minetest_get_node_or_nil = minetest.get_node_or_nil -- localize math functions -local math_pi = math.pi -local math_sin = math.sin -local math_cos = math.cos -local math_abs = math.abs -local math_min = math.min -local math_max = math.max -local math_atan = math.atan -local math_random = math.random -local math_floor = math.floor +local math = math -- localize vector functions -local vector_new = vector.new -local vector_add = vector.add -local vector_length = vector.length -local vector_direction = vector.direction -local vector_normalize = vector.normalize -local vector_multiply = vector.multiply -local vector_divide = vector.divide +local vector = vector + +local string = string -- mob constants -local BREED_TIME = 30 -local BREED_TIME_AGAIN = 300 -local CHILD_GROW_TIME = 60*20 -local DEATH_DELAY = 0.5 +--local BREED_TIME = 30 +--local BREED_TIME_AGAIN = 300 +--local CHILD_GROW_TIME = 60*20 +--local DEATH_DELAY = 0.5 local DEFAULT_FALL_SPEED = -10 -local FLOP_HEIGHT = 5.0 -local FLOP_HOR_SPEED = 1.5 +--local FLOP_HEIGHT = 5.0 +--local FLOP_HOR_SPEED = 1.5 local GRAVITY = minetest_settings:get("movement_gravity")-- + 9.81 +local MAX_MOB_NAME_LENGTH = 30 -local MOB_CAP = {} + +--[[local MOB_CAP = {} MOB_CAP.hostile = 70 MOB_CAP.passive = 10 MOB_CAP.ambient = 15 MOB_CAP.water = 15 +]] -- Load main settings -local damage_enabled = minetest_settings:get_bool("enable_damage") -local disable_blood = minetest_settings:get_bool("mobs_disable_blood") -local mobs_drop_items = minetest_settings:get_bool("mobs_drop_items") ~= false -local mobs_griefing = minetest_settings:get_bool("mobs_griefing") ~= false -local spawn_protected = minetest_settings:get_bool("mobs_spawn_protected") ~= false -local remove_far = true +--local damage_enabled = minetest_settings:get_bool("enable_damage") +--local disable_blood = minetest_settings:get_bool("mobs_disable_blood") +--local mobs_drop_items = minetest_settings:get_bool("mobs_drop_items") ~= false +--local mobs_griefing = minetest_settings:get_bool("mobs_griefing") ~= false +--local spawn_protected = minetest_settings:get_bool("mobs_spawn_protected") ~= false +--local remove_far = true local difficulty = tonumber(minetest_settings:get("mob_difficulty")) or 1.0 -local show_health = false -local max_per_block = tonumber(minetest_settings:get("max_objects_per_block") or 64) -local mobs_spawn_chance = tonumber(minetest_settings:get("mobs_spawn_chance") or 2.5) +--local show_health = false +--local max_per_block = tonumber(minetest_settings:get("max_objects_per_block") or 64) +---local mobs_spawn_chance = tonumber(minetest_settings:get("mobs_spawn_chance") or 2.5) -- pathfinding settings -local enable_pathfinding = true -local stuck_timeout = 3 -- how long before mob gets stuck in place and starts searching -local stuck_path_timeout = 10 -- how long will mob follow path before giving up +--local enable_pathfinding = true +--local stuck_timeout = 3 -- how long before mob gets stuck in place and starts searching +--local stuck_path_timeout = 10 -- how long will mob follow path before giving up -- default nodes -local node_ice = "mcl_core:ice" -local node_snowblock = "mcl_core:snowblock" -local node_snow = "mcl_core:snow" +--local node_ice = "mcl_core:ice" +--local node_snowblock = "mcl_core:snowblock" +--local node_snow = "mcl_core:snow" mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt" -local mod_weather = minetest_get_modpath("mcl_weather") ~= nil -local mod_explosions = minetest_get_modpath("mcl_explosions") ~= nil -local mod_mobspawners = minetest_get_modpath("mcl_mobspawners") ~= nil -local mod_hunger = minetest_get_modpath("mcl_hunger") ~= nil -local mod_worlds = minetest_get_modpath("mcl_worlds") ~= nil -local mod_armor = minetest_get_modpath("mcl_armor") ~= nil -local mod_experience = minetest_get_modpath("mcl_experience") ~= nil +--local mod_weather = minetest_get_modpath("mcl_weather") +--local mod_explosions = minetest_get_modpath("mcl_explosions") +local mod_mobspawners = minetest_get_modpath("mcl_mobspawners") +--local mod_hunger = minetest_get_modpath("mcl_hunger") +--local mod_worlds = minetest_get_modpath("mcl_worlds") +--local mod_armor = minetest_get_modpath("mcl_armor") +--local mod_experience = minetest_get_modpath("mcl_experience") -- random locals I found -local los_switcher = false -local height_switcher = false +--local los_switcher = false +--local height_switcher = false -- Get translator local S = minetest.get_translator("mcl_mobs") -- CMI support check -local use_cmi = minetest.global_exists("cmi") - - --- Invisibility mod check -mobs.invis = {} -if minetest.global_exists("invisibility") then - mobs.invis = invisibility -end - +--local use_cmi = minetest.global_exists("cmi") -- creative check function mobs.is_creative(name) return minetest_is_creative_enabled(name) end - -local atan = function(x) +--[[local function atan(x) if not x or x ~= x then return 0 else - return math_atan(x) + return math.atan(x) end -end - - - +end]] -- Shows helpful debug info above each mob -local mobs_debug = minetest_settings:get_bool("mobs_debug", false) +--local mobs_debug = minetest_settings:get_bool("mobs_debug", false) -- Peaceful mode message so players will know there are no monsters if minetest_settings:get_bool("only_peaceful_mobs", false) then @@ -191,7 +169,7 @@ function mobs:register_mob(name, def) if (not value) or (value == default) or (value == special) then return default else - return math_max(min, value * difficulty) + return math.max(min, value * difficulty) end end @@ -366,15 +344,11 @@ function mobs:register_mob(name, def) random_sound_timer_min = 3, random_sound_timer_max = 10, - --head code variables --defaults are for the cow's default --because I don't know what else to set them --to :P - has_head = def.has_head or false, - head_bone = def.head_bone, - --you must use these to adjust the mob's head positions --has_head is used as a logic gate (quick easy check) @@ -444,7 +418,7 @@ function mobs:register_mob(name, def) --on_detach_child = mob_detach_child, on_activate = function(self, staticdata, dtime) - self.object:set_acceleration(vector_new(0,-GRAVITY, 0)) + self.object:set_acceleration(vector.new(0,-GRAVITY, 0)) return mobs.mob_activate(self, staticdata, def, dtime) end, @@ -556,10 +530,10 @@ function mobs:register_arrow(name, def) and def.tail_texture then --do this to prevent clipping through main entity sprite - local pos_adjustment = vector_multiply(vector_normalize(vel), -1) + local pos_adjustment = vector.multiply(vector.normalize(vel), -1) local divider = def.tail_distance_divider or 1 - pos_adjustment = vector_divide(pos_adjustment, divider) - local new_pos = vector_add(pos, pos_adjustment) + pos_adjustment = vector.divide(pos_adjustment, divider) + local new_pos = vector.add(pos, pos_adjustment) minetest.add_particle({ pos = new_pos, velocity = {x = 0, y = 0, z = 0}, @@ -693,12 +667,12 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative) if pos --and within_limits(pos, 0) - and not minetest_is_protected(pos, placer:get_player_name()) then + and not minetest.is_protected(pos, placer:get_player_name()) then local name = placer:get_player_name() local privs = minetest.get_player_privs(name) if mod_mobspawners and under.name == "mcl_mobspawners:spawner" then - if minetest_is_protected(pointed_thing.under, name) then + if minetest.is_protected(pointed_thing.under, name) then minetest.record_protection_violation(pointed_thing.under, name) return itemstack end @@ -743,7 +717,7 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative) nametag = string.sub(nametag, 1, MAX_MOB_NAME_LENGTH) end ent.nametag = nametag - update_tag(ent) + --update_tag(ent) end -- if not in creative then take item diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index d75bda6c6..894a1f5e4 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -1,12 +1,8 @@ -local math_random = math.random -local math_pi = math.pi -local math_floor = math.floor -local math_round = math.round +local math = math +local vector = vector +local string = string -local vector_multiply = vector.multiply -local vector_add = vector.add -local vector_new = vector.new -local vector_distance = vector.distance +local tonumber = tonumber local minetest_yaw_to_dir = minetest.yaw_to_dir local minetest_get_item_group = minetest.get_item_group @@ -17,9 +13,8 @@ local minetest_get_node_light = minetest.get_node_light local DOUBLE_PI = math.pi * 2 local THIRTY_SECONDTH_PI = DOUBLE_PI * 0.03125 - --a simple helper function which is too small to move into movement.lua -local quick_rotate = function(self,dtime) +local function quick_rotate(self,dtime) self.yaw = self.yaw + THIRTY_SECONDTH_PI if self.yaw > DOUBLE_PI then self.yaw = self.yaw - DOUBLE_PI @@ -28,46 +23,45 @@ end --a simple helper function for rounding --http://lua-users.org/wiki/SimpleRound -function round2(num, numDecimalPlaces) +local function round2(num, numDecimalPlaces) return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num)) end --[[ - _ _ + _ _ | | | | | | __ _ _ __ __| | -| | / _` | '_ \ / _` | +| | / _` | '_ \ / _` | | |___| (_| | | | | (_| | \_____/\__,_|_| |_|\__,_| ]]-- --this is basically reverse jump_check -local cliff_check = function(self,dtime) +local function cliff_check(self,dtime) --mobs will flip out if they are falling without this if self.object:get_velocity().y ~= 0 then return false end local pos = self.object:get_pos() - local dir = minetest_yaw_to_dir(self.yaw) + local dir = minetest_yaw_to_dir(self.yaw) local collisionbox = self.object:get_properties().collisionbox local radius = collisionbox[4] + 0.5 - dir = vector_multiply(dir,radius) + dir = vector.multiply(dir,radius) - local free_fall, blocker = minetest_line_of_sight( + local free_fall = minetest_line_of_sight( {x = pos.x + dir.x, y = pos.y, z = pos.z + dir.z}, {x = pos.x + dir.x, y = pos.y - self.fear_height, z = pos.z + dir.z}) return free_fall end - -- state switching logic (stand, walk, run, attacks) local land_state_list_wandering = {"stand", "walk"} -local land_state_switch = function(self, dtime) +local function land_state_switch(self, dtime) --do math before sure not attacking, following, or running away so continue --doing random walking for mobs if all states are not met @@ -93,8 +87,8 @@ local land_state_switch = function(self, dtime) end --ignore everything else if following - if mobs.check_following(self) and - (not self.breed_lookout_timer or (self.breed_lookout_timer and self.breed_lookout_timer == 0)) and + if mobs.check_following(self) and + (not self.breed_lookout_timer or (self.breed_lookout_timer and self.breed_lookout_timer == 0)) and (not self.breed_timer or (self.breed_timer and self.breed_timer == 0)) then self.state = "follow" return @@ -120,7 +114,7 @@ local land_state_switch = function(self, dtime) end -- states are executed here -local land_state_execution = function(self,dtime) +local function land_state_execution(self, dtime) --[[ -- this is a debug which shows the timer and makes mobs breed 100 times faster print(self.breed_timer) @@ -136,7 +130,6 @@ local land_state_execution = function(self,dtime) if not self.object:get_properties() then return end - --timer to time out looking for mate if self.breed_lookout_timer and self.breed_lookout_timer > 0 then @@ -176,12 +169,12 @@ local land_state_execution = function(self,dtime) if velocity.y < 0 then --lua is acting really weird so we have to help it if round2(self.object:get_acceleration().y, 1) == -self.gravity then - self.object:set_acceleration(vector_new(0,0,0)) + self.object:set_acceleration(vector.new(0,0,0)) mobs.mob_fall_slow(self) end else if round2(self.object:get_acceleration().y, 1) == 0 then - self.object:set_acceleration(vector_new(0,-self.gravity,0)) + self.object:set_acceleration(vector.new(0,-self.gravity,0)) end end end @@ -206,15 +199,13 @@ local land_state_execution = function(self,dtime) end mobs.lock_yaw(self) - elseif self.state == "follow" then - + elseif self.state == "follow" then --always look at players mobs.set_yaw_while_following(self) --check distance - local distance_from_follow_person = vector_distance(self.object:get_pos(), self.following_person:get_pos()) + local distance_from_follow_person = vector.distance(self.object:get_pos(), self.following_person:get_pos()) local distance_2d = mobs.get_2d_distance(self.object:get_pos(), self.following_person:get_pos()) - --don't push the player if too close --don't spin around randomly if self.follow_distance < distance_from_follow_person and self.minimum_follow_distance < distance_2d then @@ -240,7 +231,7 @@ local land_state_execution = function(self,dtime) self.walk_timer = math.random(1,6) + math.random() --set the mob into a random direction - self.yaw = (math_random() * (math.pi * 2)) + self.yaw = (math.random() * (math.pi * 2)) end --do animation @@ -253,15 +244,13 @@ local land_state_execution = function(self,dtime) local node_in_front_of = mobs.jump_check(self) if node_in_front_of == 1 then - mobs.jump(self) - - --turn if on the edge of cliff - --(this is written like this because unlike - --jump_check which simply tells the mob to jump - --this requires a mob to turn, removing the - --ease of a full implementation for it in a single - --function) + --turn if on the edge of cliff + --(this is written like this because unlike + --jump_check which simply tells the mob to jump + --this requires a mob to turn, removing the + --ease of a full implementation for it in a single + --function) elseif node_in_front_of == 2 or (self.fear_height ~= 0 and cliff_check(self,dtime)) then --turn 45 degrees if so quick_rotate(self,dtime) @@ -292,9 +281,7 @@ local land_state_execution = function(self,dtime) local node_in_front_of = mobs.jump_check(self) if node_in_front_of == 1 then - mobs.jump(self) - --turn if on the edge of cliff --(this is written like this because unlike --jump_check which simply tells the mob to jump @@ -342,7 +329,7 @@ local land_state_execution = function(self,dtime) mobs.set_velocity(self, self.walk_velocity) --smoosh together basically - if vector_distance(self.object:get_pos(), mate:get_pos()) <= self.breed_distance then + if vector.distance(self.object:get_pos(), mate:get_pos()) <= self.breed_distance then mobs.set_mob_animation(self, "stand") if self.special_breed_timer == 0 then self.special_breed_timer = 2 --breeding takes 2 seconds @@ -353,7 +340,7 @@ local land_state_execution = function(self,dtime) --pop a baby out, it's a miracle! local baby_pos = vector.divide(vector.add(self.object:get_pos(), mate:get_pos()), 2) - local baby_mob = minetest.add_entity(pos, self.name, minetest.serialize({baby = true, grow_up_timer = self.grow_up_goal, bred = true})) + minetest.add_entity(baby_pos, self.name, minetest.serialize({baby = true, grow_up_timer = self.grow_up_goal, bred = true})) mobs.play_sound_specific(self,"item_drop_pickup") @@ -375,14 +362,13 @@ local land_state_execution = function(self,dtime) mobs.set_velocity(self,0) end - end - + end if float_now then mobs.float(self) else local acceleration = self.object:get_acceleration() if acceleration and acceleration.y == 0 then - self.object:set_acceleration(vector_new(0,-self.gravity,0)) + self.object:set_acceleration(vector.new(0,-self.gravity,0)) end end end @@ -391,10 +377,10 @@ end --[[ - _____ _ -/ ___| (_) -\ `--.__ ___ _ __ ___ - `--. \ \ /\ / / | '_ ` _ \ + _____ _ +/ ___| (_) +\ `--.__ ___ _ __ ___ + `--. \ \ /\ / / | '_ ` _ \ /\__/ /\ V V /| | | | | | | \____/ \_/\_/ |_|_| |_| |_| ]]-- @@ -404,7 +390,7 @@ end -- state switching logic (stand, walk, run, attacks) local swim_state_list_wandering = {"stand", "swim"} -local swim_state_switch = function(self, dtime) +local function swim_state_switch(self, dtime) self.state_timer = self.state_timer - dtime if self.state_timer <= 0 then self.state_timer = math.random(4,10) + math.random() @@ -414,41 +400,40 @@ end --check if a mob needs to turn while swimming -local swim_turn_check = function(self,dtime) +local function swim_turn_check(self,dtime) - local pos = self.object:get_pos() - pos.y = pos.y + 0.1 - local dir = minetest_yaw_to_dir(self.yaw) + local pos = self.object:get_pos() + pos.y = pos.y + 0.1 + local dir = minetest_yaw_to_dir(self.yaw) - local collisionbox = self.object:get_properties().collisionbox + local collisionbox = self.object:get_properties().collisionbox local radius = collisionbox[4] + 0.5 - vector_multiply(dir, radius) + vector.multiply(dir, radius) - local test_dir = vector.add(pos,dir) + local test_dir = vector.add(pos,dir) local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0 - return(green_flag_1) + return green_flag_1 end --this is to swap the built in engine acceleration modifier -local swim_physics_swapper = function(self,inside_swim_node) - +local function swim_physics_swapper(self, inside_swim_node) --should be swimming, gravity is applied, switch to floating if inside_swim_node and self.object:get_acceleration().y ~= 0 then - self.object:set_acceleration(vector_new(0,0,0)) + self.object:set_acceleration(vector.new(0,0,0)) --not be swim, gravity isn't applied, switch to falling elseif not inside_swim_node and self.object:get_acceleration().y == 0 then self.pitch = 0 - self.object:set_acceleration(vector_new(0,-self.gravity,0)) + self.object:set_acceleration(vector.new(0,-self.gravity,0)) end end local random_pitch_multiplier = {-1,1} -- states are executed here -local swim_state_execution = function(self,dtime) +local function swim_state_execution(self, dtime) local pos = self.object:get_pos() @@ -465,7 +450,7 @@ local swim_state_execution = function(self,dtime) end --turn gravity on or off - swim_physics_swapper(self,inside_swim_node) + swim_physics_swapper(self, inside_swim_node) --swim properly if inside swim node if inside_swim_node then @@ -482,22 +467,17 @@ local swim_state_execution = function(self,dtime) end mobs.lock_yaw(self) - elseif self.state == "swim" then - self.walk_timer = self.walk_timer - dtime - --reset the walk timer if self.walk_timer <= 0 then - --re-randomize the walk timer self.walk_timer = math.random(1,6) + math.random() - --set the mob into a random direction - self.yaw = (math_random() * (math.pi * 2)) + self.yaw = (math.random() * (math.pi * 2)) --create a truly random pitch, since there is no easy access to pitch math that I can find - self.pitch = math_random() * math.random(1,3) * random_pitch_multiplier[math_random(1,2)] + self.pitch = math.random() * math.random(1,3) * random_pitch_multiplier[math.random(1,2)] end --do animation @@ -535,20 +515,20 @@ end --[[ -______ _ -| ___| | -| |_ | |_ _ +______ _ +| ___| | +| |_ | |_ _ | _| | | | | | | | | | |_| | \_| |_|\__, | - __/ | - |___/ + __/ | + |___/ ]]-- -- state switching logic (stand, walk, run, attacks) local fly_state_list_wandering = {"stand", "fly"} -local fly_state_switch = function(self, dtime) +local function fly_state_switch(self, dtime) if self.hostile and self.attacking then self.state = "attack" @@ -564,41 +544,41 @@ end --check if a mob needs to turn while flying -local fly_turn_check = function(self,dtime) +local function fly_turn_check(self, dtime) - local pos = self.object:get_pos() - pos.y = pos.y + 0.1 - local dir = minetest_yaw_to_dir(self.yaw) + local pos = self.object:get_pos() + pos.y = pos.y + 0.1 + local dir = minetest_yaw_to_dir(self.yaw) - local collisionbox = self.object:get_properties().collisionbox + local collisionbox = self.object:get_properties().collisionbox local radius = collisionbox[4] + 0.5 - vector_multiply(dir, radius) + vector.multiply(dir, radius) - local test_dir = vector.add(pos,dir) + local test_dir = vector.add(pos,dir) local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0 - return(green_flag_1) + return green_flag_1 end --this is to swap the built in engine acceleration modifier -local fly_physics_swapper = function(self,inside_fly_node) +local function fly_physics_swapper(self, inside_fly_node) --should be flyming, gravity is applied, switch to floating if inside_fly_node and self.object:get_acceleration().y ~= 0 then - self.object:set_acceleration(vector_new(0,0,0)) + self.object:set_acceleration(vector.new(0,0,0)) --not be fly, gravity isn't applied, switch to falling elseif not inside_fly_node and self.object:get_acceleration().y == 0 then self.pitch = 0 - self.object:set_acceleration(vector_new(0,-self.gravity,0)) + self.object:set_acceleration(vector.new(0,-self.gravity,0)) end end local random_pitch_multiplier = {-1,1} -- states are executed here -local fly_state_execution = function(self,dtime) +local function fly_state_execution(self, dtime) local pos = self.object:get_pos() pos.y = pos.y + 0.1 local current_node = minetest_get_node(pos).name @@ -635,15 +615,13 @@ local fly_state_execution = function(self,dtime) --reset the walk timer if self.walk_timer <= 0 then - --re-randomize the walk timer self.walk_timer = math.random(1,6) + math.random() - --set the mob into a random direction - self.yaw = (math_random() * (math.pi * 2)) + self.yaw = (math.random() * (math.pi * 2)) --create a truly random pitch, since there is no easy access to pitch math that I can find - self.pitch = math_random() * math.random(1,3) * random_pitch_multiplier[math_random(1,2)] + self.pitch = math.random() * math.random(1,3) * random_pitch_multiplier[math.random(1,2)] end --do animation @@ -663,9 +641,7 @@ local fly_state_execution = function(self,dtime) --enable rotation locking mobs.movement_rotation_lock(self) - elseif self.state == "attack" then - --execute mob attack type --if self.attack_type == "explode" then @@ -697,40 +673,39 @@ end --[[ - ___ - |_ | - | |_ _ _ __ ___ _ __ - | | | | | '_ ` _ \| '_ \ + ___ + |_ | + | |_ _ _ __ ___ _ __ + | | | | | '_ ` _ \| '_ \ /\__/ / |_| | | | | | | |_) | -\____/ \__,_|_| |_| |_| .__/ - | | - |_| +\____/ \__,_|_| |_| |_| .__/ + | | + |_| ]]-- --check if a mob needs to turn while jumping -local jump_turn_check = function(self,dtime) +--[[local function jump_turn_check(self, dtime) + local pos = self.object:get_pos() + pos.y = pos.y + 0.1 + local dir = minetest_yaw_to_dir(self.yaw) - local pos = self.object:get_pos() - pos.y = pos.y + 0.1 - local dir = minetest_yaw_to_dir(self.yaw) - - local collisionbox = self.object:get_properties().collisionbox + local collisionbox = self.object:get_properties().collisionbox local radius = collisionbox[4] + 0.5 - vector_multiply(dir, radius) + vector.multiply(dir, radius) - local test_dir = vector.add(pos,dir) + local test_dir = vector.add(pos,dir) local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0 - return(green_flag_1) -end + return green_flag_1 +end]] -- state switching logic (stand, jump, run, attacks) local jump_state_list_wandering = {"stand", "jump"} -local jump_state_switch = function(self, dtime) +local function jump_state_switch(self, dtime) self.state_timer = self.state_timer - dtime if self.state_timer <= 0 then self.state_timer = math.random(4,10) + math.random() @@ -739,8 +714,8 @@ local jump_state_switch = function(self, dtime) end -- states are executed here -local jump_state_execution = function(self,dtime) - +local function jump_state_execution(self, dtime) + local node_in_front_of = mobs.jump_check(self) local pos = self.object:get_pos() local collisionbox = self.object:get_properties().collisionbox --get the center of the mob @@ -775,7 +750,7 @@ local jump_state_execution = function(self,dtime) self.walk_timer = math.random(1,6) + math.random() --set the mob into a random direction - self.yaw = (math_random() * (math.pi * 2)) + self.yaw = (math.random() * (math.pi * 2)) end --do animation @@ -793,15 +768,10 @@ local jump_state_execution = function(self,dtime) mobs.jump_move(self,self.walk_velocity) elseif self.state == "run" then - print("run") - elseif self.state == "attack" then - print("attack") - - end - + end if float_now then mobs.float(self) end @@ -811,18 +781,18 @@ end --[[ -___ ___ _ _ _ -| \/ | (_) | | (_) -| . . | __ _ _ _ __ | | ___ __ _ _ ___ +___ ___ _ _ _ +| \/ | (_) | | (_) +| . . | __ _ _ _ __ | | ___ __ _ _ ___ | |\/| |/ _` | | '_ \ | | / _ \ / _` | |/ __| -| | | | (_| | | | | | | |___| (_) | (_| | | (__ +| | | | (_| | | | | | | |___| (_) | (_| | | (__ \_| |_/\__,_|_|_| |_| \_____/\___/ \__, |_|\___| - __/ | - |___/ + __/ | + |___/ ]]-- --the main loop -mobs.mob_step = function(self, dtime) +function mobs.mob_step(self, dtime) --do not continue if non-existent if not self or not self.object or not self.object:get_luaentity() then @@ -859,13 +829,13 @@ mobs.mob_step = function(self, dtime) end --color modifier which coincides with the pause_timer - if self.old_health and self.health < self.old_health then + if self.old_health and self.health < self.old_health then self.object:set_texture_mod("^[colorize:red:120") --fix double death sound if self.health > 0 then mobs.play_sound(self,"damage") end - end + end self.old_health = self.health --do death logic (animation, poof, explosion, etc) @@ -916,7 +886,6 @@ mobs.mob_step = function(self, dtime) elseif self.breath < self.breath_max then self.breath = self.breath + dtime - --clean timer reset if self.breath > self.breath_max then self.breath = self.breath_max @@ -948,10 +917,6 @@ mobs.mob_step = function(self, dtime) end end - - - - --baby grows up if self.baby then --print(self.grow_up_timer) @@ -968,8 +933,6 @@ mobs.mob_step = function(self, dtime) mobs.baby_grow_up(self) end end - - --do custom mob instructions if self.do_custom then @@ -1015,7 +978,7 @@ mobs.mob_step = function(self, dtime) self.memory = self.memory - dtime --get if memory player is within viewing range if self.attacking and self.attacking:is_player() then - local distance = vector_distance(self.object:get_pos(), self.attacking:get_pos()) + local distance = vector.distance(self.object:get_pos(), self.attacking:get_pos()) if distance > self.view_range then self.memory = 0 end @@ -1090,7 +1053,7 @@ mobs.mob_step = function(self, dtime) --jump only (like slimes) if self.jump_only then jump_state_switch(self, dtime) - jump_state_execution(self, dtime) + jump_state_execution(self, dtime) --swimming elseif self.swim then swim_state_switch(self, dtime) @@ -1124,28 +1087,22 @@ mobs.mob_step = function(self, dtime) --overrides absolutely everything --mobs get stuck in cobwebs like players if not self.ignores_cobwebs then - local pos = self.object:get_pos() local node = pos and minetest_get_node(pos).name - if node == "mcl_core:cobweb" then - --fight the rest of the api if self.object:get_acceleration().y ~= 0 then - self.object:set_acceleration(vector_new(0,0,0)) + self.object:set_acceleration(vector.new(0,0,0)) end - mobs.stick_in_cobweb(self) - self.was_stuck_in_cobweb = true - else --do not override other functions if self.was_stuck_in_cobweb == true then --return the mob back to normal self.was_stuck_in_cobweb = nil if self.object:get_acceleration().y == 0 and not self.swim and not self.fly then - self.object:set_acceleration(vector_new(0,-self.gravity,0)) + self.object:set_acceleration(vector.new(0,-self.gravity,0)) end end end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua index c26d33089..cea6d838b 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua @@ -1,7 +1,7 @@ -local math_pi = math.pi -local math_floor = math.floor -local math_random = math.random -local HALF_PI = math_pi/2 +local math = math +local vector = vector + +local HALF_PI = math.pi/2 local vector_direction = vector.direction @@ -48,8 +48,7 @@ mobs.set_mob_animation = function(self, anim, fixed_frame) self.animation[anim .. "_speed"] or self.animation.speed_normal or 15, 0, self.animation[anim .. "_loop"] ~= false) - - self.current_animation = anim + self.current_animation = anim end @@ -65,14 +64,14 @@ mobs.death_effect = function(pos, yaw, collisionbox, rotate) max = { x = 0.5, y = 0.5, z = 0.5 } end if rotate then - min = vector.rotate(min, {x=0, y=yaw, z=math_pi/2}) - max = vector.rotate(max, {x=0, y=yaw, z=math_pi/2}) + min = vector.rotate(min, {x=0, y=yaw, z=math.pi/2}) + max = vector.rotate(max, {x=0, y=yaw, z=math.pi/2}) min, max = vector.sort(min, max) min = vector.multiply(min, 0.5) max = vector.multiply(max, 0.5) end - minetest_add_particlespawner({ + minetest.add_particlespawner({ amount = 50, time = 0.001, minpos = vector.add(pos, min), @@ -88,7 +87,7 @@ mobs.death_effect = function(pos, yaw, collisionbox, rotate) texture = "mcl_particles_mob_death.png^[colorize:#000000:255", }) - minetest_sound_play("mcl_mobs_mob_poof", { + minetest.sound_play("mcl_mobs_mob_poof", { pos = pos, gain = 1.0, max_hear_distance = 8, @@ -99,7 +98,6 @@ end --this allows auto facedir rotation while making it so mobs --don't look like wet noodles flopping around mobs.movement_rotation_lock = function(self) - local current_engine_yaw = self.object:get_yaw() local current_lua_yaw = self.yaw @@ -159,7 +157,7 @@ local calculate_pitch = function(self) return false end - return(minetest_dir_to_yaw(vector_new(vector_distance(vector_new(pos.x,0,pos.z),vector_new(pos2.x,0,pos2.z)),0,pos.y - pos2.y)) + HALF_PI) + return minetest_dir_to_yaw(vector_new(vector_distance(vector_new(pos.x,0,pos.z),vector_new(pos2.x,0,pos2.z)),0,pos.y - pos2.y)) + HALF_PI end --this is a helper function used to make mobs pitch rotation dynamically flow when flying/swimming 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 c973f3d1b..f5d33def4 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 @@ -1,11 +1,11 @@ local vector_direction = vector.direction -local minetest_dir_to_yaw = minetest.dir_to_yaw +--local minetest_dir_to_yaw = minetest.dir_to_yaw local vector_distance = vector.distance local vector_multiply = vector.multiply local math_random = math.random --[[ - _ _ _ _ + _ _ _ _ | | | | | | | | | | | | __ _ _ __ __| | | | | | | | / _` | '_ \ / _` | | | @@ -16,14 +16,14 @@ local math_random = math.random --[[ - _____ _ _ -| ___| | | | | -| |____ ___ __ | | ___ __| | ___ + _____ _ _ +| ___| | | | | +| |____ ___ __ | | ___ __| | ___ | __\ \/ / '_ \| |/ _ \ / _` |/ _ \ | |___> <| |_) | | (_) | (_| | __/ \____/_/\_\ .__/|_|\___/ \__,_|\___| - | | - |_| + | | + |_| ]]-- mobs.explode_attack_walk = function(self,dtime) @@ -74,7 +74,6 @@ mobs.explode_attack_walk = function(self,dtime) if node_in_front_of == 1 then mobs.jump(self) end - --do biggening explosion thing if self.explosion_animation and self.explosion_animation > self.explosion_timer then @@ -102,10 +101,10 @@ end --[[ -______ _ -| ___ \ | | -| |_/ / _ _ __ ___| |__ -| __/ | | | '_ \ / __| '_ \ +______ _ +| ___ \ | | +| |_/ / _ _ __ ___| |__ +| __/ | | | '_ \ / __| '_ \ | | | |_| | | | | (__| | | | \_| \__,_|_| |_|\___|_| |_| ]]-- @@ -113,7 +112,6 @@ ______ _ mobs.punch_attack_walk = function(self,dtime) - --this needs an exception if self.attacking == nil or not self.attacking:is_player() then self.attacking = nil @@ -187,14 +185,14 @@ end --[[ -______ _ _ _ _ -| ___ \ (_) | | (_) | -| |_/ / __ ___ _ ___ ___| |_ _| | ___ +______ _ _ _ _ +| ___ \ (_) | | (_) | +| |_/ / __ ___ _ ___ ___| |_ _| | ___ | __/ '__/ _ \| |/ _ \/ __| __| | |/ _ \ | | | | | (_) | | __/ (__| |_| | | __/ \_| |_| \___/| |\___|\___|\__|_|_|\___| - _/ | - |__/ + _/ | + |__/ ]]-- @@ -255,40 +253,39 @@ end --[[ - _ ______ _ _ + _ ______ _ _ | | | ___| | | | | | | |_ | |_ _ | | | | | _| | | | | | | | |_| | | | | |_| | |_| (_) \_| |_|\__, | (_) - __/ | - |___/ + __/ | + |___/ ]]-- --[[ -______ _ _ _ _ -| ___ \ (_) | | (_) | -| |_/ / __ ___ _ ___ ___| |_ _| | ___ +______ _ _ _ _ +| ___ \ (_) | | (_) | +| |_/ / __ ___ _ ___ ___| |_ _| | ___ | __/ '__/ _ \| |/ _ \/ __| __| | |/ _ \ | | | | | (_) | | __/ (__| |_| | | __/ \_| |_| \___/| |\___|\___|\__|_|_|\___| - _/ | - |__/ + _/ | + |__/ ]]-- local random_pitch_multiplier = {-1,1} mobs.projectile_attack_fly = function(self, dtime) - --this needs an exception if self.attacking == nil or not self.attacking:is_player() then self.attacking = nil return end - + --this is specifically for random ghast movement if self.fly_random_while_attack then @@ -315,7 +312,7 @@ mobs.projectile_attack_fly = function(self, dtime) local distance_from_attacking = vector_distance(self.object:get_pos(), self.attacking:get_pos()) - if distance_from_attacking >= self.reach then + if distance_from_attacking >= self.reach then mobs.set_pitch_while_attacking(self) mobs.set_fly_velocity(self, self.run_velocity) mobs.set_mob_animation(self,"run") diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/backup_code_api.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/backup_code_api.txt similarity index 97% rename from mods/ENTITIES/mcl_mobs/api/mob_functions/backup_code_api.lua rename to mods/ENTITIES/mcl_mobs/api/mob_functions/backup_code_api.txt index 76c062a40..48233d0b4 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/backup_code_api.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/backup_code_api.txt @@ -1,4 +1,7 @@ -local disable_physics = function(object, luaentity, ignore_check, reset_movement) +local math = math +local vector = vector + +local function disable_physics(object, luaentity, ignore_check, reset_movement) if luaentity.physical_state == true or ignore_check == true then luaentity.physical_state = false object:set_properties({ @@ -12,7 +15,7 @@ local disable_physics = function(object, luaentity, ignore_check, reset_movement end ----For Water Flowing: -local enable_physics = function(object, luaentity, ignore_check) +local function enable_physics(object, luaentity, ignore_check) if luaentity.physical_state == false or ignore_check == true then luaentity.physical_state = true object:set_properties({ @@ -272,7 +275,7 @@ local falling = function(self, pos) self.object:set_acceleration({ x = 0, - y = -self.fall_speed / (math_max(1, v.y) ^ 2), + y = -self.fall_speed / (math.max(1, v.y) ^ 2), z = 0 }) end @@ -503,9 +506,9 @@ local follow_flop = function(self) if sdef and sdef.walkable then mob_sound(self, "flop") self.object:set_velocity({ - x = math_random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED), + x = math.random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED), y = FLOP_HEIGHT, - z = math_random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED), + z = math.random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED), }) end @@ -987,7 +990,7 @@ local check_for_death = function(self, cause, cmi_cause) item_drop(self, cooked, looting) if mod_experience and ((not self.child) or self.type ~= "animal") and (minetest_get_us_time() - self.xp_timestamp <= 5000000) then - mcl_experience.throw_experience(self.object:get_pos(), math_random(self.xp_min, self.xp_max)) + mcl_experience.throw_experience(self.object:get_pos(), math.random(self.xp_min, self.xp_max)) end end end @@ -1361,7 +1364,7 @@ local do_attack = function(self, player) self.state = "attack" -- TODO: Implement war_cry sound without being annoying - --if math_random(0, 100) < 90 then + --if math.random(0, 100) < 90 then --mob_sound(self, "war_cry", true) --end end @@ -1396,7 +1399,7 @@ local mob_sound = function(self, soundname, is_opinion, fixed_pitch) pitch = base_pitch end -- randomize the pitch a bit - pitch = pitch + math_random(-10, 10) * 0.005 + pitch = pitch + math.random(-10, 10) * 0.005 end minetest_sound_play(sound, { object = self.object, @@ -1699,7 +1702,7 @@ local do_env_damage = function(self) end if drowning then - self.breath = math_max(0, self.breath - 1) + self.breath = math.max(0, self.breath - 1) effect(pos, 2, "bubble.png", nil, nil, 1, nil) if self.breath <= 0 then @@ -2044,7 +2047,7 @@ local breed = function(self) -- Give XP if mod_experience then - mcl_experience.throw_experience(pos, math_random(1, 7)) + mcl_experience.throw_experience(pos, math.random(1, 7)) end -- custom breed function @@ -2061,7 +2064,7 @@ local breed = function(self) -- Use texture of one of the parents - local p = math_random(1, 2) + local p = math.random(1, 2) if p == 1 then ent_c.base_texture = parent1.base_texture else @@ -2091,7 +2094,7 @@ local replace = function(self, pos) or not self.replace_what or self.child == true or self.object:get_velocity().y ~= 0 - or math_random(1, self.replace_rate) > 1 then + or math.random(1, self.replace_rate) > 1 then return end @@ -2099,7 +2102,7 @@ local replace = function(self, pos) if type(self.replace_what[1]) == "table" then - local num = math_random(#self.replace_what) + local num = math.random(#self.replace_what) what = self.replace_what[num][1] or "" with = self.replace_what[num][2] or "" @@ -2163,7 +2166,7 @@ function do_states(self) if self.state == "stand" then - if math_random(1, 4) == 1 then + if math.random(1, 4) == 1 then local lp = nil local s = self.object:get_pos() @@ -2189,7 +2192,7 @@ function do_states(self) if lp.x > s.x then yaw = yaw + math_pi end else - yaw = yaw + math_random(-0.5, 0.5) + yaw = yaw + math.random(-0.5, 0.5) end yaw = set_yaw(self, yaw, 8) @@ -2204,7 +2207,7 @@ function do_states(self) if self.walk_chance ~= 0 and self.facing_fence ~= true - and math_random(1, 100) <= self.walk_chance + and math.random(1, 100) <= self.walk_chance and is_at_cliff_or_danger(self) == false then set_velocity(self, self.walk_velocity) @@ -2254,7 +2257,7 @@ function do_states(self) {x = s.x + 5, y = s.y + 1, z = s.z + 5}, {"group:solid"}) - lp = #lp > 0 and lp[math_random(#lp)] + lp = #lp > 0 and lp[math.random(#lp)] -- did we find land? if lp then @@ -2280,8 +2283,8 @@ function do_states(self) else -- Randomly turn - if math_random(1, 100) <= 30 then - yaw = yaw + math_random(-0.5, 0.5) + if math.random(1, 100) <= 30 then + yaw = yaw + math.random(-0.5, 0.5) yaw = set_yaw(self, yaw, 8) end end @@ -2289,9 +2292,9 @@ function do_states(self) yaw = set_yaw(self, yaw, 8) -- otherwise randomly turn - elseif math_random(1, 100) <= 30 then + elseif math.random(1, 100) <= 30 then - yaw = yaw + math_random(-0.5, 0.5) + yaw = yaw + math.random(-0.5, 0.5) yaw = set_yaw(self, yaw, 8) end @@ -2302,7 +2305,7 @@ function do_states(self) end if self.facing_fence == true or cliff_or_danger - or math_random(1, 100) <= 30 then + or math.random(1, 100) <= 30 then set_velocity(self, 0) self.state = "stand" @@ -2602,7 +2605,7 @@ function do_states(self) self.timer = 0 if self.double_melee_attack - and math_random(1, 2) == 1 then + and math.random(1, 2) == 1 then set_animation(self, "punch2") else set_animation(self, "punch") @@ -2669,7 +2672,7 @@ function do_states(self) if self.shoot_interval and self.timer > self.shoot_interval and not minetest_raycast(p, self.attack:get_pos(), false, false):next() - and math_random(1, 100) <= 60 then + and math.random(1, 100) <= 60 then self.timer = 0 set_animation(self, "shoot") @@ -2759,7 +2762,7 @@ end -- Code to execute before custom on_rightclick handling -local on_rightclick_prefix = function(self, clicker) +local function on_rightclick_prefix(self, clicker) local item = clicker:get_wielded_item() -- Name mob with nametag @@ -2785,17 +2788,17 @@ local on_rightclick_prefix = function(self, clicker) return false end -local create_mob_on_rightclick = function(on_rightclick) +--[[local function create_mob_on_rightclick(on_rightclick) return function(self, clicker) local stop = on_rightclick_prefix(self, clicker) if (not stop) and (on_rightclick) then on_rightclick(self, clicker) end end -end +end]] -- set and return valid yaw -local set_yaw = function(self, yaw, delay, dtime) +local function set_yaw(self, yaw, delay, dtime) if not yaw or yaw ~= yaw then yaw = 0 @@ -2805,7 +2808,7 @@ local set_yaw = function(self, yaw, delay, dtime) if delay == 0 then if self.shaking and dtime then - yaw = yaw + (math_random() * 2 - 1) * 5 * dtime + yaw = yaw + (math.random() * 2 - 1) * 5 * dtime end self.yaw(yaw) update_roll(self) @@ -2825,8 +2828,7 @@ function mobs:yaw(self, yaw, delay, dtime) end -mob_step = function() - +--mob_step = function() --if self.state == "die" then -- print("need custom die stop moving thing") -- return @@ -2901,7 +2903,7 @@ mob_step = function() --end -- mob plays random sound at times - --if math_random(1, 70) == 1 then + --if math.random(1, 70) == 1 then -- mob_sound(self, "random", true) --end @@ -2934,11 +2936,11 @@ mob_step = function() --if is_at_water_danger(self) and self.state ~= "attack" then - -- if math_random(1, 10) <= 6 then + -- if math.random(1, 10) <= 6 then -- set_velocity(self, 0) -- self.state = "stand" -- set_animation(self, "stand") - -- yaw = yaw + math_random(-0.5, 0.5) + -- yaw = yaw + math.random(-0.5, 0.5) -- yaw = set_yaw(self, yaw, 8) -- end --end @@ -2982,7 +2984,7 @@ mob_step = function() mcl_burning.extinguish(self.object) self.object:remove() elseif self.lifetimer <= 10 then - if math_random(10) < 4 then + if math.random(10) < 4 then self.despawn_immediately = true else self.lifetimer = 20 @@ -2991,4 +2993,4 @@ mob_step = function() end ]]-- -end +--end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua index 5dc0b8884..c50fb6300 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua @@ -1,14 +1,13 @@ local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius -local vector_distance = vector.distance +local vector = vector --check to see if someone nearby has some tasty food mobs.check_following = function(self) -- returns true or false - --ignore if not self.follow then self.following_person = nil - return(false) + return false end --hey look, this thing works for passive mobs too! @@ -20,20 +19,20 @@ mobs.check_following = function(self) -- returns true or false --safety check if not stack then self.following_person = nil - return(false) + return false end local item_name = stack:get_name() --all checks have passed, that guy has some good looking food if item_name == self.follow then self.following_person = follower - return(true) + return true end end --everything failed self.following_person = nil - return(false) + return false end --a function which attempts to make mobs enter @@ -42,30 +41,30 @@ mobs.enter_breed_state = function(self,clicker) --do not breed if baby if self.baby then - return(false) + return false end --do not do anything if looking for mate or --if cooling off from breeding if self.breed_lookout_timer > 0 or self.breed_timer > 0 then - return(false) + return false end --if this is caught, that means something has gone --seriously wrong if not clicker or not clicker:is_player() then - return(false) + return false end local stack = clicker:get_wielded_item() --safety check if not stack then - return(false) + return false end local item_name = stack:get_name() --all checks have passed, that guy has some good looking food - if item_name == self.follow then + if item_name == self.follow then if not minetest.is_creative_enabled(clicker:get_player_name()) then stack:take_item() clicker:set_wielded_item(stack) @@ -73,11 +72,11 @@ mobs.enter_breed_state = function(self,clicker) self.breed_lookout_timer = self.breed_lookout_timer_goal self.bred = true mobs.play_sound_specific(self,"mobs_mc_animal_eat_generic") - return(true) + return true end --everything failed - return(false) + return false end @@ -96,23 +95,23 @@ mobs.look_for_mate = function(self) for _,mate in pairs(minetest_get_objects_inside_radius(pos1, radius)) do --look for a breeding mate - if mate and mate:get_luaentity() - and mate:get_luaentity()._cmi_is_mob - and mate:get_luaentity().name == self.name + if mate and mate:get_luaentity() + and mate:get_luaentity()._cmi_is_mob + and mate:get_luaentity().name == self.name and mate:get_luaentity().breed_lookout_timer > 0 and mate:get_luaentity() ~= self then local pos2 = mate:get_pos() - local distance = vector_distance(pos1,pos2) + local distance = vector.distance(pos1,pos2) if distance <= radius then - if line_of_sight then + if minetest.line_of_sight then --must add eye height or stuff breaks randomly because of --seethrough nodes being a blocker (like grass) - if minetest_line_of_sight( - vector_new(pos1.x, pos1.y, pos1.z), - vector_new(pos2.x, pos2.y + mate:get_properties().eye_height, pos2.z) + if minetest.line_of_sight( + vector.new(pos1.x, pos1.y, pos1.z), + vector.new(pos2.x, pos2.y + mate:get_properties().eye_height, pos2.z) ) then mates_detected = mates_detected + 1 mates_in_area[mate] = distance @@ -141,9 +140,7 @@ mobs.look_for_mate = function(self) winner_mate = mate end end - - return(winner_mate) - + return winner_mate end --make the baby grow up @@ -160,14 +157,14 @@ mobs.make_baby_grow_faster = function(self,clicker) if clicker and clicker:is_player() then local stack = clicker:get_wielded_item() --safety check - if not stack then - return(false) + if not stack then + return false end local item_name = stack:get_name() --all checks have passed, that guy has some good looking food if item_name == self.follow then - self.grow_up_timer = self.grow_up_timer - (self.grow_up_timer * 0.10) --take 10 percent off - diminishing returns + self.grow_up_timer = self.grow_up_timer - (self.grow_up_timer * 0.10) --take 10 percent off - diminishing returns if not minetest.is_creative_enabled(clicker:get_player_name()) then stack:take_item() @@ -175,10 +172,8 @@ mobs.make_baby_grow_faster = function(self,clicker) end mobs.play_sound_specific(self,"mobs_mc_animal_eat_generic") - - return(true) + return true end end - - return(false) + return false end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/collision.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/collision.lua index 44f43f20f..ed9aec6cd 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/collision.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/collision.lua @@ -8,10 +8,8 @@ local vector_direction = vector.direction local integer_test = {-1,1} mobs.collision = function(self) - local pos = self.object:get_pos() - if not self or not self.object or not self.object:get_luaentity() then return end @@ -20,7 +18,7 @@ mobs.collision = function(self) local collisionbox = self.object:get_properties().collisionbox pos.y = pos.y + collisionbox[2] - + local collision_boundary = collisionbox[4] local radius = collision_boundary @@ -41,7 +39,7 @@ mobs.collision = function(self) for _,object in ipairs(minetest_get_objects_inside_radius(pos, radius*1.25)) do if object and object ~= self.object and (object:is_player() or (object:get_luaentity() and object:get_luaentity()._cmi_is_mob == true and object:get_luaentity().health > 0)) and --don't collide with rider, rider don't collide with thing - (not object:get_attach() or (object:get_attach() and object:get_attach() ~= self.object)) and + (not object:get_attach() or (object:get_attach() and object:get_attach() ~= self.object)) and (not self.object:get_attach() or (self.object:get_attach() and self.object:get_attach() ~= object)) then --stop infinite loop collision_count = collision_count + 1 @@ -52,7 +50,7 @@ mobs.collision = function(self) end local pos2 = object:get_pos() - + local object_collisionbox = object:get_properties().collisionbox pos2.y = pos2.y + object_collisionbox[2] @@ -74,7 +72,7 @@ mobs.collision = function(self) local dir = vector.direction(pos,pos2) dir.y = 0 - + --eliminate mob being stuck in corners if dir.x == 0 and dir.z == 0 then --slightly adjust mob position to prevent equal length @@ -84,7 +82,7 @@ mobs.collision = function(self) end local velocity = dir - + --0.5 is the max force multiplier local force = 0.5 - (0.5 * distance / (collision_boundary + object_collision_boundary)) @@ -104,11 +102,9 @@ mobs.collision = function(self) end end end - self.object:add_velocity(vel1) object:add_velocity(vel2) end - end end end @@ -116,7 +112,6 @@ end --this is used for arrow collisions mobs.arrow_hit = function(self, player) - player:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = self._damage} diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua index 57cb6e4e5..45e46d3db 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/death_logic.lua @@ -1,5 +1,5 @@ local minetest_add_item = minetest.add_item -local minetest_sound_play = minetest.sound_play +--local minetest_sound_play = minetest.sound_play local math_pi = math.pi local math_random = math.random @@ -19,7 +19,7 @@ local item_drop = function(self, cooked, looting_level) return end - local obj, item, num + local obj, item local pos = self.object:get_pos() self.drops = self.drops or {} -- nil check @@ -56,8 +56,11 @@ local item_drop = function(self, cooked, looting_level) -- cook items when true if cooked then - local output = minetest_get_craft_result({ - method = "cooking", width = 1, items = {item}}) + local output = minetest.get_craft_result({ + method = "cooking", + width = 1, + items = {item}, + }) if output and output.item and not output.item:is_empty() then item = output.item:get_name() @@ -117,15 +120,10 @@ mobs.death_logic = function(self, dtime) --the final POOF of a mob despawning if self.death_animation_timer >= 1.25 then - item_drop(self,false,1) - mobs.death_effect(self) - mcl_experience.throw_experience(self.object:get_pos(), math_random(self.xp_min, self.xp_max)) - self.object:remove() - return end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua index 7c709c09e..5c431135e 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua @@ -1,5 +1,5 @@ local minetest_line_of_sight = minetest.line_of_sight -local minetest_dir_to_yaw = minetest.dir_to_yaw +--local minetest_dir_to_yaw = minetest.dir_to_yaw local minetest_yaw_to_dir = minetest.yaw_to_dir local minetest_get_node = minetest.get_node local minetest_get_item_group = minetest.get_item_group @@ -18,19 +18,16 @@ local table_copy = table.copy local math_abs = math.abs -- default function when mobs are blown up with TNT -local do_tnt = function(obj, damage) - +--[[local function do_tnt(obj, damage) obj.object:punch(obj.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = damage}, }, nil) - return false, true, {} -end +end]] --a fast function to be able to detect only players without using objects_in_radius mobs.detect_closest_player_within_radius = function(self, line_of_sight, radius, object_height_adder) - local pos1 = self.object:get_pos() local players_in_area = {} local winner_player = nil @@ -49,7 +46,7 @@ mobs.detect_closest_player_within_radius = function(self, line_of_sight, radius, --must add eye height or stuff breaks randomly because of --seethrough nodes being a blocker (like grass) if minetest_line_of_sight( - vector_new(pos1.x, pos1.y + object_height_adder, pos1.z), + vector_new(pos1.x, pos1.y + object_height_adder, pos1.z), vector_new(pos2.x, pos2.y + player:get_properties().eye_height, pos2.z) ) then players_detected = players_detected + 1 @@ -79,8 +76,7 @@ mobs.detect_closest_player_within_radius = function(self, line_of_sight, radius, winner_player = player end end - - return(winner_player) + return winner_player end @@ -107,14 +103,13 @@ mobs.jump_check = function(self,dtime) if green_flag_1 and green_flag_2 then --can jump over node - return(1) - elseif green_flag_1 and not green_flag_2 then + return 1 + elseif green_flag_1 and not green_flag_2 then --wall in front of mob - return(2) + return 2 end - --nothing to jump over - return(0) + return 0 end -- a helper function to quickly turn neutral passive mobs hostile @@ -180,15 +175,10 @@ end -- check if within physical map limits (-30911 to 30927) -- within_limits, wmin, wmax = nil, -30913, 30928 mobs.within_limits = function(pos, radius) + local wmin, wmax if mcl_vars then if mcl_vars.mapgen_edge_min and mcl_vars.mapgen_edge_max then wmin, wmax = mcl_vars.mapgen_edge_min, mcl_vars.mapgen_edge_max - within_limits = function(pos, radius) - return pos - and (pos.x - radius) > wmin and (pos.x + radius) < wmax - and (pos.y - radius) > wmin and (pos.y + radius) < wmax - and (pos.z - radius) > wmin and (pos.z + radius) < wmax - end end end return pos @@ -231,12 +221,12 @@ mobs.check_for_player_within_area = function(self, radius) local distance = vector_distance(pos1,pos2) if distance < radius then --found a player - return(true) + return true end end end --did not find a player - return(false) + return false end @@ -244,7 +234,7 @@ end mobs.get_2d_distance = function(pos1,pos2) pos1.y = 0 pos2.y = 0 - return(vector_distance(pos1, pos2)) + return vector_distance(pos1, pos2) end -- fall damage onto solid ground diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua index 0fc94ffe6..0f5615504 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua @@ -1,112 +1,98 @@ -local vector_new = vector.new - +local math = math +local vector = vector --converts yaw to degrees local degrees = function(yaw) - return(yaw*180.0/math.pi) + return yaw*180.0/math.pi end - mobs.do_head_logic = function(self,dtime) - local player = minetest.get_player_by_name("singleplayer") + local player = minetest.get_player_by_name("singleplayer") - local look_at = player:get_pos() - look_at.y = look_at.y + player:get_properties().eye_height + local look_at = player:get_pos() + look_at.y = look_at.y + player:get_properties().eye_height + + local pos = self.object:get_pos() + + local body_yaw = self.object:get_yaw() + + local body_dir = minetest.yaw_to_dir(body_yaw) + + pos.y = pos.y + self.head_height_offset + + local head_offset = vector.multiply(body_dir, self.head_direction_offset) + + pos = vector.add(pos, head_offset) + + minetest.add_particle({ + pos = pos, + velocity = {x=0, y=0, z=0}, + acceleration = {x=0, y=0, z=0}, + expirationtime = 0.2, + size = 1, + texture = "default_dirt.png", + }) + + local bone_pos = vector.new(0,0,0) + + --(horizontal) + bone_pos.y = self.head_bone_pos_y + + --(vertical) + bone_pos.z = self.head_bone_pos_z + + --print(yaw) + + --local _, bone_rot = self.object:get_bone_position("head") + + --bone_rot.x = bone_rot.x + (dtime * 10) + --bone_rot.z = bone_rot.z + (dtime * 10) + + local head_yaw = minetest.dir_to_yaw(vector.direction(pos,look_at)) - body_yaw + + if self.reverse_head_yaw then + head_yaw = head_yaw * -1 + end + + --over rotation protection + --stops radians from going out of spec + if head_yaw > math.pi then + head_yaw = head_yaw - (math.pi * 2) + elseif head_yaw < -math.pi then + head_yaw = head_yaw + (math.pi * 2) + end + local check_failed = false + --upper check + 90 degrees or upper math.radians (3.14/2) + if head_yaw > math.pi - (math.pi/2) then + head_yaw = 0 + check_failed = true + --lower check - 90 degrees or lower negative math.radians (-3.14/2) + elseif head_yaw < -math.pi + (math.pi/2) then + head_yaw = 0 + check_failed = true + end + local head_pitch = 0 - local pos = self.object:get_pos() + --DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG + --head_yaw = 0 + --DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG - local body_yaw = self.object:get_yaw() + if not check_failed then + head_pitch = minetest.dir_to_yaw(vector.new(vector.distance(vector.new(pos.x,0,pos.z),vector.new(look_at.x,0,look_at.z)),0,pos.y-look_at.y))+(math.pi/2) + end - local body_dir = minetest.yaw_to_dir(body_yaw) + if self.head_pitch_modifier then + head_pitch = head_pitch + self.head_pitch_modifier + end - - pos.y = pos.y + self.head_height_offset - - local head_offset = vector.multiply(body_dir, self.head_direction_offset) - - pos = vector.add(pos, head_offset) - - - - - minetest.add_particle({ - pos = pos, - velocity = {x=0, y=0, z=0}, - acceleration = {x=0, y=0, z=0}, - expirationtime = 0.2, - size = 1, - texture = "default_dirt.png", - }) - - - local bone_pos = vector_new(0,0,0) - - - --(horizontal) - bone_pos.y = self.head_bone_pos_y - - --(vertical) - bone_pos.z = self.head_bone_pos_z - - --print(yaw) - - --local _, bone_rot = self.object:get_bone_position("head") - - --bone_rot.x = bone_rot.x + (dtime * 10) - --bone_rot.z = bone_rot.z + (dtime * 10) - - - local head_yaw - head_yaw = minetest.dir_to_yaw(vector.direction(pos,look_at)) - body_yaw - - if self.reverse_head_yaw then - head_yaw = head_yaw * -1 - end - - --over rotation protection - --stops radians from going out of spec - if head_yaw > math.pi then - head_yaw = head_yaw - (math.pi * 2) - elseif head_yaw < -math.pi then - head_yaw = head_yaw + (math.pi * 2) - end - - - local check_failed = false - --upper check + 90 degrees or upper math.radians (3.14/2) - if head_yaw > math.pi - (math.pi/2) then - head_yaw = 0 - check_failed = true - --lower check - 90 degrees or lower negative math.radians (-3.14/2) - elseif head_yaw < -math.pi + (math.pi/2) then - head_yaw = 0 - check_failed = true - end - - local head_pitch = 0 - - --DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG - --head_yaw = 0 - --DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG - - if not check_failed then - head_pitch = minetest.dir_to_yaw(vector.new(vector.distance(vector.new(pos.x,0,pos.z),vector.new(look_at.x,0,look_at.z)),0,pos.y-look_at.y))+(math.pi/2) - end - - if self.head_pitch_modifier then - head_pitch = head_pitch + self.head_pitch_modifier - end - - if self.swap_y_with_x then - self.object:set_bone_position(self.head_bone, bone_pos, vector_new(degrees(head_pitch),degrees(head_yaw),0)) - else - self.object:set_bone_position(self.head_bone, bone_pos, vector_new(degrees(head_pitch),0,degrees(head_yaw))) - end - - - --set_bone_position([bone, position, rotation]) + if self.swap_y_with_x then + self.object:set_bone_position(self.head_bone, bone_pos, vector.new(degrees(head_pitch),degrees(head_yaw),0)) + else + self.object:set_bone_position(self.head_bone, bone_pos, vector.new(degrees(head_pitch),0,degrees(head_yaw))) + end + --set_bone_position([bone, position, rotation]) end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua index 6b23d2fe7..fa5b31210 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua @@ -2,22 +2,19 @@ local minetest_after = minetest.after local minetest_sound_play = minetest.sound_play local minetest_dir_to_yaw = minetest.dir_to_yaw -local math_floor = math.floor -local math_min = math.min -local math_random = math.random - -local vector_direction = vector.direction -local vector_multiply = vector.multiply +local math = math +local vector = vector local MAX_MOB_NAME_LENGTH = 30 +local mod_hunger = minetest.get_modpath("mcl_hunger") + mobs.feed_tame = function(self) return nil end -- Code to execute before custom on_rightclick handling -local on_rightclick_prefix = function(self, clicker) - +local function on_rightclick_prefix(self, clicker) local item = clicker:get_wielded_item() -- Name mob with nametag @@ -60,7 +57,6 @@ end -- deal damage and effects when mob punched mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) - --don't do anything if the mob is already dead if self.health <= 0 then return @@ -94,14 +90,13 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) pos2.y = 0 - local dir = vector_direction(pos2,pos1) + local dir = vector.direction(pos2,pos1) local yaw = minetest_dir_to_yaw(dir) self.yaw = yaw end - -- custom punch function if self.do_punch then -- when false skip going any further @@ -113,23 +108,20 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) --don't do damage until pause timer resets if self.pause_timer > 0 then return - end + end - -- error checking when mod profiling is enabled if not tool_capabilities then minetest.log("warning", "[mobs_mc] Mod profiling enabled, damage not enabled") return end - local is_player = hitter:is_player() - -- punch interval local weapon = hitter:get_wielded_item() - local punch_interval = 1.4 + --local punch_interval = 1.4 -- exhaust attacker if mod_hunger and is_player then @@ -139,7 +131,6 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) -- calculate mob damage local damage = 0 local armor = self.object:get_armor_groups() or {} - local tmp --calculate damage groups for group,_ in pairs( (tool_capabilities.damage_groups or {}) ) do @@ -163,13 +154,13 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) -- healing if damage <= -1 then - self.health = self.health - math_floor(damage) + self.health = self.health - math.floor(damage) return end - if tool_capabilities then - punch_interval = tool_capabilities.full_punch_interval or 1.4 - end + --if tool_capabilities then + -- punch_interval = tool_capabilities.full_punch_interval or 1.4 + --end -- add weapon wear manually -- Required because we have custom health handling ("health" property) @@ -183,7 +174,7 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) local weapon = hitter:get_wielded_item(player) local def = weapon:get_definition() if def.tool_capabilities and def.tool_capabilities.punch_attack_uses then - local wear = math_floor(65535/tool_capabilities.punch_attack_uses) + local wear = math.floor(65535/tool_capabilities.punch_attack_uses) weapon:add_wear(wear) hitter:set_wielded_item(weapon) end @@ -224,7 +215,7 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) -- knock back effect local velocity = self.object:get_velocity() - + --2d direction local pos1 = self.object:get_pos() pos1.y = 0 @@ -240,9 +231,8 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) up = 0 end - --0.75 for perfect distance to not be too easy, and not be too hard - local multiplier = 0.75 + local multiplier = 0.75 -- check if tool already has specific knockback value local knockback_enchant = mcl_enchanting.get_enchantment(hitter:get_wielded_item(), "knockback") @@ -254,21 +244,16 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) --it's coming for you if self.hostile then multiplier = multiplier + 2 - end - - dir = vector_multiply(dir,multiplier) - + end + dir = vector.multiply(dir,multiplier) dir.y = up - --add the velocity self.object:add_velocity(dir) - end end --do internal per mob projectile calculations mobs.shoot_projectile = function(self) - local pos1 = self.object:get_pos() --add mob eye height pos1.y = pos1.y + self.eye_height @@ -278,7 +263,7 @@ mobs.shoot_projectile = function(self) pos2.y = pos2.y + self.attacking:get_properties().eye_height --get direction - local dir = vector_direction(pos1,pos2) + local dir = vector.direction(pos1,pos2) --call internal shoot_arrow function self.shoot_arrow(self,pos1,dir) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/mob_effects.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/mob_effects.lua index 847315ff1..83df80992 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/mob_effects.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/mob_effects.lua @@ -1,9 +1,8 @@ local minetest_add_particlespawner = minetest.add_particlespawner mobs.death_effect = function(self) - local pos = self.object:get_pos() - local yaw = self.object:get_yaw() + --local yaw = self.object:get_yaw() local collisionbox = self.object:get_properties().collisionbox local min, max @@ -33,7 +32,7 @@ end mobs.critical_effect = function(self) local pos = self.object:get_pos() - local yaw = self.object:get_yaw() + --local yaw = self.object:get_yaw() local collisionbox = self.object:get_properties().collisionbox local min, max @@ -62,9 +61,8 @@ end --when feeding a mob mobs.feed_effect = function(self) - local pos = self.object:get_pos() - local yaw = self.object:get_yaw() + --local yaw = self.object:get_yaw() local collisionbox = self.object:get_properties().collisionbox local min, max @@ -94,7 +92,7 @@ end --hearts when tamed mobs.tamed_effect = function(self) local pos = self.object:get_pos() - local yaw = self.object:get_yaw() + --local yaw = self.object:get_yaw() local collisionbox = self.object:get_properties().collisionbox local min, max @@ -124,7 +122,7 @@ end --hearts when breeding mobs.breeding_effect = function(self) local pos = self.object:get_pos() - local yaw = self.object:get_yaw() + --local yaw = self.object:get_yaw() local collisionbox = self.object:get_properties().collisionbox local min, max diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua index 9a5fd9ea1..893f8eede 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/movement.lua @@ -1,16 +1,10 @@ -local math_pi = math.pi -local math_sin = math.sin -local math_cos = math.cos -local math_random = math.random -local HALF_PI = math_pi / 2 -local DOUBLE_PI = math_pi * 2 +-- localize math functions +local math = math +local HALF_PI = math.pi / 2 +local DOUBLE_PI = math.pi * 2 -- localize vector functions -local vector_new = vector.new -local vector_length = vector.length -local vector_multiply = vector.multiply -local vector_distance = vector.distance -local vector_normalize = vector.normalize +local vector = vector local minetest_yaw_to_dir = minetest.yaw_to_dir local minetest_dir_to_yaw = minetest.dir_to_yaw @@ -19,18 +13,17 @@ local DEFAULT_JUMP_HEIGHT = 5 local DEFAULT_FLOAT_SPEED = 4 local DEFAULT_CLIMB_SPEED = 3 - mobs.stick_in_cobweb = function(self) local current_velocity = self.object:get_velocity() - - local goal_velocity = vector_multiply(vector_normalize(current_velocity), 0.4) + + local goal_velocity = vector.multiply(vector.normalize(current_velocity), 0.4) goal_velocity.y = -0.5 local new_velocity_addition = vector.subtract(goal_velocity,current_velocity) --smooths out mobs a bit - if vector_length(new_velocity_addition) >= 0.0001 then + if vector.length(new_velocity_addition) >= 0.0001 then self.object:add_velocity(new_velocity_addition) end end @@ -38,8 +31,11 @@ end --this is a generic float function mobs.float = function(self) - if self.object:get_acceleration().y ~= 0 then - self.object:set_acceleration(vector_new(0,0,0)) + local acceleration = self.object:get_acceleration() + if acceleration and acceleration.y ~= 0 then + self.object:set_acceleration(vector.new(0,0,0)) + else + return end local current_velocity = self.object:get_velocity() @@ -56,7 +52,7 @@ mobs.float = function(self) new_velocity_addition.z = 0 --smooths out mobs a bit - if vector_length(new_velocity_addition) >= 0.0001 then + if vector.length(new_velocity_addition) >= 0.0001 then self.object:add_velocity(new_velocity_addition) end end @@ -78,7 +74,7 @@ mobs.climb = function(self) new_velocity_addition.z = 0 --smooths out mobs a bit - if vector_length(new_velocity_addition) >= 0.0001 then + if vector.length(new_velocity_addition) >= 0.0001 then self.object:add_velocity(new_velocity_addition) end end @@ -86,10 +82,10 @@ end --[[ - _ _ + _ _ | | | | | | __ _ _ __ __| | -| | / _` | '_ \ / _` | +| | / _` | '_ \ / _` | | |___| (_| | | | | (_| | \_____/\__,_|_| |_|\__,_| ]] @@ -100,28 +96,28 @@ end --internal = lua (self.yaw) --engine = c++ (self.object:get_yaw()) mobs.set_velocity = function(self, v) - + local yaw = (self.yaw or 0) local current_velocity = self.object:get_velocity() local goal_velocity = { - x = (math_sin(yaw) * -v), + x = (math.sin(yaw) * -v), y = 0, - z = (math_cos(yaw) * v), + z = (math.cos(yaw) * v), } local new_velocity_addition = vector.subtract(goal_velocity,current_velocity) - if vector_length(new_velocity_addition) > vector_length(goal_velocity) then - vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition))) + if vector.length(new_velocity_addition) > vector.length(goal_velocity) then + vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition))) end new_velocity_addition.y = 0 --smooths out mobs a bit - if vector_length(new_velocity_addition) >= 0.0001 then + if vector.length(new_velocity_addition) >= 0.0001 then self.object:add_velocity(new_velocity_addition) end end @@ -136,7 +132,7 @@ mobs.get_velocity = function(self) v.y = 0 if v then - return vector_length(v) + return vector.length(v) end return 0 @@ -152,7 +148,7 @@ mobs.jump = function(self, velocity) --fallback velocity to allow modularity velocity = velocity or DEFAULT_JUMP_HEIGHT - self.object:add_velocity(vector_new(0,velocity,0)) + self.object:add_velocity(vector.new(0,velocity,0)) end --make mobs fall slowly @@ -172,15 +168,15 @@ mobs.mob_fall_slow = function(self) new_velocity_addition.x = 0 new_velocity_addition.z = 0 - if vector_length(new_velocity_addition) > vector_length(goal_velocity) then - vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition))) + if vector.length(new_velocity_addition) > vector.length(goal_velocity) then + vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition))) end new_velocity_addition.x = 0 new_velocity_addition.z = 0 --smooths out mobs a bit - if vector_length(new_velocity_addition) >= 0.0001 then + if vector.length(new_velocity_addition) >= 0.0001 then self.object:add_velocity(new_velocity_addition) end @@ -188,10 +184,10 @@ end --[[ - _____ _ -/ ___| (_) -\ `--.__ ___ _ __ ___ - `--. \ \ /\ / / | '_ ` _ \ + _____ _ +/ ___| (_) +\ `--.__ ___ _ __ ___ + `--. \ \ /\ / / | '_ ` _ \ /\__/ /\ V V /| | | | | | | \____/ \_/\_/ |_|_| |_| |_| ]]-- @@ -212,16 +208,16 @@ mobs.flop = function(self, velocity) velocity = velocity or DEFAULT_JUMP_HEIGHT --create a random direction (2d yaw) - local dir = DOUBLE_PI * math_random() + local dir = DOUBLE_PI * math.random() --create a random force value - local force = math_random(0,3) + math_random() + local force = math.random(0,3) + math.random() --convert the yaw to a direction vector then multiply it times the force - local final_additional_force = vector_multiply(minetest_yaw_to_dir(dir), force) + local final_additional_force = vector.multiply(minetest_yaw_to_dir(dir), force) --place in the "flop" velocity to make the mob flop - final_additional_force.y = velocity + final_additional_force.y = velocity self.object:add_velocity(final_additional_force) @@ -235,7 +231,7 @@ end --internal = lua (self.yaw) --engine = c++ (self.object:get_yaw()) mobs.set_swim_velocity = function(self, v) - + local yaw = (self.yaw or 0) local pitch = (self.pitch or 0) @@ -246,33 +242,33 @@ mobs.set_swim_velocity = function(self, v) local current_velocity = self.object:get_velocity() local goal_velocity = { - x = (math_sin(yaw) * -v), + x = (math.sin(yaw) * -v), y = pitch, - z = (math_cos(yaw) * v), + z = (math.cos(yaw) * v), } local new_velocity_addition = vector.subtract(goal_velocity,current_velocity) - if vector_length(new_velocity_addition) > vector_length(goal_velocity) then - vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition))) + if vector.length(new_velocity_addition) > vector.length(goal_velocity) then + vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition))) end --smooths out mobs a bit - if vector_length(new_velocity_addition) >= 0.0001 then + if vector.length(new_velocity_addition) >= 0.0001 then self.object:add_velocity(new_velocity_addition) end end --[[ -______ _ -| ___| | -| |_ | |_ _ +______ _ +| ___| | +| |_ | |_ _ | _| | | | | | | | | | |_| | \_| |_|\__, | __/ | - |___/ + |___/ ]]-- -- move mob in facing direction @@ -280,7 +276,7 @@ ______ _ --internal = lua (self.yaw) --engine = c++ (self.object:get_yaw()) mobs.set_fly_velocity = function(self, v) - + local yaw = (self.yaw or 0) local pitch = (self.pitch or 0) @@ -291,20 +287,20 @@ mobs.set_fly_velocity = function(self, v) local current_velocity = self.object:get_velocity() local goal_velocity = { - x = (math_sin(yaw) * -v), + x = (math.sin(yaw) * -v), y = pitch, - z = (math_cos(yaw) * v), + z = (math.cos(yaw) * v), } local new_velocity_addition = vector.subtract(goal_velocity,current_velocity) - if vector_length(new_velocity_addition) > vector_length(goal_velocity) then - vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition))) + if vector.length(new_velocity_addition) > vector.length(goal_velocity) then + vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition))) end --smooths out mobs a bit - if vector_length(new_velocity_addition) >= 0.0001 then + if vector.length(new_velocity_addition) >= 0.0001 then self.object:add_velocity(new_velocity_addition) end end @@ -316,7 +312,7 @@ mobs.calculate_pitch = function(pos1, pos2) return false end - return(minetest_dir_to_yaw(vector_new(vector_distance(vector_new(pos1.x,0,pos1.z),vector_new(pos2.x,0,pos2.z)),0,pos1.y - pos2.y)) + HALF_PI) + return minetest_dir_to_yaw(vector.new(vector.distance(vector.new(pos1.x,0,pos1.z),vector.new(pos2.x,0,pos2.z)),0,pos1.y - pos2.y)) + HALF_PI end --make mobs fly up or down based on their y difference @@ -332,14 +328,14 @@ end --[[ - ___ - |_ | - | |_ _ _ __ ___ _ __ - | | | | | '_ ` _ \| '_ \ + ___ + |_ | + | |_ _ _ __ ___ _ __ + | | | | | '_ ` _ \| '_ \ /\__/ / |_| | | | | | | |_) | -\____/ \__,_|_| |_| |_| .__/ - | | - |_| +\____/ \__,_|_| |_| |_| .__/ + | | + |_| ]]-- --special mob jump movement @@ -353,27 +349,27 @@ mobs.jump_move = function(self, velocity) mobs.set_velocity(self,0) --fallback velocity to allow modularity - jump_height = DEFAULT_JUMP_HEIGHT + local jump_height = DEFAULT_JUMP_HEIGHT local yaw = (self.yaw or 0) local current_velocity = self.object:get_velocity() local goal_velocity = { - x = (math_sin(yaw) * -velocity), + x = (math.sin(yaw) * -velocity), y = jump_height, - z = (math_cos(yaw) * velocity), + z = (math.cos(yaw) * velocity), } local new_velocity_addition = vector.subtract(goal_velocity,current_velocity) - if vector_length(new_velocity_addition) > vector_length(goal_velocity) then - vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition))) + if vector.length(new_velocity_addition) > vector.length(goal_velocity) then + vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition))) end --smooths out mobs a bit - if vector_length(new_velocity_addition) >= 0.0001 then + if vector.length(new_velocity_addition) >= 0.0001 then self.object:add_velocity(new_velocity_addition) end end @@ -388,4 +384,4 @@ mobs.swap_auto_step_height_adjust = function(self) elseif y_vel ~= 0 and self.stepheight ~= 0 then self.stepheight = 0 end -end \ No newline at end of file +end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua index dfef98ee8..65ba764f6 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua @@ -1,10 +1,12 @@ local math_random = math.random -local minetest_settings = minetest.settings +local minetest_settings = minetest.settings + +-- CMI support check +local use_cmi = minetest.global_exists("cmi") -- get entity staticdata mobs.mob_staticdata = function(self) - --despawn mechanism --don't despawned tamed or bred mobs if not self.tamed and not self.bred then @@ -142,8 +144,6 @@ mobs.mob_activate = function(self, staticdata, def, dtime) self.health = math_random (self.hp_min, self.hp_max) end - - if not self.random_sound_timer then self.random_sound_timer = math_random(self.random_sound_timer_min,self.random_sound_timer_max) end @@ -185,7 +185,6 @@ mobs.mob_activate = function(self, staticdata, def, dtime) self.opinion_sound_cooloff = 0 -- used to prevent sound spam of particular sound types self.texture_mods = {} - self.v_start = false self.timer = 0 @@ -199,7 +198,6 @@ mobs.mob_activate = function(self, staticdata, def, dtime) else self.object:set_texture_mod("") end - -- set anything changed above self.object:set_properties(self) diff --git a/mods/ENTITIES/mcl_mobs/api/mount.lua b/mods/ENTITIES/mcl_mobs/api/mount.lua index 8ee45f299..0ed54a46e 100644 --- a/mods/ENTITIES/mcl_mobs/api/mount.lua +++ b/mods/ENTITIES/mcl_mobs/api/mount.lua @@ -1,8 +1,11 @@ -- lib_mount by Blert2112 (edited by TenPlus1) -local enable_crash = false -local crash_threshold = 6.5 -- ignored if enable_crash=false +--local enable_crash = false +--local crash_threshold = 6.5 -- ignored if enable_crash=false + +local math = math +local vector = vector ------------------------------------------------------------------------------ @@ -10,7 +13,7 @@ local crash_threshold = 6.5 -- ignored if enable_crash=false -- Helper functions -- -local node_ok = function(pos, fallback) +--[[local function node_ok(pos, fallback) fallback = fallback or mobs.fallback_node @@ -21,10 +24,10 @@ local node_ok = function(pos, fallback) end return {name = fallback} -end +end]] -local function node_is(pos) +--[[local function node_is(pos) local node = node_ok(pos) @@ -45,7 +48,7 @@ local function node_is(pos) end return "other" -end +end]] local function get_sign(i) @@ -60,13 +63,11 @@ local function get_sign(i) end -local function get_velocity(v, yaw, y) - +--[[local function get_velocity(v, yaw, y) local x = -math.sin(yaw) * v local z = math.cos(yaw) * v - return {x = x, y = y, z = z} -end +end]] local function get_v(v) @@ -172,7 +173,7 @@ function mobs.detach(player, offset) --pos = {x = pos.x + offset.x, y = pos.y + 0.2 + offset.y, z = pos.z + offset.z} - player:add_velocity(vector.new(math.random(-6,6),math.random(5,8),math.random(-6,6))) --throw the rider off + player:add_velocity(vector.new(math.random(-6,6), math.random(5,8), math.random(-6,6))) --throw the rider off --[[ minetest.after(0.1, function(name, pos) @@ -187,13 +188,13 @@ end function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime) - local rot_view = 0 + --local rot_view = 0 - if entity.player_rotation.y == 90 then - rot_view = math.pi/2 - end + --if entity.player_rotation.y == 90 then + -- rot_view = math.pi/2 + --end - local acce_y = 0 + --local acce_y = 0 local velo = entity.object:get_velocity() entity.v = get_v(velo) * get_sign(entity.v) @@ -388,7 +389,6 @@ end -- directional flying routine by D00Med (edited by TenPlus1) function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim) - if true then print("succ") return diff --git a/mods/ENTITIES/mcl_mobs/api/spawning.lua b/mods/ENTITIES/mcl_mobs/api/spawning.lua index ca4dc1e4f..70167b421 100644 --- a/mods/ENTITIES/mcl_mobs/api/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/api/spawning.lua @@ -9,9 +9,9 @@ local get_objects_inside_radius = minetest.get_objects_inside_radius local math_random = math.random local math_floor = math.floor -local max = math.max +--local max = math.max -local vector_distance = vector.distance +--local vector_distance = vector.distance local vector_new = vector.new local vector_floor = vector.floor @@ -167,7 +167,7 @@ Overworld regular: -- count how many mobs are in an area -local count_mobs = function(pos) +local function count_mobs(pos) local num = 0 for _,object in pairs(get_objects_inside_radius(pos, aoc_range)) do if object and object:get_luaentity() and object:get_luaentity()._cmi_is_mob then @@ -242,8 +242,7 @@ function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_ligh end --[[ - local spawn_action - spawn_action = function(pos, node, active_object_count, active_object_count_wider, name) + local function spawn_action(pos, node, active_object_count, active_object_count_wider, name) local orig_pos = table.copy(pos) -- is mob actually registered? @@ -486,7 +485,8 @@ local axis local inner = 15 local outer = 64 local int = {-1,1} -local position_calculation = function(pos) + +local function position_calculation(pos) pos = vector_floor(pos) @@ -501,7 +501,7 @@ local position_calculation = function(pos) pos.z = pos.z + math_random(inner,outer)*int[math_random(1,2)] pos.x = pos.x + math_random(-outer,outer) end - return(pos) + return pos end --[[ @@ -573,10 +573,10 @@ if mobs_spawn then local spawning_position = spawning_position_list[math_random(1,#spawning_position_list)] --Prevent strange behavior --- this is commented out: /too close to player --fixed with inner circle - if not spawning_position then -- or vector_distance(player_pos, spawning_position) < 15 + if not spawning_position then -- or vector_distance(player_pos, spawning_position) < 15 break end - + --hard code mob limit in area to 5 for now if count_mobs(spawning_position) >= 5 then break @@ -606,7 +606,7 @@ if mobs_spawn then local is_lava = get_item_group(gotten_node, "lava") ~= 0 local mob_def = nil - + --create a disconnected clone of the spawn dictionary --prevents memory leak local mob_library_worker_table = table_copy(spawn_dictionary) diff --git a/mods/ENTITIES/mcl_mobs/mod.conf b/mods/ENTITIES/mcl_mobs/mod.conf index 9dfb43aef..2a91a7764 100644 --- a/mods/ENTITIES/mcl_mobs/mod.conf +++ b/mods/ENTITIES/mcl_mobs/mod.conf @@ -2,4 +2,4 @@ name = mcl_mobs author = PilzAdam description = Adds a mob API for mods to add animals or monsters, etc. depends = mcl_particles -optional_depends = mcl_weather, mcl_explosions, mcl_hunger, mcl_worlds, invisibility, cmi, doc_identifier, mcl_armor, mcl_portals, mcl_experience +optional_depends = mcl_weather, mcl_explosions, mcl_hunger, mcl_worlds, cmi, doc_identifier, mcl_armor, mcl_portals, mcl_experience diff --git a/mods/ENTITIES/mcl_paintings/init.lua b/mods/ENTITIES/mcl_paintings/init.lua index cb85ee5f8..be210c74c 100644 --- a/mods/ENTITIES/mcl_paintings/init.lua +++ b/mods/ENTITIES/mcl_paintings/init.lua @@ -4,9 +4,11 @@ dofile(minetest.get_modpath(minetest.get_current_modname()).."/paintings.lua") local S = minetest.get_translator("mcl_paintings") +local math = math + local wood = "[combine:16x16:-192,0=mcl_paintings_paintings.png" -local is_protected = function(pos, name) +local function is_protected(pos, name) if minetest.is_protected(pos, name) then minetest.record_protection_violation(pos, name) return true @@ -17,7 +19,7 @@ end -- Check if there's a painting for provided painting size. -- If yes, returns the arguments. -- If not, returns the next smaller available painting. -local shrink_painting = function(x, y) +local function shrink_painting(x, y) if x > 4 or y > 4 then return nil end @@ -43,7 +45,7 @@ local shrink_painting = function(x, y) end end -local get_painting = function(x, y, motive) +local function get_painting(x, y, motive) local painting = mcl_paintings.paintings[y] and mcl_paintings.paintings[y][x] and mcl_paintings.paintings[y][x][motive] if not painting then return nil @@ -53,7 +55,7 @@ local get_painting = function(x, y, motive) return "[combine:"..sx.."x"..sy..":"..px..","..py.."=mcl_paintings_paintings.png" end -local get_random_painting = function(x, y) +local function get_random_painting(x, y) if not mcl_paintings.paintings[y] or not mcl_paintings.paintings[y][x] then return nil end @@ -65,7 +67,7 @@ local get_random_painting = function(x, y) return get_painting(x, y, r), r end -local size_to_minmax = function(size) +--[[local function size_to_minmax(size) local min, max if size == 2 then min = -0.5 @@ -81,13 +83,13 @@ local size_to_minmax = function(size) max = 0.5 end return min, max -end +end]] -local size_to_minmax_entity = function(size) +local function size_to_minmax_entity(size) return -size/2, size/2 end -local set_entity = function(object) +local function set_entity(object) local ent = object:get_luaentity() local wallm = ent._facing local xsize = ent._xsize @@ -169,7 +171,7 @@ minetest.register_entity("mcl_paintings:painting", { on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage) -- Drop as item on punch if puncher and puncher:is_player() then - kname = puncher:get_player_name() + local kname = puncher:get_player_name() local pos = self._pos if not pos then pos = self.object:get_pos() diff --git a/mods/ENTITIES/mcl_paintings/paintings.lua b/mods/ENTITIES/mcl_paintings/paintings.lua index d606306c2..ccf584364 100644 --- a/mods/ENTITIES/mcl_paintings/paintings.lua +++ b/mods/ENTITIES/mcl_paintings/paintings.lua @@ -3,7 +3,7 @@ local TS = 16 -- texture size mcl_paintings.paintings = { [1] = { [1] = { - { cx = 0, cy = 0 }, + { cx = 0, cy = 0 }, { cx = TS, cy = 0 }, { cx = 2*TS, cy = 0 }, { cx = 3*TS, cy = 0 }, @@ -26,7 +26,7 @@ mcl_paintings.paintings = { { cx = 0, cy = 4*TS }, { cx = TS, cy = 4*TS }, }, - [2] = { + [2] = { { cx = 0, cy = 8*TS }, { cx = 2*TS, cy = 8*TS }, { cx = 4*TS, cy = 8*TS }, @@ -35,7 +35,7 @@ mcl_paintings.paintings = { { cx = 10*TS, cy = 8*TS }, }, [3] = 2, - [4] = { + [4] = { { cx = 0, cy = 6*TS }, }, }, diff --git a/mods/ENTITIES/mobs_mc/0_gameconfig.lua b/mods/ENTITIES/mobs_mc/0_gameconfig.lua index c947e9185..f21d946fe 100644 --- a/mods/ENTITIES/mobs_mc/0_gameconfig.lua +++ b/mods/ENTITIES/mobs_mc/0_gameconfig.lua @@ -83,7 +83,7 @@ mobs_mc.items = { water_source = "default:water_source", water_flowing = "default:water_flowing", river_water_source = "default:river_water_source", - water_flowing = "default:river_water_flowing", + --water_flowing = "default:river_water_flowing", black_dye = "dye:black", poppy = "flowers:rose", dandelion = "flowers:dandelion_yellow", @@ -128,7 +128,6 @@ mobs_mc.items = { nether_portal = "nether:portal", netherrack = "nether:rack", - nether_brick_block = "nether:brick", -- Wool (Minecraft color scheme) wool_white = "wool:white", diff --git a/mods/ENTITIES/mobs_mc/2_throwing.lua b/mods/ENTITIES/mobs_mc/2_throwing.lua index 23ae86d80..6f01ae6e6 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("mobs_mc") --maikerumines throwing code --arrow (weapon) diff --git a/mods/ENTITIES/mobs_mc/4_heads.lua b/mods/ENTITIES/mobs_mc/4_heads.lua index 01b8ee577..2ba0d548b 100644 --- a/mods/ENTITIES/mobs_mc/4_heads.lua +++ b/mods/ENTITIES/mobs_mc/4_heads.lua @@ -3,8 +3,9 @@ -- 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. +-- TODO: Add translation. -local S = minetest.get_translator("mobs_mc") +--local S = minetest.get_translator("mobs_mc") -- Heads system diff --git a/mods/ENTITIES/mobs_mc/blaze.lua b/mods/ENTITIES/mobs_mc/blaze.lua index 146e8da70..a5e6f2bd3 100644 --- a/mods/ENTITIES/mobs_mc/blaze.lua +++ b/mods/ENTITIES/mobs_mc/blaze.lua @@ -20,7 +20,7 @@ mobs:register_mob("mobs_mc:blaze", { xp_max = 10, tilt_fly = false, hostile = true, - rotate = 270, + --rotate = 270, collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.79, 0.3}, rotate = -180, visual = "mesh", diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index 0d6d31ffe..6100e5899 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -89,7 +89,7 @@ local cow_def = { --head code has_head = true, head_bone = "head", - + swap_y_with_x = false, reverse_head_yaw = false, @@ -168,7 +168,7 @@ mooshroom_def.on_rightclick = function(self, clicker) pos.y = pos.y + 0.5 minetest.add_item(pos, {name = mobs_mc.items.mushroom_stew}) end - end + end end mobs:register_mob("mobs_mc:mooshroom", mooshroom_def) diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index 2111105d3..d2d040ad2 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -16,7 +16,7 @@ mobs:register_mob("mobs_mc:enderdragon", { shoot_arrow = function(self, pos, dir) -- 2-4 damage per arrow local dmg = math.random(2,4) - mobs.shoot_projectile_handling("mobs_mc:dragon_fireball", pos, dir, self.object:get_yaw(), self.object, nil, dmg) + mobs.shoot_projectile_handling("mobs_mc:dragon_fireball", pos, dir, self.object:get_yaw(), self.object, nil, dmg) end, hp_max = 200, hp_min = 200, @@ -24,7 +24,6 @@ mobs:register_mob("mobs_mc:enderdragon", { xp_max = 500, collisionbox = {-2, 0, -2, 2, 2, 2}, eye_height = 1, - physical = false, visual = "mesh", mesh = "mobs_mc_dragon.b3d", textures = { @@ -60,8 +59,6 @@ mobs:register_mob("mobs_mc:enderdragon", { arrow = "mobs_mc:dragon_fireball", shoot_interval = 0.5, shoot_offset = -1.0, - xp_min = 500, - xp_max = 500, animation = { fly_speed = 8, stand_speed = 8, stand_start = 0, stand_end = 20, @@ -114,8 +111,8 @@ mobs:register_mob("mobs_mc:enderdragon", { fire_resistant = true, }) - -local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false +--TODO: replace this setting by a proper gamerules system +local mobs_griefing = minetest.settings:get_bool("mobs_griefing", true) -- dragon fireball (projectile) mobs:register_arrow("mobs_mc:dragon_fireball", { @@ -143,7 +140,9 @@ mobs:register_arrow("mobs_mc:dragon_fireball", { -- node hit, explode hit_node = function(self, pos, node) --mobs:boom(self, pos, 2) - mcl_explosions.explode(self.object:get_pos(), 2,{ drop_chance = 1.0 }) + if mobs_griefing then + mcl_explosions.explode(self.object:get_pos(), 2, { drop_chance = 1.0 }) + end end }) diff --git a/mods/ENTITIES/mobs_mc/enderman.lua b/mods/ENTITIES/mobs_mc/enderman.lua index 9ebc3d6fa..0b6985711 100644 --- a/mods/ENTITIES/mobs_mc/enderman.lua +++ b/mods/ENTITIES/mobs_mc/enderman.lua @@ -318,12 +318,12 @@ mobs:register_mob("mobs_mc:enderman", { for n = 1, #objs do local obj = objs[n] if obj then - if minetest.is_player(obj) then + --if minetest.is_player(obj) then -- Warp from players during day. --if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then -- self:teleport(nil) --end - else + if not obj:is_player() then local lua = obj:get_luaentity() if lua then if lua.name == "mcl_bows:arrow_entity" or lua.name == "mcl_throwing:snowball_entity" then diff --git a/mods/ENTITIES/mobs_mc/guardian.lua b/mods/ENTITIES/mobs_mc/guardian.lua index 241ac3444..0916010d2 100644 --- a/mods/ENTITIES/mobs_mc/guardian.lua +++ b/mods/ENTITIES/mobs_mc/guardian.lua @@ -13,7 +13,7 @@ mobs:register_mob("mobs_mc:guardian", { xp_min = 10, xp_max = 10, breath_max = -1, - passive = false, + passive = false, attack_type = "punch", pathfinding = 1, view_range = 16, @@ -94,7 +94,6 @@ mobs:register_mob("mobs_mc:guardian", { makes_footstep_sound = false, fly_in = { mobs_mc.items.water_source, mobs_mc.items.river_water_source }, jump = false, - view_range = 16, }) -- Spawning disabled due to size issues diff --git a/mods/ENTITIES/mobs_mc/guardian_elder.lua b/mods/ENTITIES/mobs_mc/guardian_elder.lua index e44796bad..0c871da7a 100644 --- a/mods/ENTITIES/mobs_mc/guardian_elder.lua +++ b/mods/ENTITIES/mobs_mc/guardian_elder.lua @@ -104,7 +104,6 @@ mobs:register_mob("mobs_mc:guardian_elder", { makes_footstep_sound = false, fly_in = { mobs_mc.items.water_source, mobs_mc.items.river_water_source }, jump = false, - view_range = 16, }) -- Spawning disabled due to size issues <- what do you mean? -j4i diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index 461c60efd..db23d410b 100644 --- a/mods/ENTITIES/mobs_mc/horse.lua +++ b/mods/ENTITIES/mobs_mc/horse.lua @@ -38,9 +38,9 @@ end local can_equip_horse_armor = function(entity_id) return entity_id == "mobs_mc:horse" or entity_id == "mobs_mc:skeleton_horse" or entity_id == "mobs_mc:zombie_horse" end -local can_equip_chest = function(entity_id) +--[[local can_equip_chest = function(entity_id) return entity_id == "mobs_mc:mule" or entity_id == "mobs_mc:donkey" -end +end]] local can_breed = function(entity_id) return entity_id == "mobs_mc:horse" or "mobs_mc:mule" or entity_id == "mobs_mc:donkey" end @@ -314,7 +314,7 @@ local horse = { -- Make sure tamed horse is mature and being clicked by owner only if self.tamed and not self.child and self.owner == clicker:get_player_name() then - local inv = clicker:get_inventory() + --local inv = clicker:get_inventory() -- detatch player already riding horse if self.driver and clicker == self.driver then diff --git a/mods/ENTITIES/mobs_mc/iron_golem.lua b/mods/ENTITIES/mobs_mc/iron_golem.lua index 48e573e13..d68dc157b 100644 --- a/mods/ENTITIES/mobs_mc/iron_golem.lua +++ b/mods/ENTITIES/mobs_mc/iron_golem.lua @@ -18,7 +18,7 @@ mobs:register_mob("mobs_mc:iron_golem", { passive = true, rotate = 270, hp_min = 100, - hp_max = 100, + hp_max = 100, protect = true, neutral = true, breath_max = -1, diff --git a/mods/ENTITIES/mobs_mc/llama.lua b/mods/ENTITIES/mobs_mc/llama.lua index 58f565ec1..9803b582b 100644 --- a/mods/ENTITIES/mobs_mc/llama.lua +++ b/mods/ENTITIES/mobs_mc/llama.lua @@ -35,7 +35,7 @@ mobs:register_mob("mobs_mc:llama", { shoot_arrow = function(self, pos, dir) -- 2-4 damage per arrow local dmg = 1 - mobs.shoot_projectile_handling("mobs_mc:spit", pos, dir, self.object:get_yaw(), self.object, nil, dmg) + mobs.shoot_projectile_handling("mobs_mc:spit", pos, dir, self.object:get_yaw(), self.object, nil, dmg) end, hp_min = 15, hp_max = 30, @@ -146,7 +146,7 @@ mobs:register_mob("mobs_mc:llama", { self.tamed = true self.owner = clicker:get_player_name() return - end + end --ignore other logic --make baby grow faster @@ -307,19 +307,19 @@ mobs:register_arrow("mobs_mc:spit", { tail_distance_divider = 4, hit_player = function(self, player) - if rawget(_G, "armor") and armor.last_damage_types then + --[[if rawget(_G, "armor") and armor.last_damage_types then armor.last_damage_types[player:get_player_name()] = "spit" - end + end]] player:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = self._damage}, }, nil) end, - hit_mob = function(self, mob) + hit_mob = function(self, mob) mob:punch(self.object, 1.0, { full_punch_interval = 1.0, - damage_groups = {fleshy = _damage}, + damage_groups = {fleshy = self._damage}, }, nil) end, diff --git a/mods/ENTITIES/mobs_mc/ocelot.lua b/mods/ENTITIES/mobs_mc/ocelot.lua index e36abec77..933d7aad4 100644 --- a/mods/ENTITIES/mobs_mc/ocelot.lua +++ b/mods/ENTITIES/mobs_mc/ocelot.lua @@ -151,7 +151,7 @@ end mobs:register_mob("mobs_mc:cat", cat) -local base_spawn_chance = 5000 +--local base_spawn_chance = 5000 -- Spawn ocelot --they get the same as the llama because I'm trying to rework so much of this code right now -j4i diff --git a/mods/ENTITIES/mobs_mc/parrot.lua b/mods/ENTITIES/mobs_mc/parrot.lua index de52c6252..88ab54ff5 100644 --- a/mods/ENTITIES/mobs_mc/parrot.lua +++ b/mods/ENTITIES/mobs_mc/parrot.lua @@ -44,7 +44,7 @@ mobs:register_mob("mobs_mc:parrot", { max = 2, looting = "common",}, }, - animation = { + animation = { stand_speed = 50, walk_speed = 50, fly_speed = 50, diff --git a/mods/ENTITIES/mobs_mc/pig.lua b/mods/ENTITIES/mobs_mc/pig.lua index d7433a092..14c9595b6 100644 --- a/mods/ENTITIES/mobs_mc/pig.lua +++ b/mods/ENTITIES/mobs_mc/pig.lua @@ -130,7 +130,7 @@ mobs:register_mob("mobs_mc:pig", { -- Put saddle on pig local item = clicker:get_wielded_item() local wielditem = item - + if item:get_name() == mobs_mc.items.saddle and self.saddle ~= "yes" then self.base_texture = { "blank.png", -- baby @@ -163,7 +163,7 @@ mobs:register_mob("mobs_mc:pig", { end -- Mount or detach player - local name = clicker:get_player_name() + --local name = clicker:get_player_name() if self.driver and clicker == self.driver then -- Detach if already attached mobs.detach(clicker, {x=1, y=0, z=0}) diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index 1527fd6da..7e01a1403 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -79,11 +79,11 @@ mobs:register_mob("mobs_mc:sheep", { makes_footstep_sound = true, walk_velocity = 1, run_velocity = 3, - + --head code has_head = true, head_bone = "head", - + swap_y_with_x = false, reverse_head_yaw = false, @@ -150,7 +150,6 @@ mobs:register_mob("mobs_mc:sheep", { do_custom = function(self, dtime) if not self.initial_color_set then local r = math.random(0,100000) - local textures if r <= 81836 then -- 81.836% self.color = "unicolor_white" diff --git a/mods/ENTITIES/mobs_mc/silverfish.lua b/mods/ENTITIES/mobs_mc/silverfish.lua index 148c4c722..05485bc51 100644 --- a/mods/ENTITIES/mobs_mc/silverfish.lua +++ b/mods/ENTITIES/mobs_mc/silverfish.lua @@ -46,7 +46,6 @@ mobs:register_mob("mobs_mc:silverfish", { view_range = 16, attack_type = "punch", damage = 1, - reach = 1, }) mobs:register_egg("mobs_mc:silverfish", S("Silverfish"), "mobs_mc_spawn_icon_silverfish.png", 0) diff --git a/mods/ENTITIES/mobs_mc/skeleton+stray.lua b/mods/ENTITIES/mobs_mc/skeleton+stray.lua index 37b1fc6dd..e0aaef215 100644 --- a/mods/ENTITIES/mobs_mc/skeleton+stray.lua +++ b/mods/ENTITIES/mobs_mc/skeleton+stray.lua @@ -31,12 +31,8 @@ local skeleton = { group_attack = true, visual = "mesh", mesh = "mobs_mc_skeleton.b3d", - textures = { { - "mcl_bows_bow_0.png", -- bow - "mobs_mc_skeleton.png", -- skeleton - } }, - --head code + --head code has_head = false, head_bone = "head", diff --git a/mods/ENTITIES/mobs_mc/vex.lua b/mods/ENTITIES/mobs_mc/vex.lua index c23643cda..da162e5bf 100644 --- a/mods/ENTITIES/mobs_mc/vex.lua +++ b/mods/ENTITIES/mobs_mc/vex.lua @@ -15,7 +15,7 @@ mobs:register_mob("mobs_mc:vex", { spawn_class = "hostile", pathfinding = 1, passive = false, - attack_type = "punch", + attack_type = "dogfight", physical = false, hp_min = 14, hp_max = 14, @@ -36,7 +36,6 @@ mobs:register_mob("mobs_mc:vex", { view_range = 16, walk_velocity = 3.2, run_velocity = 5.9, - attack_type = "dogfight", sounds = { -- TODO: random death = "mobs_mc_vex_death", diff --git a/mods/ENTITIES/mobs_mc/wither.lua b/mods/ENTITIES/mobs_mc/wither.lua index 7c9072f43..8bd8f5341 100644 --- a/mods/ENTITIES/mobs_mc/wither.lua +++ b/mods/ENTITIES/mobs_mc/wither.lua @@ -26,7 +26,6 @@ mobs:register_mob("mobs_mc:wither", { {"mobs_mc_wither.png"}, }, visual_size = {x=4, y=4}, - makes_footstep_sound = true, view_range = 16, fear_height = 4, walk_velocity = 2, @@ -81,7 +80,7 @@ mobs:register_mob("mobs_mc:wither", { end, }) -local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false +--local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false mobs:register_arrow("mobs_mc:wither_skull", { visual = "sprite", diff --git a/mods/ENTITIES/mobs_mc/wolf.lua b/mods/ENTITIES/mobs_mc/wolf.lua index 89a4b4629..2ce142c33 100644 --- a/mods/ENTITIES/mobs_mc/wolf.lua +++ b/mods/ENTITIES/mobs_mc/wolf.lua @@ -35,7 +35,7 @@ local wolf = { --head code has_head = false, head_bone = "head", - + swap_y_with_x = false, reverse_head_yaw = false, @@ -186,7 +186,7 @@ dog.on_rightclick = function(self, clicker) if is_food(item:get_name()) then -- Feed to increase health local hp = self.health - local hp_add = 0 + local hp_add -- Use eatable group to determine health boost local eatable = minetest.get_item_group(item, "eatable") if eatable > 0 then diff --git a/mods/ENTITIES/mobs_mc_gameconfig/init.lua b/mods/ENTITIES/mobs_mc_gameconfig/init.lua index 06d7eb87f..27cb4b4bf 100644 --- a/mods/ENTITIES/mobs_mc_gameconfig/init.lua +++ b/mods/ENTITIES/mobs_mc_gameconfig/init.lua @@ -200,14 +200,14 @@ end mobs_mc.override.enderman_block_texture_overrides = { ["mcl_core:cactus"] = ctable, -- FIXME: replace colorize colors with colors from palette - ["mcl_core:dirt_with_grass"] = - { - "mcl_core_grass_block_top.png^[colorize:green:90", - "default_dirt.png", - "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)", - "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)", - "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)", - "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)"} + ["mcl_core:dirt_with_grass"] = { + "mcl_core_grass_block_top.png^[colorize:green:90", + "default_dirt.png", + "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)", + "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)", + "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)", + "default_dirt.png^(mcl_core_grass_block_side_overlay.png^[colorize:green:90)", + }, } -- List of nodes on which mobs can spawn diff --git a/mods/ENVIRONMENT/lightning/init.lua b/mods/ENVIRONMENT/lightning/init.lua index 4a58866f9..2b79bf5ce 100644 --- a/mods/ENVIRONMENT/lightning/init.lua +++ b/mods/ENVIRONMENT/lightning/init.lua @@ -134,6 +134,7 @@ lightning.strike = function(pos) sound_play({ name = "lightning_thunder", gain = 10 }, { pos = pos, max_hear_distance = 500 }, true) -- damage nearby objects, transform mobs + -- TODO: use an API insteed of hardcoding this behaviour local objs = get_objects_inside_radius(pos2, 3.5) for o=1, #objs do local obj = objs[o] @@ -153,7 +154,7 @@ lightning.strike = function(pos) end obj:set_properties({textures = lua.base_texture}) -- villager → witch (no damage) - elseif lua and lua.name == "mobs_mc:villager" then + --elseif lua and lua.name == "mobs_mc:villager" then -- Witches are incomplete, this code is unused -- TODO: Enable this code when witches are working. --[[ diff --git a/mods/ENVIRONMENT/mcl_moon/init.lua b/mods/ENVIRONMENT/mcl_moon/init.lua index 4ee2623a6..200c6ca41 100644 --- a/mods/ENVIRONMENT/mcl_moon/init.lua +++ b/mods/ENVIRONMENT/mcl_moon/init.lua @@ -4,18 +4,16 @@ local SHEET_W = 4 local SHEET_H = 2 -- Randomize initial moon phase, based on map seed -local phase_offset local mg_seed = minetest.get_mapgen_setting("seed") local rand = PseudoRandom(mg_seed) local phase_offset = rand:next(0, MOON_PHASES - 1) -rand = nil minetest.log("info", "[mcl_moon] Moon phase offset of this world: "..phase_offset) mcl_moon = {} mcl_moon.MOON_PHASES = MOON_PHASES -mcl_moon.get_moon_phase = function() +function mcl_moon.get_moon_phase() local after_midday = 0 -- Moon phase changes after midday local tod = minetest.get_timeofday() @@ -25,7 +23,7 @@ mcl_moon.get_moon_phase = function() return (minetest.get_day_count() + phase_offset + after_midday) % MOON_PHASES end -local get_moon_texture = function() +local function get_moon_texture() local phase = mcl_moon.get_moon_phase() local x = phase % MOON_PHASES_HALF local y diff --git a/mods/ENVIRONMENT/mcl_void_damage/init.lua b/mods/ENVIRONMENT/mcl_void_damage/init.lua index d7681f8b0..fb22c3d14 100644 --- a/mods/ENVIRONMENT/mcl_void_damage/init.lua +++ b/mods/ENVIRONMENT/mcl_void_damage/init.lua @@ -1,5 +1,5 @@ local S = minetest.get_translator("mcl_void_damage") -local enable_damage = minetest.settings:get_bool("enable_damage") +--local enable_damage = minetest.settings:get_bool("enable_damage") local pos_to_dim = mcl_worlds.pos_to_dimension local dim_change = mcl_worlds.dimension_change @@ -38,9 +38,9 @@ minetest.register_on_mods_loaded(function() end self._void_timer = 0 - local void, void_deadly = is_in_void(pos) + local _, void_deadly = is_in_void(pos) if void_deadly then - local ent = obj:get_luaentity() + --local ent = obj:get_luaentity() obj:remove() return end diff --git a/mods/ENVIRONMENT/mcl_weather/rain.lua b/mods/ENVIRONMENT/mcl_weather/rain.lua index d8425784a..c128da942 100644 --- a/mods/ENVIRONMENT/mcl_weather/rain.lua +++ b/mods/ENVIRONMENT/mcl_weather/rain.lua @@ -20,7 +20,7 @@ mcl_weather.rain = { init_done = false, } -mcl_weather.rain.sound_handler = function(player) +function mcl_weather.rain.sound_handler(player) return minetest.sound_play("weather_rain", { to_player = player:get_player_name(), loop = true, @@ -28,7 +28,7 @@ mcl_weather.rain.sound_handler = function(player) end -- set skybox based on time (uses skycolor api) -mcl_weather.rain.set_sky_box = function() +function mcl_weather.rain.set_sky_box() if mcl_weather.state == "rain" then mcl_weather.skycolor.add_layer( "weather-pack-rain-sky", @@ -46,8 +46,7 @@ end -- creating manually parctiles instead of particles spawner because of easier to control -- spawn position. -mcl_weather.rain.add_rain_particles = function(player) - +function mcl_weather.rain.add_rain_particles(player) mcl_weather.rain.last_rp_count = 0 for i=mcl_weather.rain.particles_count, 1,-1 do local random_pos_x, random_pos_y, random_pos_z = mcl_weather.get_random_pos_by_player_look_dir(player) @@ -70,7 +69,7 @@ mcl_weather.rain.add_rain_particles = function(player) end -- Simple random texture getter -mcl_weather.rain.get_texture = function() +function mcl_weather.rain.get_texture() local texture_name local random_number = math.random() if random_number > 0.33 then @@ -85,7 +84,7 @@ end -- register player for rain weather. -- basically needs for origin sky reference and rain sound controls. -mcl_weather.rain.add_player = function(player) +function mcl_weather.rain.add_player(player) if mcl_weather.players[player:get_player_name()] == nil then local player_meta = {} player_meta.origin_sky = {player:get_sky()} @@ -95,7 +94,7 @@ end -- remove player from player list effected by rain. -- be sure to remove sound before removing player otherwise soundhandler reference will be lost. -mcl_weather.rain.remove_player = function(player) +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 player:set_clouds({color="#FFF0F0E5"}) @@ -119,7 +118,7 @@ end) -- adds and removes rain sound depending how much rain particles around player currently exist. -- have few seconds delay before each check to avoid on/off sound too often -- when player stay on 'edge' where sound should play and stop depending from random raindrop appearance. -mcl_weather.rain.update_sound = function(player) +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 @@ -140,7 +139,7 @@ mcl_weather.rain.update_sound = function(player) end -- rain sound removed from player. -mcl_weather.rain.remove_sound = function(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 minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0) @@ -150,7 +149,7 @@ mcl_weather.rain.remove_sound = function(player) end -- callback function for removing rain -mcl_weather.rain.clear = function() +function mcl_weather.rain.clear() mcl_weather.rain.raining = false mcl_weather.rain.sky_last_update = -1 mcl_weather.rain.init_done = false @@ -166,11 +165,10 @@ minetest.register_globalstep(function(dtime) if mcl_weather.state ~= "rain" then return false end - mcl_weather.rain.make_weather() end) -mcl_weather.rain.make_weather = function() +function mcl_weather.rain.make_weather() if mcl_weather.rain.init_done == false then mcl_weather.rain.raining = true mcl_weather.rain.set_sky_box() @@ -190,7 +188,7 @@ mcl_weather.rain.make_weather = function() end -- Switch the number of raindrops: "thunder" for many raindrops, otherwise for normal raindrops -mcl_weather.rain.set_particles_mode = function(mode) +function mcl_weather.rain.set_particles_mode(mode) if mode == "thunder" then mcl_weather.rain.particles_count = PARTICLES_COUNT_THUNDER else @@ -249,7 +247,7 @@ if mcl_weather.allow_abm then end end end - }) + }) -- Wetten the soil minetest.register_abm({ @@ -264,7 +262,7 @@ if mcl_weather.allow_abm then end end end - }) + }) end if mcl_weather.reg_weathers.rain == nil then diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index 061634fcb..488f6b1a1 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -11,7 +11,7 @@ mcl_weather.skycolor = { -- Update interval. update_interval = 15, - -- Main sky colors: starts from midnight to midnight. + -- Main sky colors: starts from midnight to midnight. -- Please do not set directly. Use add_layer instead. colors = {}, @@ -205,8 +205,8 @@ mcl_weather.skycolor = { -- Returns first player sky color. I assume that all players are in same color layout. get_current_bg_color = function() local players = mcl_weather.skycolor.utils.get_players(nil) - for _, player in ipairs(players) do - return player:get_sky() + if players[1] then + return players[1]:get_sky() end return nil end diff --git a/mods/ENVIRONMENT/mcl_weather/snow.lua b/mods/ENVIRONMENT/mcl_weather/snow.lua index 3a0c539e3..9ec9fbac1 100644 --- a/mods/ENVIRONMENT/mcl_weather/snow.lua +++ b/mods/ENVIRONMENT/mcl_weather/snow.lua @@ -5,80 +5,80 @@ mcl_weather.snow = {} mcl_weather.snow.particles_count = 15 mcl_weather.snow.init_done = false --- calculates coordinates and draw particles for snow weather +-- calculates coordinates and draw particles for snow weather mcl_weather.snow.add_snow_particles = function(player) - mcl_weather.rain.last_rp_count = 0 - for i=mcl_weather.snow.particles_count, 1,-1 do - local random_pos_x, random_pos_y, random_pos_z = mcl_weather.get_random_pos_by_player_look_dir(player) - random_pos_y = math.random() + math.random(player:get_pos().y - 1, player:get_pos().y + 7) - if minetest.get_node_light({x=random_pos_x, y=random_pos_y, z=random_pos_z}, 0.5) == 15 then - mcl_weather.rain.last_rp_count = mcl_weather.rain.last_rp_count + 1 - minetest.add_particle({ - pos = {x=random_pos_x, y=random_pos_y, z=random_pos_z}, - velocity = {x = math.random(-100,100)*0.001, y = math.random(-300,-100)*0.004, z = math.random(-100,100)*0.001}, - acceleration = {x = 0, y=0, z = 0}, - expirationtime = 8.0, - size = 1, - collisiondetection = true, - collision_removal = true, - object_collision = false, - vertical = false, - texture = mcl_weather.snow.get_texture(), - playername = player:get_player_name() - }) - end - end + mcl_weather.rain.last_rp_count = 0 + for i=mcl_weather.snow.particles_count, 1,-1 do + local random_pos_x, _, random_pos_z = mcl_weather.get_random_pos_by_player_look_dir(player) + local random_pos_y = math.random() + math.random(player:get_pos().y - 1, player:get_pos().y + 7) + if minetest.get_node_light({x=random_pos_x, y=random_pos_y, z=random_pos_z}, 0.5) == 15 then + mcl_weather.rain.last_rp_count = mcl_weather.rain.last_rp_count + 1 + minetest.add_particle({ + pos = {x=random_pos_x, y=random_pos_y, z=random_pos_z}, + velocity = {x = math.random(-100,100)*0.001, y = math.random(-300,-100)*0.004, z = math.random(-100,100)*0.001}, + acceleration = {x = 0, y=0, z = 0}, + expirationtime = 8.0, + size = 1, + collisiondetection = true, + collision_removal = true, + object_collision = false, + vertical = false, + texture = mcl_weather.snow.get_texture(), + playername = player:get_player_name() + }) + end + end end mcl_weather.snow.set_sky_box = function() - mcl_weather.skycolor.add_layer( - "weather-pack-snow-sky", - {{r=0, g=0, b=0}, - {r=85, g=86, b=86}, - {r=135, g=135, b=135}, - {r=85, g=86, b=86}, - {r=0, g=0, b=0}}) - mcl_weather.skycolor.active = true - for _, player in pairs(get_connected_players()) do - player:set_clouds({color="#ADADADE8"}) - end - mcl_weather.skycolor.active = true + mcl_weather.skycolor.add_layer( + "weather-pack-snow-sky", + {{r=0, g=0, b=0}, + {r=85, g=86, b=86}, + {r=135, g=135, b=135}, + {r=85, g=86, b=86}, + {r=0, g=0, b=0}}) + mcl_weather.skycolor.active = true + for _, player in pairs(get_connected_players()) do + player:set_clouds({color="#ADADADE8"}) + end + mcl_weather.skycolor.active = true end -mcl_weather.snow.clear = function() - mcl_weather.skycolor.remove_layer("weather-pack-snow-sky") - mcl_weather.snow.init_done = false +function mcl_weather.snow.clear() + mcl_weather.skycolor.remove_layer("weather-pack-snow-sky") + mcl_weather.snow.init_done = false end -- Simple random texture getter -mcl_weather.snow.get_texture = function() - return "weather_pack_snow_snowflake"..math.random(1,2)..".png" +function mcl_weather.snow.get_texture() + return "weather_pack_snow_snowflake"..math.random(1,2)..".png" end local timer = 0 minetest.register_globalstep(function(dtime) - if mcl_weather.state ~= "snow" then - return false - end - - timer = timer + dtime; - if timer >= 0.5 then - timer = 0 - else - return - end + if mcl_weather.state ~= "snow" then + return false + end - if mcl_weather.snow.init_done == false then - mcl_weather.snow.set_sky_box() - mcl_weather.snow.init_done = true - end + timer = timer + dtime; + if timer >= 0.5 then + timer = 0 + else + return + end - for _, player in pairs(get_connected_players()) do - if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos())) then - return false - end - mcl_weather.snow.add_snow_particles(player) - end + if mcl_weather.snow.init_done == false then + mcl_weather.snow.set_sky_box() + mcl_weather.snow.init_done = true + end + + for _, player in pairs(get_connected_players()) do + if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos())) then + return false + end + mcl_weather.snow.add_snow_particles(player) + end end) -- register snow weather diff --git a/mods/ENVIRONMENT/mcl_weather/thunder.lua b/mods/ENVIRONMENT/mcl_weather/thunder.lua index ece673170..f8e5a0371 100644 --- a/mods/ENVIRONMENT/mcl_weather/thunder.lua +++ b/mods/ENVIRONMENT/mcl_weather/thunder.lua @@ -4,60 +4,58 @@ local get_connected_players = minetest.get_connected_players lightning.auto = false mcl_weather.thunder = { - next_strike = 0, - min_delay = 3, - max_delay = 12, - init_done = false, + next_strike = 0, + min_delay = 3, + max_delay = 12, + init_done = false, } minetest.register_globalstep(function(dtime) - if mcl_weather.get_weather() ~= "thunder" then - return false - end - - mcl_weather.rain.set_particles_mode("thunder") - mcl_weather.rain.make_weather() + if mcl_weather.get_weather() ~= "thunder" then + return false + end - if mcl_weather.thunder.init_done == false then - mcl_weather.skycolor.add_layer( - "weather-pack-thunder-sky", - {{r=0, g=0, b=0}, - {r=40, g=40, b=40}, - {r=85, g=86, b=86}, - {r=40, g=40, b=40}, - {r=0, g=0, b=0}}) - mcl_weather.skycolor.active = true - for _, player in pairs(get_connected_players()) do - player:set_clouds({color="#3D3D3FE8"}) - end - mcl_weather.thunder.init_done = true - end - - if (mcl_weather.thunder.next_strike <= minetest.get_gametime()) then - lightning.strike() - local delay = math.random(mcl_weather.thunder.min_delay, mcl_weather.thunder.max_delay) - mcl_weather.thunder.next_strike = minetest.get_gametime() + delay - end + mcl_weather.rain.set_particles_mode("thunder") + mcl_weather.rain.make_weather() + if mcl_weather.thunder.init_done == false then + mcl_weather.skycolor.add_layer("weather-pack-thunder-sky", { + {r=0, g=0, b=0}, + {r=40, g=40, b=40}, + {r=85, g=86, b=86}, + {r=40, g=40, b=40}, + {r=0, g=0, b=0}, + }) + mcl_weather.skycolor.active = true + for _, player in pairs(get_connected_players()) do + player:set_clouds({color="#3D3D3FE8"}) + end + mcl_weather.thunder.init_done = true + end + if (mcl_weather.thunder.next_strike <= minetest.get_gametime()) then + lightning.strike() + local delay = math.random(mcl_weather.thunder.min_delay, mcl_weather.thunder.max_delay) + mcl_weather.thunder.next_strike = minetest.get_gametime() + delay + end end) -mcl_weather.thunder.clear = function() - mcl_weather.rain.clear() - mcl_weather.skycolor.remove_layer("weather-pack-thunder-sky") - mcl_weather.skycolor.remove_layer("lightning") - mcl_weather.thunder.init_done = false +function mcl_weather.thunder.clear() + mcl_weather.rain.clear() + mcl_weather.skycolor.remove_layer("weather-pack-thunder-sky") + mcl_weather.skycolor.remove_layer("lightning") + mcl_weather.thunder.init_done = false end -- register thunderstorm weather if mcl_weather.reg_weathers.thunder == nil then - mcl_weather.reg_weathers.thunder = { - clear = mcl_weather.thunder.clear, - light_factor = 0.33333, - -- 10min - 20min - min_duration = 600, - max_duration = 1200, - transitions = { - [100] = "rain", - } - } + mcl_weather.reg_weathers.thunder = { + clear = mcl_weather.thunder.clear, + light_factor = 0.33333, + -- 10min - 20min + min_duration = 600, + max_duration = 1200, + transitions = { + [100] = "rain", + }, + } end diff --git a/mods/ENVIRONMENT/mcl_weather/weather_core.lua b/mods/ENVIRONMENT/mcl_weather/weather_core.lua index d3772dc7e..b8deba318 100644 --- a/mods/ENVIRONMENT/mcl_weather/weather_core.lua +++ b/mods/ENVIRONMENT/mcl_weather/weather_core.lua @@ -1,27 +1,29 @@ local S = minetest.get_translator("mcl_weather") +local math = math + -- weather states, 'none' is default, other states depends from active mods mcl_weather.state = "none" - + -- player list for saving player meta info mcl_weather.players = {} - + -- default weather check interval for global step mcl_weather.check_interval = 5 - + -- weather min duration mcl_weather.min_duration = 600 - + -- weather max duration mcl_weather.max_duration = 9000 -- weather calculated end time mcl_weather.end_time = nil - + -- registered weathers mcl_weather.reg_weathers = {} --- global flag to disable/enable ABM logic. +-- global flag to disable/enable ABM logic. mcl_weather.allow_abm = true mcl_weather.reg_weathers["none"] = { @@ -51,7 +53,7 @@ mcl_weather.get_rand_end_time = function(min_duration, max_duration) r = math.random(min_duration, max_duration) else r = math.random(mcl_weather.min_duration, mcl_weather.max_duration) - end + end return minetest.get_gametime() + r end @@ -80,8 +82,8 @@ end mcl_weather.is_underwater = function(player) local ppos = player:get_pos() local offset = player:get_eye_offset() - local player_eye_pos = {x = ppos.x + offset.x, - y = ppos.y + offset.y + 1.5, + local player_eye_pos = {x = ppos.x + offset.x, + y = ppos.y + offset.y + 1.5, z = ppos.z + offset.z} local node_level = minetest.get_node_level(player_eye_pos) if node_level == 8 or node_level == 7 then @@ -91,14 +93,12 @@ mcl_weather.is_underwater = function(player) end -- trying to locate position for particles by player look direction for performance reason. --- it is costly to generate many particles around player so goal is focus mainly on front view. +-- it is costly to generate many particles around player so goal is focus mainly on front view. mcl_weather.get_random_pos_by_player_look_dir = function(player) local look_dir = player:get_look_dir() local player_pos = player:get_pos() - local random_pos_x = 0 - local random_pos_y = 0 - local random_pos_z = 0 + local random_pos_x, random_pos_y, random_pos_z if look_dir.x > 0 then if look_dir.z > 0 then @@ -208,7 +208,7 @@ minetest.register_privilege("weather_manager", { give_to_singleplayer = false }) --- Weather command definition. Set +-- Weather command definition. Set minetest.register_chatcommand("weather", { params = "(clear | rain | snow | thunder) []", description = S("Changes the weather to the specified parameter."), @@ -270,7 +270,7 @@ minetest.register_chatcommand("toggledownfall", { local weather_allow_abm = minetest.settings:get_bool("weather_allow_abm") if weather_allow_abm ~= nil and weather_allow_abm == false then mcl_weather.allow_abm = false -end +end local load_weather = function() diff --git a/mods/HELP/doc/doc/init.lua b/mods/HELP/doc/doc/init.lua index 029914a53..a04d83bda 100644 --- a/mods/HELP/doc/doc/init.lua +++ b/mods/HELP/doc/doc/init.lua @@ -233,7 +233,7 @@ end -- Returns true if the specified entry has been viewed by the player function doc.entry_viewed(playername, category_id, entry_id) - local entry, category_id, entry_id = get_entry(category_id, entry_id) + local _, category_id, entry_id = get_entry(category_id, entry_id) if doc.data.players[playername].stored_data.viewed[category_id] == nil then return false else @@ -243,7 +243,7 @@ end -- Returns true if the specified entry is hidden from the player function doc.entry_revealed(playername, category_id, entry_id) - local entry, category_id, entry_id = get_entry(category_id, entry_id) + local _, category_id, entry_id = get_entry(category_id, entry_id) local hidden = doc.data.categories[category_id].entries[entry_id].hidden if doc.data.players[playername].stored_data.revealed[category_id] == nil then return not hidden @@ -302,7 +302,7 @@ function doc.show_entry(playername, category_id, entry_id, ignore_hidden) minetest.show_formspec(playername, "doc:error_no_categories", doc.formspec_error_no_categories()) return end - local entry, category_id, entry_id = get_entry(category_id, entry_id) + local _, category_id, entry_id = get_entry(category_id, entry_id) if ignore_hidden or doc.entry_revealed(playername, category_id, entry_id) then local playerdata = doc.data.players[playername] playerdata.category = category_id @@ -587,8 +587,6 @@ doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width, formstring = formstring .. "label["..nx..","..ny..";"..i.."]" pos = pos + 1 end - local bw, bh - return formstring, ih end diff --git a/mods/HELP/doc/doc_items/init.lua b/mods/HELP/doc/doc_items/init.lua index 5a7e161a3..f94a67c7c 100644 --- a/mods/HELP/doc/doc_items/init.lua +++ b/mods/HELP/doc/doc_items/init.lua @@ -166,7 +166,7 @@ local factoid_toolcaps = function(tool_capabilities, check_uses) local useslines = 0 for k,v in pairs(groupcaps) do -- Mining capabilities - local minrating, maxrating + --[[local minrating, maxrating if v.times then for rating, time in pairs(v.times) do if minrating == nil then minrating = rating else @@ -179,7 +179,7 @@ local factoid_toolcaps = function(tool_capabilities, check_uses) else minrating = 1 maxrating = 1 - end + end]] local maxlevel = v.maxlevel if not maxlevel then -- Default from tool.h @@ -579,11 +579,8 @@ doc.add_category("nodes", { description = S("Item reference of blocks and other things which are capable of occupying space"), build_formspec = function(data, playername) if data then - local formstring = "" - local datastring = "" - - formstring = entry_image(data) - datastring = factoids_header(data, "nodes") + local formstring = entry_image(data) + local datastring = factoids_header(data, "nodes") local liquid = data.def.liquidtype ~= "none" and minetest.get_item_group(data.itemstring, "fake_liquid") == 0 if not forbidden_core_factoids.basics then @@ -836,7 +833,7 @@ doc.add_category("nodes", { elseif type(data.def.drop) == "table" and data.def.drop.items ~= nil then local max = data.def.drop.max_items local dropstring = "" - local dropstring_base = "" + local dropstring_base if max == nil then dropstring_base = N("This block will drop the following items when mined: @1.") elseif max == 1 then @@ -854,7 +851,7 @@ doc.add_category("nodes", { local rarity_history = {} for i=1,#data.def.drop.items do local local_rarity = data.def.drop.items[i].rarity - local chance = 1 + local chance local rarity = 1 if local_rarity == nil then local_rarity = 1 @@ -939,7 +936,6 @@ doc.add_category("nodes", { end local rarity = probtable.rarity - local raritystring = "" -- No percentage if there's only one possible guaranteed drop if not(rarity == 1 and #data.def.drop.items == 1) then local chance = (1/rarity)*100 @@ -1088,11 +1084,8 @@ doc.add_category("tools", { end, build_formspec = function(data, playername) if data then - local formstring = "" - local datastring = "" - - formstring = entry_image(data) - datastring = factoids_header(data, "tools") + local formstring = entry_image(data) + local datastring = factoids_header(data, "tools") -- Overwritten durability info if type(data.def._doc_items_durability) == "number" then @@ -1122,11 +1115,8 @@ doc.add_category("craftitems", { description = S("Item reference of items which are neither blocks, tools or weapons (esp. crafting items)"), build_formspec = function(data, playername) if data then - local formstring = "" - local datastring = "" - - formstring = entry_image(data) - datastring = factoids_header(data, "craftitems") + local formstring = entry_image(data) + local datastring = factoids_header(data, "craftitems") datastring = datastring .. factoids_footer(data, playername, "craftitems") formstring = formstring .. doc.widgets.text(datastring, nil, nil, doc.FORMSPEC.ENTRY_WIDTH - 1.2) diff --git a/mods/HELP/mcl_craftguide/init.lua b/mods/HELP/mcl_craftguide/init.lua index d05d8b3d0..bfaef6011 100644 --- a/mods/HELP/mcl_craftguide/init.lua +++ b/mods/HELP/mcl_craftguide/init.lua @@ -417,9 +417,9 @@ local function get_tooltip(item, groups, cooktime, burntime) -- and just print the normal item name without special formatting if groups[1] == "compass" or groups[1] == "clock" then groupstr = reg_items[item].description - elseif group_names[groups[1]] then + elseif g then -- Use the special group name string - groupstr = minetest.colorize(gcol, group_names[groups[1]]) + groupstr = minetest.colorize(gcol, g) else --[[ Fallback: Generic group explanation: This always works, but the internally used group name (which @@ -545,7 +545,7 @@ local function get_recipe_fs(data, iY) if custom_recipe or shapeless or recipe.type == "cooking" then local icon = custom_recipe and custom_recipe.icon or - shapeless and "shapeless" or "furnace" + shapeless and "shapeless" or "furnace" if recipe.type == "cooking" then icon = "default_furnace_front_active.png" @@ -638,7 +638,7 @@ local function make_formspec(name) fs[#fs + 1] = "background9[1,1;1,1;mcl_base_textures_background9.png;true;7]" fs[#fs + 1] = fmt([[ tooltip[size_inc;%s] - tooltip[size_dec;%s] ]], + tooltip[size_dec;%s] ]], ESC(S("Increase window size")), ESC(S("Decrease window size"))) @@ -656,9 +656,9 @@ local function make_formspec(name) ]] fs[#fs + 1] = fmt([[ tooltip[search;%s] - tooltip[clear;%s] - tooltip[prev;%s] - tooltip[next;%s] ]], + tooltip[clear;%s] + tooltip[prev;%s] + tooltip[next;%s] ]], ESC(S("Search")), ESC(S("Reset")), ESC(S("Previous page")), diff --git a/mods/HELP/mcl_doc/init.lua b/mods/HELP/mcl_doc/init.lua index d926550f8..fa6ae6c05 100644 --- a/mods/HELP/mcl_doc/init.lua +++ b/mods/HELP/mcl_doc/init.lua @@ -154,7 +154,7 @@ doc.sub.items.register_factoid(nil, "use", function(itemstring, def) return s end) doc.sub.items.register_factoid(nil, "groups", function(itemstring, def) - local def = minetest.registered_items[itemstring] + --local def = minetest.registered_items[itemstring] local s = "" local use = minetest.get_item_group(itemstring, "mcl_armor_uses") local pts = minetest.get_item_group(itemstring, "mcl_armor_points") @@ -289,7 +289,7 @@ doc.sub.items.register_factoid("nodes", "drops", function(itemstring, def) local itemname = item:get_name() local itemcount = item:get_count() local idef = minetest.registered_items[itemname] - local text = "" + local text if idef.description and idef.description ~= "" then text = idef.description else diff --git a/mods/HELP/mcl_tt/snippets_base.lua b/mods/HELP/mcl_tt/snippets_base.lua index 8242f2c19..bd5495721 100644 --- a/mods/HELP/mcl_tt/snippets_base.lua +++ b/mods/HELP/mcl_tt/snippets_base.lua @@ -1,6 +1,6 @@ local S = minetest.get_translator("mcl_tt") -local function get_min_digtime(caps) +--[[local function get_min_digtime(caps) local mintime local unique = true local maxlevel = caps.maxlevel @@ -25,7 +25,7 @@ local function get_min_digtime(caps) end end return mintime, unique -end +end]] local function newline(str) if str ~= "" then @@ -47,7 +47,7 @@ tt.register_snippet(function(itemstring, toolcaps) local minestring = "" local capstr = "" local caplines = 0 - for k,v in pairs(groupcaps) do + for _,v in pairs(groupcaps) do local speedstr = "" local miningusesstr = "" -- Mining capabilities @@ -153,9 +153,9 @@ tt.register_snippet(function(itemstring, toolcaps) end) -- Weapon stats -tt.register_snippet(function(itemstring) +--[[tt.register_snippet(function(itemstring) local def = minetest.registered_items[itemstring] -end) +end)]] -- Food tt.register_snippet(function(itemstring) diff --git a/mods/HELP/mcl_tt/snippets_mcl.lua b/mods/HELP/mcl_tt/snippets_mcl.lua index 3d13df751..b10021640 100644 --- a/mods/HELP/mcl_tt/snippets_mcl.lua +++ b/mods/HELP/mcl_tt/snippets_mcl.lua @@ -2,7 +2,7 @@ local S = minetest.get_translator("mcl_tt") -- Armor tt.register_snippet(function(itemstring) - local def = minetest.registered_items[itemstring] + --local def = minetest.registered_items[itemstring] local s = "" local head = minetest.get_item_group(itemstring, "armor_head") local torso = minetest.get_item_group(itemstring, "armor_torso") @@ -26,7 +26,7 @@ tt.register_snippet(function(itemstring) return s end) tt.register_snippet(function(itemstring, _, itemstack) - local def = minetest.registered_items[itemstring] + --local def = minetest.registered_items[itemstring] local s = "" local use = minetest.get_item_group(itemstring, "mcl_armor_uses") local pts = minetest.get_item_group(itemstring, "mcl_armor_points") @@ -75,7 +75,7 @@ tt.register_snippet(function(itemstring) end) tt.register_snippet(function(itemstring) - local def = minetest.registered_items[itemstring] + --local def = minetest.registered_items[itemstring] if minetest.get_item_group(itemstring, "crush_after_fall") == 1 then return S("Deals damage when falling"), mcl_colors.YELLOW end diff --git a/mods/HUD/awards/triggers.lua b/mods/HUD/awards/triggers.lua index 318a4b281..995dd005c 100644 --- a/mods/HUD/awards/triggers.lua +++ b/mods/HUD/awards/triggers.lua @@ -250,9 +250,7 @@ minetest.register_on_dignode(function(pos, oldnode, digger) local tnodedug = string.split(entry.node, ":") local tmod = tnodedug[1] local titem = tnodedug[2] - if not tmod or not titem or not data.count[tmod] or not data.count[tmod][titem] then - -- table running failed! - elseif data.count[tmod][titem] > entry.target-1 then + if tmod and titem and data.count[tmod] and data.count[tmod][titem] and data.count[tmod][titem] > entry.target-1 then return entry.award end elseif awards.get_total_item_count(data, "count") > entry.target-1 then @@ -277,9 +275,7 @@ minetest.register_on_placenode(function(pos, node, digger) local tnodedug = string.split(entry.node, ":") local tmod = tnodedug[1] local titem = tnodedug[2] - if not tmod or not titem or not data.place[tmod] or not data.place[tmod][titem] then - -- table running failed! - elseif data.place[tmod][titem] > entry.target-1 then + if tmod and titem and data.place[tmod] and data.place[tmod][titem] and data.place[tmod][titem] > entry.target-1 then return entry.award end elseif awards.get_total_item_count(data, "place") > entry.target-1 then @@ -303,9 +299,7 @@ minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, local titemstring = string.split(entry.item, ":") local tmod = titemstring[1] local titem = titemstring[2] - if not tmod or not titem or not data.eat[tmod] or not data.eat[tmod][titem] then - -- table running failed! - elseif data.eat[tmod][titem] > entry.target-1 then + if tmod and titem and data.eat[tmod] and data.eat[tmod][titem] and data.eat[tmod][titem] > entry.target-1 then return entry.award end elseif awards.get_total_item_count(data, "eat") > entry.target-1 then @@ -331,9 +325,7 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv local titemcrafted = string.split(entry.item, ":") local tmod = titemcrafted[1] local titem = titemcrafted[2] - if not tmod or not titem or not data.craft[tmod] or not data.craft[tmod][titem] then - -- table running failed! - elseif data.craft[tmod][titem] > entry.target-1 then + if tmod and titem and data.craft[tmod] and data.craft[tmod][titem] and data.craft[tmod][titem] > entry.target-1 then return entry.award end elseif awards.get_total_item_count(data, "craft") > entry.target-1 then diff --git a/mods/HUD/awards/unified_inventory.lua b/mods/HUD/awards/unified_inventory.lua index be5ca5f94..3dc238e1a 100644 --- a/mods/HUD/awards/unified_inventory.lua +++ b/mods/HUD/awards/unified_inventory.lua @@ -1,6 +1,5 @@ -if minetest.get_modpath("unified_inventory") ~= nil then - local S = minetest.get_translator("awards") - +if minetest.get_modpath("unified_inventory") then + local S = minetest.get_translator(minetest.get_current_modname()) unified_inventory.register_button("awards", { type = "image", image = "awards_ui_icon.png", diff --git a/mods/HUD/hudbars/init.lua b/mods/HUD/hudbars/init.lua index 6f90aa03d..a88d14dcf 100644 --- a/mods/HUD/hudbars/init.lua +++ b/mods/HUD/hudbars/init.lua @@ -1,17 +1,22 @@ -local S = minetest.get_translator("hudbars") +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 -hb = {} +local math = math +local table = table -hb.hudtables = {} - --- number of registered HUD bars -hb.hudbars_count = 0 - --- table which records which HUD bar slots have been “registered” so far; used for automatic positioning -hb.registered_slots = {} - -hb.settings = {} +hb = { + hudtables = {}, + -- number of registered HUD bars + hudbars_count = 0, + -- table which records which HUD bar slots have been “registered” so far; used for automatic positioning + registered_slots = {}, + settings = {}, + -- Table which contains all players with active default HUD bars (only for internal use) + players = {}, +} function hb.load_setting(sname, stype, defaultval, valid_values) local sval @@ -45,7 +50,8 @@ function hb.load_setting(sname, stype, defaultval, valid_values) end -- Load default settings -dofile(minetest.get_modpath("hudbars").."/default_settings.lua") +dofile(modpath.."/default_settings.lua") + if minetest.get_modpath("mcl_experience") and not minetest.is_creative_enabled("") then -- reserve some space for experience bar: hb.settings.start_offset_left.y = hb.settings.start_offset_left.y - 20 @@ -85,9 +91,6 @@ local function make_label(format_string, format_string_config, label, start_valu return ret end --- Table which contains all players with active default HUD bars (only for internal use) -hb.players = {} - function hb.value_to_barlength(value, max) if max == 0 then return 0 diff --git a/mods/HUD/mcl_death_messages/init.lua b/mods/HUD/mcl_death_messages/init.lua index 0432c3488..107daa2a3 100644 --- a/mods/HUD/mcl_death_messages/init.lua +++ b/mods/HUD/mcl_death_messages/init.lua @@ -237,12 +237,10 @@ mcl_damage.register_on_damage(function(obj, damage, reason) end) minetest.register_globalstep(function(dtime) - local new_assist = {} - for obj, tbl in pairs(mcl_death_messages.assist) do tbl.timeout = tbl.timeout - dtime - if (obj:is_player() or obj:get_luaentity()) and tbl.timeout > 0 then - new_assist[obj] = tbl + if not obj:is_player() and not obj:get_luaentity() or tbl.timeout > 0 then + mcl_death_messages.assist[obj] = nil end end end) diff --git a/mods/HUD/mcl_experience/init.lua b/mods/HUD/mcl_experience/init.lua index b52611d5a..a40599d17 100644 --- a/mods/HUD/mcl_experience/init.lua +++ b/mods/HUD/mcl_experience/init.lua @@ -1,5 +1,11 @@ local S = minetest.get_translator("mcl_experience") + mcl_experience = {} + +local vector = vector +local math = math +local string = string + local pool = {} local registered_nodes local max_xp = 2^31-1 @@ -114,9 +120,9 @@ end hud_manager.hud_exists = function(player,hud_name) local name = player:get_player_name() if player_huds[name] and player_huds[name][hud_name] then - return(true) + return true else - return(false) + return false end end ------------------- @@ -144,7 +150,7 @@ end) function mcl_experience.get_player_xp_level(player) local name = player:get_player_name() - return(pool[name].level) + return pool[name].level end function mcl_experience.set_player_xp_level(player,level) @@ -262,7 +268,6 @@ function mcl_experience.add_experience(player, experience) if #final_candidates > 0 then local can = final_candidates[math.random(#final_candidates)] local stack, list, index, wear = can.stack, can.list, can.index, can.wear - local unbreaking_level = mcl_enchanting.get_enchantment(stack, "unbreaking") local uses = mcl_util.calculate_durability(stack) local multiplier = 2 * 65535 / uses local repair = experience * multiplier @@ -329,14 +334,12 @@ minetest.register_on_dieplayer(function(player) mcl_experience.throw_experience(player:get_pos(), xp_amount) end) - -local name local collector, pos, pos2 local direction, distance, player_velocity, goal local currentvel, acceleration, multiplier, velocity local node, vel, def local is_moving, is_slippery, slippery, slip_factor -local size, data +local size local function xp_step(self, dtime) --if item set to be collected then only execute go to player if self.collected == true then diff --git a/mods/HUD/mcl_hbarmor/init.lua b/mods/HUD/mcl_hbarmor/init.lua index cbb724493..9f0c7204a 100644 --- a/mods/HUD/mcl_hbarmor/init.lua +++ b/mods/HUD/mcl_hbarmor/init.lua @@ -1,31 +1,34 @@ -local S = minetest.get_translator("mcl_hbarmor") +local S = minetest.get_translator(minetest.get_current_modname()) -local mcl_hbarmor = {} +local math = math +local tonumber = tonumber --- HUD statbar values -mcl_hbarmor.armor = {} +local get_connected_players = minetest.get_connected_players --- Stores if player's HUD bar has been initialized so far. -mcl_hbarmor.player_active = {} +local mcl_hbarmor = { + -- HUD statbar values + armor = {}, + -- Stores if player's HUD bar has been initialized so far. + player_active = {}, + -- Time difference in seconds between updates to the HUD armor bar. + -- Increase this number for slow servers. + tick = 0.1, + -- If true, the armor bar is hidden when the player does not wear any armor + autohide = true, +} --- Time difference in seconds between updates to the HUD armor bar. --- Increase this number for slow servers. -mcl_hbarmor.tick = 0.1 +local tick_config = minetest.settings:get("mcl_hbarmor_tick") --- If true, the armor bar is hidden when the player does not wear any armor -mcl_hbarmor.autohide = true - -set = minetest.settings:get("mcl_hbarmor_tick") -if tonumber(set) ~= nil then - mcl_hbarmor.tick = tonumber(set) +if tonumber(tick_config) ~= nil then + mcl_hbarmor.tick = tonumber(tick_config) end -local must_hide = function(playername, arm) +local function must_hide(playername, arm) return arm == 0 end -local arm_printable = function(arm) +local function arm_printable(arm) return math.ceil(math.floor(arm+0.5)) end @@ -106,12 +109,13 @@ end) local main_timer = 0 local timer = 0 --[[minetest.register_globalstep(function(dtime) + --TODO: replace this by playerglobalstep API then implemented main_timer = main_timer + dtime timer = timer + dtime if main_timer > mcl_hbarmor.tick or timer > 4 then if minetest.settings:get_bool("enable_damage") then if main_timer > mcl_hbarmor.tick then main_timer = 0 end - for _,player in pairs(minetest.get_connected_players()) do + for _,player in pairs(get_connected_players()) do local name = player:get_player_name() if mcl_hbarmor.player_active[name] == true then local ret = mcl_hbarmor.get_armor(player) diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index 61ba39b10..4d73aca35 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -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") ~= nil -- Create tables local builtin_filter_ids = {"blocks","deco","redstone","rail","food","tools","combat","mobs","brew","matr","misc","all"} @@ -161,7 +161,7 @@ end local function init(player) local playername = player:get_player_name() - local inv = minetest.create_detached_inventory("creative_"..playername, { + minetest.create_detached_inventory("creative_"..playername, { allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) if minetest.is_creative_enabled(playername) then return count @@ -203,7 +203,7 @@ local offset = {} -- string offset: local boffset = {} -- local hoch = {} local filtername = {} -local bg = {} +--local bg = {} local noffset_x_start = -0.24 local noffset_x = noffset_x_start @@ -257,7 +257,6 @@ hoch["mobs"] = "_down" hoch["matr"] = "_down" hoch["inv"] = "_down" -filtername = {} filtername["blocks"] = S("Building Blocks") filtername["deco"] = S("Decoration Blocks") filtername["redstone"] = S("Redstone") @@ -272,9 +271,9 @@ filtername["brew"] = S("Brewing") filtername["matr"] = S("Materials") filtername["inv"] = S("Survival Inventory") -local dark_bg = "crafting_creative_bg_dark.png" +--local dark_bg = "crafting_creative_bg_dark.png" -local function reset_menu_item_bg() +--[[local function reset_menu_item_bg() bg["blocks"] = dark_bg bg["deco"] = dark_bg bg["redstone"] = dark_bg @@ -289,11 +288,11 @@ local function reset_menu_item_bg() bg["matr"] = dark_bg bg["inv"] = dark_bg bg["default"] = dark_bg -end +end]] mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_size, show, page, filter) - reset_menu_item_bg() + --reset_menu_item_bg() pagenum = math.floor(pagenum) or 1 local playername = player:get_player_name() @@ -310,7 +309,6 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_siz end local pagemax = math.max(1, math.floor((inv_size-1) / (9*5) + 1)) local name = "nix" - local formspec = "" local main_list local listrings = "listring[detached:creative_"..playername..";main]".. "listring[current_player;main]".. @@ -322,7 +320,7 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_siz players[playername].page = page end end - bg[name] = "crafting_creative_bg.png" + --bg[name] = "crafting_creative_bg.png" local inv_bg = "crafting_inventory_creative.png" if name == "inv" then @@ -428,7 +426,7 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_siz caption = "label[0,1.2;"..F(minetest.colorize("#313131", filtername[name])).."]" end - formspec = "size[10,9.3]".. + 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.."]".. @@ -560,7 +558,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end -- Figure out current scroll bar from formspec - local formspec = player:get_inventory_formspec() + --local formspec = player:get_inventory_formspec() local start_i = players[name].start_i @@ -628,7 +626,7 @@ if minetest.is_creative_enabled("") then end mcl_inventory.update_inventory_formspec = function(player) - local page = nil + local page local name = player:get_player_name() @@ -639,7 +637,7 @@ if minetest.is_creative_enabled("") then end -- Figure out current scroll bar from formspec - local formspec = player:get_inventory_formspec() + --local formspec = player:get_inventory_formspec() local start_i = players[name].start_i local inv_size diff --git a/mods/HUD/mcl_inventory/init.lua b/mods/HUD/mcl_inventory/init.lua index 1744ec089..4c50a6c13 100644 --- a/mods/HUD/mcl_inventory/init.lua +++ b/mods/HUD/mcl_inventory/init.lua @@ -3,8 +3,8 @@ 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") ~= nil +--local mod_craftguide = minetest.get_modpath("mcl_craftguide") ~= nil -- 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) @@ -60,8 +60,6 @@ local function set_inventory(player, armor_change_only) inv:set_width("craft", 2) inv:set_size("craft", 4) - local player_name = player:get_player_name() - -- Show armor and player image local player_preview if minetest.settings:get_bool("3d_player_preview", true) then @@ -180,6 +178,6 @@ minetest.register_on_joinplayer(function(player) end) if minetest.is_creative_enabled("") then - dofile(minetest.get_modpath("mcl_inventory").."/creative.lua") + dofile(minetest.get_modpath(minetest.get_current_modname()).."/creative.lua") end diff --git a/mods/HUD/mcl_inventory/mod.conf b/mods/HUD/mcl_inventory/mod.conf index fa6b2c2f4..7585d9f70 100644 --- a/mods/HUD/mcl_inventory/mod.conf +++ b/mods/HUD/mcl_inventory/mod.conf @@ -1,6 +1,6 @@ name = mcl_inventory author = BlockMen description = Adds the player inventory and creative inventory. -depends = mcl_init, mcl_formspec -optional_depends = mcl_player, _mcl_autogroup, mcl_armor, mcl_brewing, mcl_potions, mcl_enchanting +depends = mcl_init, mcl_formspec, mcl_player +optional_depends = _mcl_autogroup, mcl_armor, mcl_brewing, mcl_potions, mcl_enchanting, mcl_craftguide diff --git a/mods/HUD/show_wielded_item/init.lua b/mods/HUD/show_wielded_item/init.lua index 7e2d078e3..44585de5f 100644 --- a/mods/HUD/show_wielded_item/init.lua +++ b/mods/HUD/show_wielded_item/init.lua @@ -11,7 +11,7 @@ local xp_mod = minetest.get_modpath("mcl_experience") local function set_hud(player) if not player:is_player() then return end - local player_name = player:get_player_name() + local player_name = player:get_player_name() -- Fixed offset in config file local fixed = tonumber(minetest.settings:get("show_wielded_item_y_offset")) local off @@ -52,7 +52,6 @@ end minetest.register_on_joinplayer(function(player) set_hud(player) - local name = player:get_player_name() wield[name] = player:get_wielded_item():get_name() wieldindex[name] = player:get_wield_index() diff --git a/mods/ITEMS/REDSTONE/mcl_comparators/init.lua b/mods/ITEMS/REDSTONE/mcl_comparators/init.lua index cd194b0d1..a76821543 100644 --- a/mods/ITEMS/REDSTONE/mcl_comparators/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_comparators/init.lua @@ -217,94 +217,94 @@ if minetest.get_modpath("screwdriver") then end for _, mode in pairs{"comp", "sub"} do -for _, state in pairs{mesecon.state.on, mesecon.state.off} do - local state_str = state_strs[state] - local nodename = - "mcl_comparators:comparator_"..state_strs[state].."_"..mode + for _, state in pairs{mesecon.state.on, mesecon.state.off} do + local state_str = state_strs[state] + local nodename = + "mcl_comparators:comparator_"..state_str.."_"..mode - -- Help - local longdesc, usagehelp, use_help - if state_strs[state] == "off" and mode == "comp" then - longdesc = S("Redstone comparators are multi-purpose redstone components.").."\n".. - S("They can transmit a redstone signal, detect whether a block contains any items and compare multiple signals.") + -- Help + local longdesc, usagehelp, use_help + if state_str == "off" and mode == "comp" then + longdesc = S("Redstone comparators are multi-purpose redstone components.").."\n".. + S("They can transmit a redstone signal, detect whether a block contains any items and compare multiple signals.") - usagehelp = S("A redstone comparator has 1 main input, 2 side inputs and 1 output. The output is in arrow direction, the main input is in the opposite direction. The other 2 sides are the side inputs.").."\n".. - S("The main input can powered in 2 ways: First, it can be powered directly by redstone power like any other component. Second, it is powered if, and only if a container (like a chest) is placed in front of it and the container contains at least one item.").."\n".. - S("The side inputs are only powered by normal redstone power. The redstone comparator can operate in two modes: Transmission mode and subtraction mode. It starts in transmission mode and the mode can be changed by using the block.").."\n\n".. - S("Transmission mode:\nThe front torch is unlit and lowered. The output is powered if, and only if the main input is powered. The two side inputs are ignored.").."\n".. - S("Subtraction mode:\nThe front torch is lit. The output is powered if, and only if the main input is powered and none of the side inputs is powered.") - else - use_help = false - end + usagehelp = S("A redstone comparator has 1 main input, 2 side inputs and 1 output. The output is in arrow direction, the main input is in the opposite direction. The other 2 sides are the side inputs.").."\n".. + S("The main input can powered in 2 ways: First, it can be powered directly by redstone power like any other component. Second, it is powered if, and only if a container (like a chest) is placed in front of it and the container contains at least one item.").."\n".. + S("The side inputs are only powered by normal redstone power. The redstone comparator can operate in two modes: Transmission mode and subtraction mode. It starts in transmission mode and the mode can be changed by using the block.").."\n\n".. + S("Transmission mode:\nThe front torch is unlit and lowered. The output is powered if, and only if the main input is powered. The two side inputs are ignored.").."\n".. + S("Subtraction mode:\nThe front torch is lit. The output is powered if, and only if the main input is powered and none of the side inputs is powered.") + else + use_help = false + end - local nodedef = { - description = S("Redstone Comparator"), - inventory_image = icon, - wield_image = icon, - _doc_items_create_entry = use_help, - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usagehelp, - drawtype = "nodebox", - tiles = get_tiles(state_strs[state], mode), - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, - wield_image = "mcl_comparators_off.png", - walkable = true, - selection_box = collision_box, - collision_box = collision_box, - node_box = { - type = "fixed", - fixed = node_boxes[mode], - }, - groups = groups, - paramtype = "light", - paramtype2 = "facedir", - sunlight_propagates = false, - is_ground_content = false, - drop = 'mcl_comparators:comparator_off_comp', - on_construct = update_self, - on_rightclick = - make_rightclick_handler(state_strs[state], mode), - comparator_mode = mode, - comparator_onstate = "mcl_comparators:comparator_on_"..mode, - comparator_offstate = "mcl_comparators:comparator_off_"..mode, - sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = { - receptor = { - state = state, - rules = comparator_get_output_rules, + local nodedef = { + description = S("Redstone Comparator"), + inventory_image = icon, + wield_image = icon, + _doc_items_create_entry = use_help, + _doc_items_longdesc = longdesc, + _doc_items_usagehelp = usagehelp, + drawtype = "nodebox", + tiles = get_tiles(state_str, mode), + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, + --wield_image = "mcl_comparators_off.png", + walkable = true, + selection_box = collision_box, + collision_box = collision_box, + node_box = { + type = "fixed", + fixed = node_boxes[mode], }, - effector = { - rules = comparator_get_input_rules, - action_change = update_self, - } - }, - on_rotate = on_rotate, - } + groups = groups, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = false, + is_ground_content = false, + drop = 'mcl_comparators:comparator_off_comp', + on_construct = update_self, + on_rightclick = + make_rightclick_handler(state_str, mode), + comparator_mode = mode, + comparator_onstate = "mcl_comparators:comparator_on_"..mode, + comparator_offstate = "mcl_comparators:comparator_off_"..mode, + sounds = mcl_sounds.node_sound_stone_defaults(), + mesecons = { + receptor = { + state = state, + rules = comparator_get_output_rules, + }, + effector = { + rules = comparator_get_input_rules, + action_change = update_self, + } + }, + on_rotate = on_rotate, + } - if mode == "comp" and state == mesecon.state.off then - -- This is the prototype - nodedef._doc_items_create_entry = true - else - nodedef.groups = table.copy(nodedef.groups) - nodedef.groups.not_in_creative_inventory = 1 - local extra_desc = {} - if mode == "sub" or state == mesecon.state.on then - nodedef.inventory_image = nil + if mode == "comp" and state == mesecon.state.off then + -- This is the prototype + nodedef._doc_items_create_entry = true + else + nodedef.groups = table.copy(nodedef.groups) + nodedef.groups.not_in_creative_inventory = 1 + --local extra_desc = {} + if mode == "sub" or state == mesecon.state.on then + nodedef.inventory_image = nil + end + local desc = nodedef.description + if mode ~= "sub" and state == mesecon.state.on then + desc = S("Redstone Comparator (Powered)") + elseif mode == "sub" and state ~= mesecon.state.on then + desc = S("Redstone Comparator (Subtract)") + elseif mode == "sub" and state == mesecon.state.on then + desc = S("Redstone Comparator (Subtract, Powered)") + end + nodedef.description = desc end - local desc = nodedef.description - if mode ~= "sub" and state == mesecon.state.on then - desc = S("Redstone Comparator (Powered)") - elseif mode == "sub" and state ~= mesecon.state.on then - desc = S("Redstone Comparator (Subtract)") - elseif mode == "sub" and state == mesecon.state.on then - desc = S("Redstone Comparator (Subtract, Powered)") - end - nodedef.description = desc + + minetest.register_node(nodename, nodedef) + mcl_wip.register_wip_item(nodename) end - - minetest.register_node(nodename, nodedef) - mcl_wip.register_wip_item(nodename) -end end -- Register recipies @@ -351,9 +351,9 @@ minetest.register_abm({ -- Add entry aliases for the Help if minetest.get_modpath("doc") then doc.add_entry_alias("nodes", "mcl_comparators:comparator_off_comp", - "nodes", "mcl_comparators:comparator_off_sub") + "nodes", "mcl_comparators:comparator_off_sub") doc.add_entry_alias("nodes", "mcl_comparators:comparator_off_comp", - "nodes", "mcl_comparators:comparator_on_comp") + "nodes", "mcl_comparators:comparator_on_comp") doc.add_entry_alias("nodes", "mcl_comparators:comparator_off_comp", - "nodes", "mcl_comparators:comparator_on_sub") + "nodes", "mcl_comparators:comparator_on_sub") end diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua index 02ed70aed..73bc1f0da 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua @@ -96,125 +96,127 @@ local dispenserdef = { end, _mcl_blast_resistance = 3.5, _mcl_hardness = 3.5, - mesecons = {effector = { - -- Dispense random item when triggered - action_on = function (pos, node) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - local droppos, dropdir - if node.name == "mcl_dispensers:dispenser" then - dropdir = vector.multiply(minetest.facedir_to_dir(node.param2), -1) - droppos = vector.add(pos, dropdir) - elseif node.name == "mcl_dispensers:dispenser_up" then - dropdir = {x=0, y=1, z=0} - droppos = {x=pos.x, y=pos.y+1, z=pos.z} - elseif node.name == "mcl_dispensers:dispenser_down" then - dropdir = {x=0, y=-1, z=0} - droppos = {x=pos.x, y=pos.y-1, z=pos.z} - end - local dropnode = minetest.get_node(droppos) - local dropnodedef = minetest.registered_nodes[dropnode.name] - local stacks = {} - for i=1,inv:get_size("main") do - local stack = inv:get_stack("main", i) - if not stack:is_empty() then - table.insert(stacks, {stack = stack, stackpos = i}) + mesecons = { + effector = { + -- Dispense random item when triggered + action_on = function (pos, node) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local droppos, dropdir + if node.name == "mcl_dispensers:dispenser" then + dropdir = vector.multiply(minetest.facedir_to_dir(node.param2), -1) + droppos = vector.add(pos, dropdir) + elseif node.name == "mcl_dispensers:dispenser_up" then + dropdir = {x=0, y=1, z=0} + droppos = {x=pos.x, y=pos.y+1, z=pos.z} + elseif node.name == "mcl_dispensers:dispenser_down" then + dropdir = {x=0, y=-1, z=0} + droppos = {x=pos.x, y=pos.y-1, z=pos.z} end - end - if #stacks >= 1 then - local r = math.random(1, #stacks) - local stack = stacks[r].stack - local dropitem = ItemStack(stack) - dropitem:set_count(1) - local stack_id = stacks[r].stackpos - local stackdef = stack:get_definition() - local iname = stack:get_name() - local igroups = minetest.registered_items[iname].groups + local dropnode = minetest.get_node(droppos) + local dropnodedef = minetest.registered_nodes[dropnode.name] + local stacks = {} + for i=1,inv:get_size("main") do + local stack = inv:get_stack("main", i) + if not stack:is_empty() then + table.insert(stacks, {stack = stack, stackpos = i}) + end + end + if #stacks >= 1 then + local r = math.random(1, #stacks) + local stack = stacks[r].stack + local dropitem = ItemStack(stack) + dropitem:set_count(1) + local stack_id = stacks[r].stackpos + local stackdef = stack:get_definition() + local iname = stack:get_name() + local igroups = minetest.registered_items[iname].groups - --[===[ Dispense item ]===] + --[===[ Dispense item ]===] - -- Hardcoded dispensions -- + -- Hardcoded dispensions -- - -- Armor, mob heads and pumpkins - if igroups.armor then - local droppos_below = {x = droppos.x, y = droppos.y - 1, z = droppos.z} + -- Armor, mob heads and pumpkins + if igroups.armor then + local droppos_below = {x = droppos.x, y = droppos.y - 1, z = droppos.z} - for _, objs in ipairs({minetest.get_objects_inside_radius(droppos, 1), minetest.get_objects_inside_radius(droppos_below, 1)}) do - for _, obj in ipairs(objs) do - stack = mcl_armor.equip(stack, obj) + for _, objs in ipairs({minetest.get_objects_inside_radius(droppos, 1), minetest.get_objects_inside_radius(droppos_below, 1)}) do + for _, obj in ipairs(objs) do + stack = mcl_armor.equip(stack, obj) + if stack:is_empty() then + break + end + end if stack:is_empty() then break end end - if stack:is_empty() then - break - end - end - -- Place head or pumpkin as node, if equipping it as armor has failed - if not stack:is_empty() then - if igroups.head or iname == "mcl_farming:pumpkin_face" then - if dropnodedef.buildable_to then - minetest.set_node(droppos, {name = iname, param2 = node.param2}) - stack:take_item() + -- Place head or pumpkin as node, if equipping it as armor has failed + if not stack:is_empty() then + if igroups.head or iname == "mcl_farming:pumpkin_face" then + if dropnodedef.buildable_to then + minetest.set_node(droppos, {name = iname, param2 = node.param2}) + stack:take_item() + end end end - end - inv:set_stack("main", stack_id, stack) - -- Spawn Egg - elseif igroups.spawn_egg then - -- Spawn mob - if not dropnodedef.walkable then - pointed_thing = { above = droppos, under = { x=droppos.x, y=droppos.y-1, z=droppos.z } } - minetest.add_entity(droppos, stack:get_name()) - - stack:take_item() inv:set_stack("main", stack_id, stack) - end + -- Spawn Egg + elseif igroups.spawn_egg then + -- Spawn mob + if not dropnodedef.walkable then + --pointed_thing = { above = droppos, under = { x=droppos.x, y=droppos.y-1, z=droppos.z } } + minetest.add_entity(droppos, stack:get_name()) - -- Generalized dispension - elseif (not dropnodedef.walkable or stackdef._dispense_into_walkable) then - --[[ _on_dispense(stack, pos, droppos, dropnode, dropdir) - * stack: Itemstack which is dispense - * pos: Position of dispenser - * droppos: Position to which to dispense item - * dropnode: Node of droppos - * dropdir: Drop direction - - _dispense_into_walkable: If true, can dispense into walkable nodes - ]] - if stackdef._on_dispense then - -- Item-specific dispension (if defined) - local od_ret = stackdef._on_dispense(dropitem, pos, droppos, dropnode, dropdir) - if od_ret then - local newcount = stack:get_count() - 1 - stack:set_count(newcount) - inv:set_stack("main", stack_id, stack) - if newcount == 0 then - inv:set_stack("main", stack_id, od_ret) - elseif inv:room_for_item("main", od_ret) then - inv:add_item("main", od_ret) - else - minetest.add_item(droppos, dropitem) - end - else stack:take_item() inv:set_stack("main", stack_id, stack) end - else - -- Drop item otherwise - minetest.add_item(droppos, dropitem) - stack:take_item() - inv:set_stack("main", stack_id, stack) + + -- Generalized dispension + elseif (not dropnodedef.walkable or stackdef._dispense_into_walkable) then + --[[ _on_dispense(stack, pos, droppos, dropnode, dropdir) + * stack: Itemstack which is dispense + * pos: Position of dispenser + * droppos: Position to which to dispense item + * dropnode: Node of droppos + * dropdir: Drop direction + + _dispense_into_walkable: If true, can dispense into walkable nodes + ]] + if stackdef._on_dispense then + -- Item-specific dispension (if defined) + local od_ret = stackdef._on_dispense(dropitem, pos, droppos, dropnode, dropdir) + if od_ret then + local newcount = stack:get_count() - 1 + stack:set_count(newcount) + inv:set_stack("main", stack_id, stack) + if newcount == 0 then + inv:set_stack("main", stack_id, od_ret) + elseif inv:room_for_item("main", od_ret) then + inv:add_item("main", od_ret) + else + minetest.add_item(droppos, dropitem) + end + else + stack:take_item() + inv:set_stack("main", stack_id, stack) + end + else + -- Drop item otherwise + minetest.add_item(droppos, dropitem) + stack:take_item() + inv:set_stack("main", stack_id, stack) + end end + + end - - - end - end, - rules = mesecon.rules.alldirs, - }}, + end, + rules = mesecon.rules.alldirs, + }, + }, on_rotate = on_rotate, } diff --git a/mods/ITEMS/REDSTONE/mcl_observers/init.lua b/mods/ITEMS/REDSTONE/mcl_observers/init.lua index 932f4f643..8f7f6c262 100644 --- a/mods/ITEMS/REDSTONE/mcl_observers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_observers/init.lua @@ -11,7 +11,7 @@ local realtime = true local rules_flat = { { x = 0, y = 0, z = -1, spread = true }, } -local get_rules_flat = function(node) +local function get_rules_flat(node) local rules = rules_flat for i=1, node.param2 do rules = mesecon.rotate_rules_left(rules) @@ -46,7 +46,7 @@ end -- and update the observer state if needed. -- TODO: Also scan metadata changes. -- TODO: Ignore some node changes. -local observer_scan = function(pos, initialize) +local function observer_scan(pos, initialize) local node = minetest.get_node(pos) local front if node.name == "mcl_observers:observer_up_off" or node.name == "mcl_observers:observer_up_on" then @@ -87,14 +87,14 @@ local observer_scan = function(pos, initialize) end -- Vertical orientation (CURRENTLY DISABLED) -local observer_orientate = function(pos, placer) +local function observer_orientate(pos, placer) -- Not placed by player if not placer then return end -- Placer pitch in degrees local pitch = placer:get_look_vertical() * (180 / math.pi) - local node = minetest.get_node(pos) + --local node = minetest.get_node(pos) if pitch > 55 then -- player looking upwards -- Observer looking downwards minetest.set_node(pos, {name="mcl_observers:observer_down_off"}) @@ -104,162 +104,167 @@ local observer_orientate = function(pos, placer) end end -mesecon.register_node("mcl_observers:observer", -{ - is_ground_content = false, - sounds = mcl_sounds.node_sound_stone_defaults(), - paramtype2 = "facedir", - on_rotate = false, - _mcl_blast_resistance = 3.5, - _mcl_hardness = 3.5, -}, -{ - description = S("Observer"), - _tt_help = S("Emits redstone pulse when block in front changes"), - _doc_items_longdesc = S("An observer is a redstone component which observes the block in front of it and sends a very short redstone pulse whenever this block changes."), - _doc_items_usagehelp = S("Place the observer directly in front of the block you want to observe with the “face” looking at the block. The arrow points to the side of the output, which is at the opposite side of the “face”. You can place your redstone dust or any other component here."), +mesecon.register_node("mcl_observers:observer", { + is_ground_content = false, + sounds = mcl_sounds.node_sound_stone_defaults(), + paramtype2 = "facedir", + on_rotate = false, + _mcl_blast_resistance = 3.5, + _mcl_hardness = 3.5, + }, { + description = S("Observer"), + _tt_help = S("Emits redstone pulse when block in front changes"), + _doc_items_longdesc = S("An observer is a redstone component which observes the block in front of it and sends a very short redstone pulse whenever this block changes."), + _doc_items_usagehelp = S("Place the observer directly in front of the block you want to observe with the “face” looking at the block. The arrow points to the side of the output, which is at the opposite side of the “face”. You can place your redstone dust or any other component here."), - groups = {pickaxey=1, material_stone=1, not_opaque=1, }, - tiles = { - "mcl_observers_observer_top.png^[transformR180", "default_furnace_bottom.png", - "mcl_observers_observer_side.png", "mcl_observers_observer_side.png", - "mcl_observers_observer_front.png", "mcl_observers_observer_back.png", - }, - mesecons = { receptor = { - state = mesecon.state.off, - rules = get_rules_flat, - }}, - on_construct = function(pos) - if not realtime then - observer_scan(pos, true) - end - end, - after_place_node = observer_orientate, -}, -{ - _doc_items_create_entry = false, - groups = {pickaxey=1, material_stone=1, not_opaque=1, not_in_creative_inventory=1 }, - tiles = { - "mcl_observers_observer_top.png^[transformR180", "default_furnace_bottom.png", - "mcl_observers_observer_side.png", "mcl_observers_observer_side.png", - "mcl_observers_observer_front.png", "mcl_observers_observer_back_lit.png", - }, - mesecons = { receptor = { - state = mesecon.state.on, - rules = get_rules_flat, - }}, + groups = {pickaxey=1, material_stone=1, not_opaque=1, }, + tiles = { + "mcl_observers_observer_top.png^[transformR180", "default_furnace_bottom.png", + "mcl_observers_observer_side.png", "mcl_observers_observer_side.png", + "mcl_observers_observer_front.png", "mcl_observers_observer_back.png", + }, + mesecons = { + receptor = { + state = mesecon.state.off, + rules = get_rules_flat, + }, + }, + on_construct = function(pos) + if not realtime then + observer_scan(pos, true) + end + end, + after_place_node = observer_orientate, + }, { + _doc_items_create_entry = false, + groups = {pickaxey=1, material_stone=1, not_opaque=1, not_in_creative_inventory=1 }, + tiles = { + "mcl_observers_observer_top.png^[transformR180", "default_furnace_bottom.png", + "mcl_observers_observer_side.png", "mcl_observers_observer_side.png", + "mcl_observers_observer_front.png", "mcl_observers_observer_back_lit.png", + }, + mesecons = { + receptor = { + state = mesecon.state.on, + rules = get_rules_flat, + } + }, - -- VERY quickly disable observer after construction - on_construct = function(pos) - local timer = minetest.get_node_timer(pos) - timer:start(mcl_vars.redstone_tick) - end, - on_timer = function(pos, elapsed) - local node = minetest.get_node(pos) - minetest.set_node(pos, {name = "mcl_observers:observer_off", param2 = node.param2}) - mesecon.receptor_off(pos, get_rules_flat(node)) - end, -} + -- VERY quickly disable observer after construction + on_construct = function(pos) + local timer = minetest.get_node_timer(pos) + timer:start(mcl_vars.redstone_tick) + end, + on_timer = function(pos, elapsed) + local node = minetest.get_node(pos) + minetest.set_node(pos, {name = "mcl_observers:observer_off", param2 = node.param2}) + mesecon.receptor_off(pos, get_rules_flat(node)) + end, + } ) -mesecon.register_node("mcl_observers:observer_down", -{ - is_ground_content = false, - sounds = mcl_sounds.node_sound_stone_defaults(), - groups = {pickaxey=1, material_stone=1, not_opaque=1, not_in_creative_inventory=1 }, - on_rotate = false, - _mcl_blast_resistance = 3.5, - _mcl_hardness = 3.5, - drop = "mcl_observers:observer_off", -}, -{ - tiles = { - "mcl_observers_observer_back.png", "mcl_observers_observer_front.png", - "mcl_observers_observer_side.png^[transformR90", "mcl_observers_observer_side.png^[transformR90", - "mcl_observers_observer_top.png", "mcl_observers_observer_top.png", - }, - mesecons = { receptor = { - state = mesecon.state.off, - rules = rules_down, - }}, - on_construct = function(pos) - if not realtime then - observer_scan(pos, true) - end - end, -}, -{ - _doc_items_create_entry = false, - tiles = { - "mcl_observers_observer_back_lit.png", "mcl_observers_observer_front.png", - "mcl_observers_observer_side.png^[transformR90", "mcl_observers_observer_side.png^[transformR90", - "mcl_observers_observer_top.png", "mcl_observers_observer_top.png", - }, - mesecons = { receptor = { - state = mesecon.state.on, - rules = rules_down, - }}, +mesecon.register_node("mcl_observers:observer_down", { + is_ground_content = false, + sounds = mcl_sounds.node_sound_stone_defaults(), + groups = {pickaxey=1, material_stone=1, not_opaque=1, not_in_creative_inventory=1 }, + on_rotate = false, + _mcl_blast_resistance = 3.5, + _mcl_hardness = 3.5, + drop = "mcl_observers:observer_off", + }, { + tiles = { + "mcl_observers_observer_back.png", "mcl_observers_observer_front.png", + "mcl_observers_observer_side.png^[transformR90", "mcl_observers_observer_side.png^[transformR90", + "mcl_observers_observer_top.png", "mcl_observers_observer_top.png", + }, + mesecons = { + receptor = { + state = mesecon.state.off, + rules = rules_down, + }, + }, + on_construct = function(pos) + if not realtime then + observer_scan(pos, true) + end + end, + }, { + _doc_items_create_entry = false, + tiles = { + "mcl_observers_observer_back_lit.png", "mcl_observers_observer_front.png", + "mcl_observers_observer_side.png^[transformR90", "mcl_observers_observer_side.png^[transformR90", + "mcl_observers_observer_top.png", "mcl_observers_observer_top.png", + }, + mesecons = { + receptor = { + state = mesecon.state.on, + rules = rules_down, + }, + }, - -- VERY quickly disable observer after construction - on_construct = function(pos) - local timer = minetest.get_node_timer(pos) - timer:start(mcl_vars.redstone_tick) - end, - on_timer = function(pos, elapsed) - local node = minetest.get_node(pos) - minetest.set_node(pos, {name = "mcl_observers:observer_down_off", param2 = node.param2}) - mesecon.receptor_off(pos, rules_down) - end, -}) + -- VERY quickly disable observer after construction + on_construct = function(pos) + local timer = minetest.get_node_timer(pos) + timer:start(mcl_vars.redstone_tick) + end, + on_timer = function(pos, elapsed) + local node = minetest.get_node(pos) + minetest.set_node(pos, {name = "mcl_observers:observer_down_off", param2 = node.param2}) + mesecon.receptor_off(pos, rules_down) + end, + } +) -mesecon.register_node("mcl_observers:observer_up", -{ - is_ground_content = false, - sounds = mcl_sounds.node_sound_stone_defaults(), - groups = {pickaxey=1, material_stone=1, not_opaque=1, not_in_creative_inventory=1 }, - on_rotate = false, - _mcl_blast_resistance = 3.5, - _mcl_hardness = 3.5, - drop = "mcl_observers:observer_off", -}, -{ - tiles = { - "mcl_observers_observer_front.png", "mcl_observers_observer_back.png", - "mcl_observers_observer_side.png^[transformR270", "mcl_observers_observer_side.png^[transformR270", - "mcl_observers_observer_top.png^[transformR180", "mcl_observers_observer_top.png^[transformR180", - }, - mesecons = { receptor = { - state = mesecon.state.off, - rules = rules_up, - }}, - on_construct = function(pos) - if not realtime then - observer_scan(pos, true) - end - end, -}, -{ - _doc_items_create_entry = false, - tiles = { - "mcl_observers_observer_front.png", "mcl_observers_observer_back_lit.png", - "mcl_observers_observer_side.png^[transformR270", "mcl_observers_observer_side.png^[transformR270", - "mcl_observers_observer_top.png^[transformR180", "mcl_observers_observer_top.png^[transformR180", - }, - mesecons = { receptor = { - state = mesecon.state.on, - rules = rules_up, - }}, +mesecon.register_node("mcl_observers:observer_up", { + is_ground_content = false, + sounds = mcl_sounds.node_sound_stone_defaults(), + groups = {pickaxey=1, material_stone=1, not_opaque=1, not_in_creative_inventory=1 }, + on_rotate = false, + _mcl_blast_resistance = 3.5, + _mcl_hardness = 3.5, + drop = "mcl_observers:observer_off", + }, { + tiles = { + "mcl_observers_observer_front.png", "mcl_observers_observer_back.png", + "mcl_observers_observer_side.png^[transformR270", "mcl_observers_observer_side.png^[transformR270", + "mcl_observers_observer_top.png^[transformR180", "mcl_observers_observer_top.png^[transformR180", + }, + mesecons = { + receptor = { + state = mesecon.state.off, + rules = rules_up, + }, + }, + on_construct = function(pos) + if not realtime then + observer_scan(pos, true) + end + end, + }, { + _doc_items_create_entry = false, + tiles = { + "mcl_observers_observer_front.png", "mcl_observers_observer_back_lit.png", + "mcl_observers_observer_side.png^[transformR270", "mcl_observers_observer_side.png^[transformR270", + "mcl_observers_observer_top.png^[transformR180", "mcl_observers_observer_top.png^[transformR180", + }, + mesecons = { + receptor = { + state = mesecon.state.on, + rules = rules_up, + }, + }, - -- VERY quickly disable observer after construction - on_construct = function(pos) - local timer = minetest.get_node_timer(pos) - timer:start(mcl_vars.redstone_tick) - end, - on_timer = function(pos, elapsed) - minetest.set_node(pos, {name = "mcl_observers:observer_up_off"}) - mesecon.receptor_off(pos, rules_up) - end, -}) + -- VERY quickly disable observer after construction + on_construct = function(pos) + local timer = minetest.get_node_timer(pos) + timer:start(mcl_vars.redstone_tick) + end, + on_timer = function(pos, elapsed) + minetest.set_node(pos, {name = "mcl_observers:observer_up_off"}) + mesecon.receptor_off(pos, rules_up) + end, + } +) minetest.register_craft({ output = "mcl_observers:observer_off", @@ -267,7 +272,7 @@ minetest.register_craft({ { "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" }, { "mcl_nether:quartz", "mesecons:redstone", "mesecons:redstone" }, { "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" }, - } + }, }) minetest.register_craft({ output = "mcl_observers:observer_off", @@ -275,7 +280,7 @@ minetest.register_craft({ { "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" }, { "mesecons:redstone", "mesecons:redstone", "mcl_nether:quartz" }, { "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" }, - } + }, }) if realtime then @@ -454,7 +459,7 @@ minetest.register_lbm({ "mcl_observers:observer_down_on", "mcl_observers:observer_up_on", }, - run_at_every_load = true, + run_at_every_load = true, action = function(pos) minetest.after(1, mcl_observers.observer_activate, {x=pos.x, y=pos.y, z=pos.z}) end, diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index f4ed9df4e..a5bcb80e8 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -329,7 +329,7 @@ function mesecon.get_conductor_on(node_off, rulename) return conductor.states[tonumber(binstate,2)+1] end end - return offstate + return conductor.offstate end function mesecon.get_conductor_off(node_on, rulename) @@ -345,7 +345,7 @@ function mesecon.get_conductor_off(node_on, rulename) return conductor.states[tonumber(binstate,2)+1] end end - return onstate + return conductor.onstate end function mesecon.conductor_get_rules(node) @@ -391,9 +391,7 @@ function mesecon.turnon(pos, link) local f = table.remove(frontiers, 1) local node = get_node_force(f.pos) - if not node then - -- Area does not exist; do nothing - elseif mesecon.is_conductor_off(node, f.link) then + if node and mesecon.is_conductor_off(node, f.link) then local rules = mesecon.conductor_get_rules(node) -- Call turnon on neighbors @@ -453,9 +451,7 @@ function mesecon.turnoff(pos, link) local f = table.remove(frontiers, 1) local node = get_node_force(f.pos) - if not node then - -- No-op - elseif mesecon.is_conductor_on(node, f.link) then + if node and mesecon.is_conductor_on(node, f.link) then local rules = mesecon.conductor_get_rules(node) for _, r in pairs(mesecon.rule2meta(f.link, rules)) do local np = vector.add(f.pos, r) diff --git a/mods/ITEMS/REDSTONE/mesecons/presets.lua b/mods/ITEMS/REDSTONE/mesecons/presets.lua index f624c52fe..d9d8418d8 100644 --- a/mods/ITEMS/REDSTONE/mesecons/presets.lua +++ b/mods/ITEMS/REDSTONE/mesecons/presets.lua @@ -96,12 +96,12 @@ local function rules_from_dir(ruleset, dir) if dir.z == -1 then return ruleset.zn end end -mesecon.rules.buttonlike_get = function(node) +function mesecon.rules.buttonlike_get(node) local dir = minetest.facedir_to_dir(node.param2) return rules_from_dir(rules_buttonlike, dir) end -mesecon.rules.wallmounted_get = function(node) +function mesecon.rules.wallmounted_get(node) local dir = minetest.wallmounted_to_dir(node.param2) return rules_from_dir(rules_wallmounted, dir) end diff --git a/mods/ITEMS/REDSTONE/mesecons/services.lua b/mods/ITEMS/REDSTONE/mesecons/services.lua index 9addda8bd..7d1fce2d8 100644 --- a/mods/ITEMS/REDSTONE/mesecons/services.lua +++ b/mods/ITEMS/REDSTONE/mesecons/services.lua @@ -1,6 +1,6 @@ -- Dig and place services -mesecon.on_placenode = function(pos, node) +function mesecon.on_placenode(pos, node) mesecon.execute_autoconnect_hooks_now(pos, node) -- Receptors: Send on signal when active @@ -70,14 +70,14 @@ mesecon.on_placenode = function(pos, node) end end -mesecon.on_dignode = function(pos, node) +function mesecon.on_dignode(pos, node) if mesecon.is_conductor_on(node) then mesecon.receptor_off(pos, mesecon.conductor_get_rules(node)) elseif mesecon.is_receptor_on(node.name) then mesecon.receptor_off(pos, mesecon.receptor_get_rules(node)) end if minetest.get_item_group(node.name, "opaque") == 1 then - local sources = mesecon.is_powered(pos) + --local sources = mesecon.is_powered(pos) local neighbors = mesecon.mcl_get_neighbors(pos) for n=1, #neighbors do local npos = neighbors[n].pos @@ -95,7 +95,7 @@ mesecon.on_dignode = function(pos, node) mesecon.execute_autoconnect_hooks_queue(pos, node) end -mesecon.on_blastnode = function(pos, node) +function mesecon.on_blastnode(pos, node) local node = minetest.get_node(pos) minetest.remove_node(pos) mesecon.on_dignode(pos, node) diff --git a/mods/ITEMS/REDSTONE/mesecons_button/init.lua b/mods/ITEMS/REDSTONE/mesecons_button/init.lua index 377a24c00..a8c671004 100644 --- a/mods/ITEMS/REDSTONE/mesecons_button/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_button/init.lua @@ -21,7 +21,7 @@ local boxes_on = { } -- Push the button -mesecon.push_button = function(pos, node) +function mesecon.push_button(pos, node) -- No-op if button is already pushed if mesecon.is_receptor_on(node) then return diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua index 1928f809c..9c0914efb 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua @@ -72,7 +72,7 @@ end local function check_commands(commands, player_name) for _, command in pairs(commands:split("\n")) do local pos = command:find(" ") - local cmd, param = command, "" + local cmd = command if pos then cmd = command:sub(1, pos - 1) end @@ -103,10 +103,10 @@ local function commandblock_action_on(pos, node) if node.name ~= "mesecons_commandblock:commandblock_off" then return end - + local meta = minetest.get_meta(pos) local commander = meta:get_string("commander") - + if not command_blocks_activated then --minetest.chat_send_player(commander, msg_not_activated) return diff --git a/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua b/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua index caf5e9652..0a330ef2c 100644 --- a/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua @@ -4,7 +4,7 @@ local DELAYS = { 0.1, 0.2, 0.3, 0.4 } local DEFAULT_DELAY = DELAYS[1] -- Function that get the input/output rules of the delayer -local delayer_get_output_rules = function(node) +local function delayer_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) @@ -12,7 +12,7 @@ local delayer_get_output_rules = function(node) return rules end -local delayer_get_input_rules = function(node) +local function delayer_get_input_rules(node) local rules = {{x = 1, y = 0, z = 0}} for i = 0, node.param2 do rules = mesecon.rotate_rules_left(rules) @@ -22,7 +22,7 @@ end -- Return the sides of a delayer. -- Those are used to toggle the lock state. -local delayer_get_sides = function(node) +local function delayer_get_sides(node) local rules = { {x = 0, y = 0, z = -1}, {x = 0, y = 0, z = 1}, @@ -35,7 +35,7 @@ end -- Make the repeater at pos try to lock any repeater it faces. -- Returns true if a repeater was locked. -local check_lock_repeater = function(pos, node) +local function check_lock_repeater(pos, node) -- Check the repeater at pos and look if it faces -- a repeater placed sideways. -- If yes, lock the second repeater. @@ -67,7 +67,7 @@ end -- Make the repeater at pos try to unlock any repeater it faces. -- Returns true if a repeater was unlocked. -local check_unlock_repeater = function(pos, node) +local function check_unlock_repeater(pos, node) -- Check the repeater at pos and look if it faces -- a repeater placed sideways. -- If yes, also check if the second repeater doesn't receive @@ -119,21 +119,19 @@ local check_unlock_repeater = function(pos, node) end -- Functions that are called after the delay time -local delayer_activate = function(pos, node) +local function delayer_activate(pos, node) local def = minetest.registered_nodes[node.name] local time = def.delayer_time minetest.set_node(pos, {name=def.delayer_onstate, param2=node.param2}) mesecon.queue:add_action(pos, "receptor_on", {delayer_get_output_rules(node)}, time, nil) - check_lock_repeater(pos, node) end -local delayer_deactivate = function(pos, node) +local function delayer_deactivate(pos, node) local def = minetest.registered_nodes[node.name] local time = def.delayer_time minetest.set_node(pos, {name=def.delayer_offstate, param2=node.param2}) mesecon.queue:add_action(pos, "receptor_off", {delayer_get_output_rules(node)}, time, nil) - check_unlock_repeater(pos, node) end @@ -145,236 +143,230 @@ end -- Register the 2 (states) x 4 (delay times) delayers for i = 1, 4 do -local groups = {} -if i == 1 then - groups = {dig_immediate=3,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,attached_node=1,redstone_repeater=i} -else - groups = {dig_immediate=3,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,attached_node=1,redstone_repeater=i,not_in_creative_inventory=1} -end + local groups + if i == 1 then + groups = {dig_immediate=3,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,attached_node=1,redstone_repeater=i} + else + groups = {dig_immediate=3,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,attached_node=1,redstone_repeater=i,not_in_creative_inventory=1} + end -local delaytime = DELAYS[i] + local delaytime = DELAYS[i] -local boxes -if i == 1 then -boxes = { - { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab - { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch - { -1/16, -6/16, 0/16, 1/16, -1/16, 2/16}, -- moved torch -} -elseif i == 2 then -boxes = { - { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab - { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch - { -1/16, -6/16, -2/16, 1/16, -1/16, 0/16}, -- moved torch -} -elseif i == 3 then -boxes = { - { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab - { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch - { -1/16, -6/16, -4/16, 1/16, -1/16, -2/16}, -- moved torch -} -elseif i == 4 then -boxes = { - { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab - { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch - { -1/16, -6/16, -6/16, 1/16, -1/16, -4/16}, -- moved torch -} -end + local boxes + if i == 1 then + boxes = { + { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab + { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch + { -1/16, -6/16, 0/16, 1/16, -1/16, 2/16}, -- moved torch + } + elseif i == 2 then + boxes = { + { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab + { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch + { -1/16, -6/16, -2/16, 1/16, -1/16, 0/16}, -- moved torch + } + elseif i == 3 then + boxes = { + { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab + { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch + { -1/16, -6/16, -4/16, 1/16, -1/16, -2/16}, -- moved torch + } + elseif i == 4 then + boxes = { + { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab + { -1/16, -6/16, 6/16, 1/16, -1/16, 4/16}, -- still torch + { -1/16, -6/16, -6/16, 1/16, -1/16, -4/16}, -- moved torch + } + end -local help, tt, longdesc, usagehelp, icon, on_construct -if i == 1 then - help = true - tt = S("Transmits redstone power only in one direction").."\n".. - S("Delays signal").."\n".. - S("Output locks when getting active redstone repeater signal from the side") - longdesc = S("Redstone repeaters are versatile redstone components with multiple purposes: 1. They only allow signals to travel in one direction. 2. They delay the signal. 3. Optionally, they can lock their output in one state.") - usagehelp = S("To power a redstone repeater, send a signal in “arrow” direction (the input). The signal goes out on the opposite side (the output) with a delay. To change the delay, use the redstone repeater. The delay is between 0.1 and 0.4 seconds long and can be changed in steps of 0.1 seconds. It is indicated by the position of the moving redstone torch.").."\n".. - S("To lock a repeater, send a signal from an adjacent repeater into one of its sides. While locked, the moving redstone torch disappears, the output doesn't change and the input signal is ignored.") - icon = "mesecons_delayer_item.png" - - -- Check sides of constructed repeater and lock it, if required - on_construct = function(pos) - local node = minetest.get_node(pos) - local sides = delayer_get_sides(node) - for s=1, #sides do - local spos = vector.add(pos, sides[s]) - local snode = minetest.get_node(spos) - -- Is there a powered repeater at one of our sides? - local g = minetest.get_item_group(snode.name, "redstone_repeater") - if g ~= 0 and mesecon.is_receptor_on(snode.name) then - -- The other repeater must also face towards the constructed node - local sface = delayer_get_output_rules(snode)[1] - local sface_pos = vector.add(spos, sface) - if vector.equals(sface_pos, pos) then - -- Repeater is facing towards us! Now we just need to lock the costructed node - if mesecon.is_powered(pos, delayer_get_input_rules(node)[1]) ~= false then - local newnode = {name="mesecons_delayer:delayer_on_locked", param2 = node.param2} - minetest.set_node(pos, newnode) - mesecon.queue:add_action(pos, "receptor_on", {delayer_get_output_rules(newnode)}, DEFAULT_DELAY, nil) - else - minetest.set_node(pos, {name="mesecons_delayer:delayer_off_locked", param2 = node.param2}) + local help, tt, longdesc, usagehelp, icon, on_construct + if i == 1 then + help = true + tt = S("Transmits redstone power only in one direction").."\n".. + S("Delays signal").."\n".. + S("Output locks when getting active redstone repeater signal from the side") + longdesc = S("Redstone repeaters are versatile redstone components with multiple purposes: 1. They only allow signals to travel in one direction. 2. They delay the signal. 3. Optionally, they can lock their output in one state.") + usagehelp = S("To power a redstone repeater, send a signal in “arrow” direction (the input). The signal goes out on the opposite side (the output) with a delay. To change the delay, use the redstone repeater. The delay is between 0.1 and 0.4 seconds long and can be changed in steps of 0.1 seconds. It is indicated by the position of the moving redstone torch.").."\n".. + S("To lock a repeater, send a signal from an adjacent repeater into one of its sides. While locked, the moving redstone torch disappears, the output doesn't change and the input signal is ignored.") + icon = "mesecons_delayer_item.png" + -- Check sides of constructed repeater and lock it, if required + on_construct = function(pos) + local node = minetest.get_node(pos) + local sides = delayer_get_sides(node) + for s=1, #sides do + local spos = vector.add(pos, sides[s]) + local snode = minetest.get_node(spos) + -- Is there a powered repeater at one of our sides? + local g = minetest.get_item_group(snode.name, "redstone_repeater") + if g ~= 0 and mesecon.is_receptor_on(snode.name) then + -- The other repeater must also face towards the constructed node + local sface = delayer_get_output_rules(snode)[1] + local sface_pos = vector.add(spos, sface) + if vector.equals(sface_pos, pos) then + -- Repeater is facing towards us! Now we just need to lock the costructed node + if mesecon.is_powered(pos, delayer_get_input_rules(node)[1]) ~= false then + local newnode = {name="mesecons_delayer:delayer_on_locked", param2 = node.param2} + minetest.set_node(pos, newnode) + mesecon.queue:add_action(pos, "receptor_on", {delayer_get_output_rules(newnode)}, DEFAULT_DELAY, nil) + else + minetest.set_node(pos, {name="mesecons_delayer:delayer_off_locked", param2 = node.param2}) + end + break end - break end end end + else + help = false end -else - help = false -end -local desc_off -if i == 1 then - desc_off = S("Redstone Repeater") -else - desc_off = S("Redstone Repeater (Delay @1)", i) -end + local desc_off + if i == 1 then + desc_off = S("Redstone Repeater") + else + desc_off = S("Redstone Repeater (Delay @1)", i) + end -minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), { - description = desc_off, - inventory_image = icon, - wield_image = icon, - _tt_help = tt, - _doc_items_create_entry = help, - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usagehelp, - drawtype = "nodebox", - tiles = { - "mesecons_delayer_off.png", - "mcl_stairs_stone_slab_top.png", - "mesecons_delayer_sides_off.png", - "mesecons_delayer_sides_off.png", - "mesecons_delayer_ends_off.png", - "mesecons_delayer_ends_off.png", - }, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, - wield_image = "mesecons_delayer_off.png", - walkable = true, - selection_box = { - type = "fixed", - fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, - }, - collision_box = { - type = "fixed", - fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, - }, - node_box = { - type = "fixed", - fixed = boxes - }, - groups = groups, - paramtype = "light", - paramtype2 = "facedir", - sunlight_propagates = false, - is_ground_content = false, - 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) - return - end - if node.name=="mesecons_delayer:delayer_off_1" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_off_2", param2=node.param2}) - elseif node.name=="mesecons_delayer:delayer_off_2" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_off_3", param2=node.param2}) - elseif node.name=="mesecons_delayer:delayer_off_3" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_off_4", param2=node.param2}) - elseif node.name=="mesecons_delayer:delayer_off_4" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_off_1", param2=node.param2}) - end - end, - on_construct = on_construct, - delayer_time = delaytime, - delayer_onstate = "mesecons_delayer:delayer_on_"..tostring(i), - delayer_lockstate = "mesecons_delayer:delayer_off_locked", - sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = { - receptor = - { - state = mesecon.state.off, - rules = delayer_get_output_rules + minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), { + description = desc_off, + inventory_image = icon, + wield_image = icon, + _tt_help = tt, + _doc_items_create_entry = help, + _doc_items_longdesc = longdesc, + _doc_items_usagehelp = usagehelp, + drawtype = "nodebox", + tiles = { + "mesecons_delayer_off.png", + "mcl_stairs_stone_slab_top.png", + "mesecons_delayer_sides_off.png", + "mesecons_delayer_sides_off.png", + "mesecons_delayer_ends_off.png", + "mesecons_delayer_ends_off.png", }, - effector = - { - rules = delayer_get_input_rules, - action_on = delayer_activate - } - }, - on_rotate = on_rotate, -}) - - -minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), { - description = S("Redstone Repeater (Delay @1, Powered)", i), - _doc_items_create_entry = false, - drawtype = "nodebox", - tiles = { - "mesecons_delayer_on.png", - "mcl_stairs_stone_slab_top.png", - "mesecons_delayer_sides_on.png", - "mesecons_delayer_sides_on.png", - "mesecons_delayer_ends_on.png", - "mesecons_delayer_ends_on.png", - }, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, - walkable = true, - selection_box = { - type = "fixed", - fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, - }, - collision_box = { - type = "fixed", - fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, - }, - node_box = { - type = "fixed", - fixed = boxes - }, - groups = {dig_immediate = 3, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1, attached_node=1, redstone_repeater=i, not_in_creative_inventory = 1}, - paramtype = "light", - paramtype2 = "facedir", - sunlight_propagates = false, - is_ground_content = false, - 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) - return - end - if node.name=="mesecons_delayer:delayer_on_1" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_on_2",param2=node.param2}) - elseif node.name=="mesecons_delayer:delayer_on_2" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_on_3",param2=node.param2}) - elseif node.name=="mesecons_delayer:delayer_on_3" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_on_4",param2=node.param2}) - elseif node.name=="mesecons_delayer:delayer_on_4" then - minetest.set_node(pos, {name="mesecons_delayer:delayer_on_1",param2=node.param2}) - end - end, - after_dig_node = function(pos, oldnode) - check_unlock_repeater(pos, oldnode) - end, - delayer_time = delaytime, - delayer_offstate = "mesecons_delayer:delayer_off_"..tostring(i), - delayer_lockstate = "mesecons_delayer:delayer_on_locked", - sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = { - receptor = - { - state = mesecon.state.on, - rules = delayer_get_output_rules + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, + --wield_image = "mesecons_delayer_off.png", + walkable = true, + selection_box = { + type = "fixed", + fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, }, - effector = - { - rules = delayer_get_input_rules, - action_off = delayer_deactivate - } - }, - on_rotate = on_rotate, -}) + collision_box = { + type = "fixed", + fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, + }, + node_box = { + type = "fixed", + fixed = boxes + }, + groups = groups, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = false, + is_ground_content = false, + 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) + return + end + if node.name=="mesecons_delayer:delayer_off_1" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_off_2", param2=node.param2}) + elseif node.name=="mesecons_delayer:delayer_off_2" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_off_3", param2=node.param2}) + elseif node.name=="mesecons_delayer:delayer_off_3" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_off_4", param2=node.param2}) + elseif node.name=="mesecons_delayer:delayer_off_4" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_off_1", param2=node.param2}) + end + end, + on_construct = on_construct, + delayer_time = delaytime, + delayer_onstate = "mesecons_delayer:delayer_on_"..tostring(i), + delayer_lockstate = "mesecons_delayer:delayer_off_locked", + sounds = mcl_sounds.node_sound_stone_defaults(), + mesecons = { + receptor = { + state = mesecon.state.off, + rules = delayer_get_output_rules, + }, + effector = { + rules = delayer_get_input_rules, + action_on = delayer_activate, + }, + }, + on_rotate = on_rotate, + }) + minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), { + description = S("Redstone Repeater (Delay @1, Powered)", i), + _doc_items_create_entry = false, + drawtype = "nodebox", + tiles = { + "mesecons_delayer_on.png", + "mcl_stairs_stone_slab_top.png", + "mesecons_delayer_sides_on.png", + "mesecons_delayer_sides_on.png", + "mesecons_delayer_ends_on.png", + "mesecons_delayer_ends_on.png", + }, + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, + walkable = true, + selection_box = { + type = "fixed", + fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, + }, + collision_box = { + type = "fixed", + fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, + }, + node_box = { + type = "fixed", + fixed = boxes + }, + groups = {dig_immediate = 3, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1, attached_node=1, redstone_repeater=i, not_in_creative_inventory = 1}, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = false, + is_ground_content = false, + 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) + return + end + --HACK! we already know the node name, so we should generate the function to avoid multiple checks + if node.name=="mesecons_delayer:delayer_on_1" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_on_2",param2=node.param2}) + elseif node.name=="mesecons_delayer:delayer_on_2" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_on_3",param2=node.param2}) + elseif node.name=="mesecons_delayer:delayer_on_3" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_on_4",param2=node.param2}) + elseif node.name=="mesecons_delayer:delayer_on_4" then + minetest.set_node(pos, {name="mesecons_delayer:delayer_on_1",param2=node.param2}) + end + end, + after_dig_node = function(pos, oldnode) + check_unlock_repeater(pos, oldnode) + end, + delayer_time = delaytime, + delayer_offstate = "mesecons_delayer:delayer_off_"..tostring(i), + delayer_lockstate = "mesecons_delayer:delayer_on_locked", + sounds = mcl_sounds.node_sound_stone_defaults(), + mesecons = { + receptor = { + state = mesecon.state.on, + rules = delayer_get_output_rules, + }, + effector = { + rules = delayer_get_input_rules, + action_off = delayer_deactivate, + }, + }, + on_rotate = on_rotate, + }) end diff --git a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua index 8cd5ae872..fedb8fa5d 100644 --- a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua @@ -1,3 +1,5 @@ +local table = table + --register stoppers for movestones/pistons mesecon.mvps_stoppers = {} @@ -6,8 +8,6 @@ mesecon.mvps_droppers = {} mesecon.on_mvps_move = {} mesecon.mvps_unmov = {} -local is_protected = minetest.is_protected - --- Objects (entities) that cannot be moved function mesecon.register_mvps_unmov(objectname) mesecon.mvps_unmov[objectname] = true; @@ -151,6 +151,7 @@ function mesecon.mvps_get_stack(pos, dir, maximum, piston_pos) -- add connected nodes to frontiers, connected is a vector list -- the vectors must be absolute positions local connected = {} + local has_loop if minetest.registered_nodes[nn.name] and minetest.registered_nodes[nn.name].mvps_sticky then connected, has_loop = minetest.registered_nodes[nn.name].mvps_sticky(np, nn, piston_pos) @@ -258,7 +259,7 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, player_name, n.meta = minetest.get_meta(n.pos):to_table() local is_dropper = mesecon.is_mvps_dropper(n.node, movedir, nodes, id) if is_dropper then - local drops = minetest.get_node_drops(n.node.name, "") + --local drops = minetest.get_node_drops(n.node.name, "") minetest.dig_node(n.pos) else minetest.remove_node(n.pos) diff --git a/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua b/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua index 3230d9804..0073aeb48 100644 --- a/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua @@ -2,29 +2,36 @@ local S = minetest.get_translator("mesecons_pistons") local PISTON_MAXIMUM_PUSH = 12 --- Get mesecon rules of pistons -local piston_rules = -{{x=0, y=0, z=1}, --everything apart from z- (pusher side) - {x=1, y=0, z=0}, - {x=-1, y=0, z=0}, - {x=0, y=1, z=0}, - {x=0, y=-1, z=0}} +--Get mesecon rules of pistons -local piston_up_rules = -{{x=0, y=0, z=-1}, --everything apart from y+ (pusher side) - {x=0, y=0, z=1}, - {x=-1, y=0, z=0}, - {x=1, y=0, z=0}, - {x=0, y=-1, z=0}} +--everything apart from z- (pusher side) +local piston_rules = { + {x=0, y=0, z=1}, + {x=1, y=0, z=0}, + {x=-1, y=0, z=0}, + {x=0, y=1, z=0}, + {x=0, y=-1, z=0}, +} -local piston_down_rules = -{{x=0, y=0, z=-1}, --everything apart from y- (pusher side) - {x=0, y=0, z=1}, - {x=-1, y=0, z=0}, - {x=1, y=0, z=0}, - {x=0, y=1, z=0}} +--everything apart from y+ (pusher side) +local piston_up_rules = { + {x=0, y=0, z=-1}, + {x=0, y=0, z=1}, + {x=-1, y=0, z=0}, + {x=1, y=0, z=0}, + {x=0, y=-1, z=0}, +} -local piston_get_rules = function (node) +--everything apart from y- (pusher side) +local piston_down_rules = { + {x=0, y=0, z=-1}, + {x=0, y=0, z=1}, + {x=-1, y=0, z=0}, + {x=1, y=0, z=0}, + {x=0, y=1, z=0}, +} + +local function piston_get_rules(node) local rules = piston_rules for i = 1, node.param2 do rules = mesecon.rotate_rules_left(rules) @@ -32,7 +39,7 @@ local piston_get_rules = function (node) return rules end -local piston_facedir_direction = function (node) +local function piston_facedir_direction(node) local rules = {{x = 0, y = 0, z = -1}} for i = 1, node.param2 do rules = mesecon.rotate_rules_left(rules) @@ -40,7 +47,7 @@ local piston_facedir_direction = function (node) return rules[1] end -local piston_get_direction = function (dir, node) +local function piston_get_direction(dir, node) if type(dir) == "function" then return dir(node) else @@ -50,7 +57,7 @@ end -- Remove pusher of piston. -- To be used when piston was destroyed or dug. -local piston_remove_pusher = function (pos, oldnode) +local function piston_remove_pusher(pos, oldnode) local pistonspec = minetest.registered_nodes[oldnode.name].mesecons_piston local dir = piston_get_direction(pistonspec.dir, oldnode) @@ -70,7 +77,7 @@ end -- Remove base node of piston. -- To be used when pusher was destroyed. -local piston_remove_base = function (pos, oldnode) +local function piston_remove_base(pos, oldnode) local basenodename = minetest.registered_nodes[oldnode.name].corresponding_piston local pistonspec = minetest.registered_nodes[basenodename].mesecons_piston @@ -89,7 +96,7 @@ local piston_remove_base = function (pos, oldnode) end end -local piston_on = function (pos, node) +local function piston_on(pos, node) local pistonspec = minetest.registered_nodes[node.name].mesecons_piston local dir = piston_get_direction(pistonspec.dir, node) @@ -113,7 +120,7 @@ local piston_on = function (pos, node) end end -local piston_off = function (pos, node) +local function piston_off(pos, node) local pistonspec = minetest.registered_nodes[node.name].mesecons_piston minetest.swap_node(pos, {param2 = node.param2, name = pistonspec.offname}) piston_remove_pusher (pos, node) @@ -124,13 +131,13 @@ local piston_off = function (pos, node) local dir = piston_get_direction(pistonspec.dir, node) local pullpos = vector.add(pos, vector.multiply(dir, 2)) local meta = minetest.get_meta(pos) - local success, stack, oldstack = mesecon.mvps_pull_single(pullpos, vector.multiply(dir, -1), PISTON_MAXIMUM_PUSH, meta:get_string("owner"), pos) + local success, stack = mesecon.mvps_pull_single(pullpos, vector.multiply(dir, -1), PISTON_MAXIMUM_PUSH, meta:get_string("owner"), pos) if success then mesecon.mvps_process_stack(pos, dir, stack) end end -local piston_orientate = function (pos, placer) +local function piston_orientate(pos, placer) mesecon.mvps_set_owner(pos, placer) -- not placed by player @@ -158,14 +165,14 @@ local piston_pusher_box = { fixed = { {-2/16, -2/16, -.5 + pt, 2/16, 2/16, .5 + pt}, {-.5 , -.5 , -.5 , .5 , .5 , -.5 + pt}, - } + }, } local piston_on_box = { type = "fixed", fixed = { {-.5, -.5, -.5 + pt, .5, .5, .5} - } + }, } @@ -195,18 +202,20 @@ minetest.register_node("mesecons_pistons:piston_normal_off", { "mesecons_piston_bottom.png^[transformR270", "mesecons_piston_back.png", "mesecons_piston_pusher_front.png" - }, - groups = {handy = 1, piston=1}, + }, + groups = {handy=1, piston=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, after_place_node = piston_orientate, mesecons_piston = pistonspec_normal, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_on = piston_on, - rules = piston_get_rules - }}, + mesecons = { + effector = { + action_on = piston_on, + rules = piston_get_rules + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = function(pos, node, user, mode) @@ -227,8 +236,8 @@ minetest.register_node("mesecons_pistons:piston_normal_on", { "mesecons_piston_bottom.png^[transformR270", "mesecons_piston_back.png", "mesecons_piston_on_front.png" - }, - groups = {handy=1, piston=1, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=1, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -238,10 +247,12 @@ minetest.register_node("mesecons_pistons:piston_normal_on", { selection_box = piston_on_box, mesecons_piston = pistonspec_normal, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_off = piston_off, - rules = piston_get_rules - }}, + mesecons = { + effector = { + action_off = piston_off, + rules = piston_get_rules + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = false, @@ -257,10 +268,10 @@ minetest.register_node("mesecons_pistons:piston_pusher_normal", { "mesecons_piston_pusher_right.png", "mesecons_piston_pusher_back.png", "mesecons_piston_pusher_front.png" - }, + }, paramtype = "light", paramtype2 = "facedir", - groups = { piston_pusher = 1 }, + groups = {piston_pusher=1}, is_ground_content = false, after_destruct = piston_remove_base, diggable = false, @@ -299,7 +310,7 @@ minetest.register_node("mesecons_pistons:piston_sticky_off", { "mesecons_piston_bottom.png^[transformR270", "mesecons_piston_back.png", "mesecons_piston_pusher_front_sticky.png" - }, + }, groups = {handy=1, piston=2}, paramtype = "light", paramtype2 = "facedir", @@ -307,10 +318,12 @@ minetest.register_node("mesecons_pistons:piston_sticky_off", { after_place_node = piston_orientate, mesecons_piston = pistonspec_sticky, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_on = piston_on, - rules = piston_get_rules - }}, + mesecons = { + effector = { + action_on = piston_on, + rules = piston_get_rules + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = function(pos, node, user, mode) @@ -331,8 +344,8 @@ minetest.register_node("mesecons_pistons:piston_sticky_on", { "mesecons_piston_bottom.png^[transformR270", "mesecons_piston_back.png", "mesecons_piston_on_front.png" - }, - groups = {handy=1, piston=2, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=2, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -342,10 +355,12 @@ minetest.register_node("mesecons_pistons:piston_sticky_on", { selection_box = piston_on_box, mesecons_piston = pistonspec_sticky, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_off = piston_off, - rules = piston_get_rules - }}, + mesecons = { + effector = { + action_off = piston_off, + rules = piston_get_rules + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = false, @@ -361,10 +376,10 @@ minetest.register_node("mesecons_pistons:piston_pusher_sticky", { "mesecons_piston_pusher_right.png", "mesecons_piston_pusher_back.png", "mesecons_piston_pusher_front_sticky.png" - }, + }, paramtype = "light", paramtype2 = "facedir", - groups = { piston_pusher = 2 }, + groups = {piston_pusher=2}, is_ground_content = false, after_destruct = piston_remove_base, diggable = false, @@ -388,14 +403,14 @@ local piston_up_pusher_box = { fixed = { {-2/16, -.5 - pt, -2/16, 2/16, .5 - pt, 2/16}, {-.5 , .5 - pt, -.5 , .5 , .5 , .5}, - } + }, } local piston_up_on_box = { type = "fixed", fixed = { {-.5, -.5, -.5 , .5, .5-pt, .5} - } + }, } -- Normal @@ -404,7 +419,7 @@ local pistonspec_normal_up = { offname = "mesecons_pistons:piston_up_normal_off", onname = "mesecons_pistons:piston_up_normal_on", dir = {x = 0, y = 1, z = 0}, - pusher = "mesecons_pistons:piston_up_pusher_normal" + pusher = "mesecons_pistons:piston_up_pusher_normal", } -- offstate @@ -416,17 +431,19 @@ minetest.register_node("mesecons_pistons:piston_up_normal_off", { "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", - }, - groups = {handy=1, piston=1, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=1, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, drop = "mesecons_pistons:piston_normal_off", mesecons_piston = pistonspec_normal_up, - mesecons = {effector={ - action_on = piston_on, - rules = piston_up_rules, - }}, + mesecons = { + effector = { + action_on = piston_on, + rules = piston_up_rules, + }, + }, sounds = mcl_sounds.node_sound_stone_defaults({ footstep = mcl_sounds.node_sound_wood_defaults().footstep }), @@ -451,8 +468,8 @@ minetest.register_node("mesecons_pistons:piston_up_normal_on", { "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", - }, - groups = {handy=1, piston_=1, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston_=1, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -462,10 +479,12 @@ minetest.register_node("mesecons_pistons:piston_up_normal_on", { selection_box = piston_up_on_box, mesecons_piston = pistonspec_normal_up, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_off = piston_off, - rules = piston_up_rules, - }}, + mesecons = { + effector = { + action_off = piston_off, + rules = piston_up_rules, + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = false, @@ -481,10 +500,10 @@ minetest.register_node("mesecons_pistons:piston_up_pusher_normal", { "mesecons_piston_pusher_right.png^[transformR90", "mesecons_piston_pusher_bottom.png", "mesecons_piston_pusher_top.png^[transformR180", - }, + }, paramtype = "light", paramtype2 = "facedir", - groups = { piston_pusher = 1 }, + groups = {piston_pusher=1}, is_ground_content = false, after_destruct = piston_remove_base, diggable = false, @@ -507,7 +526,7 @@ local pistonspec_sticky_up = { onname = "mesecons_pistons:piston_up_sticky_on", dir = {x = 0, y = 1, z = 0}, pusher = "mesecons_pistons:piston_up_pusher_sticky", - sticky = true + sticky = true, } -- offstate @@ -519,8 +538,8 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_off", { "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", - }, - groups = {handy=1, piston=2, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=2, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -529,10 +548,12 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_off", { sounds = mcl_sounds.node_sound_stone_defaults({ footstep = mcl_sounds.node_sound_wood_defaults().footstep }), - mesecons = {effector={ - action_on = piston_on, - rules = piston_up_rules, - }}, + mesecons = { + effector = { + action_on = piston_on, + rules = piston_up_rules, + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = function(pos, node, user, mode) @@ -554,8 +575,8 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_on", { "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", "mesecons_piston_bottom.png", - }, - groups = {handy=1, piston=2, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=2, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -565,10 +586,12 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_on", { selection_box = piston_up_on_box, mesecons_piston = pistonspec_sticky_up, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_off = piston_off, - rules = piston_up_rules, - }}, + mesecons = { + effector = { + action_off = piston_off, + rules = piston_up_rules, + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = false, @@ -584,10 +607,10 @@ minetest.register_node("mesecons_pistons:piston_up_pusher_sticky", { "mesecons_piston_pusher_right.png^[transformR90", "mesecons_piston_pusher_bottom.png", "mesecons_piston_pusher_top.png^[transformR180", - }, + }, paramtype = "light", paramtype2 = "facedir", - groups = { piston_pusher = 2 }, + groups = {piston_pusher=2}, is_ground_content = false, after_destruct = piston_remove_base, diggable = false, @@ -611,14 +634,14 @@ local piston_down_pusher_box = { fixed = { {-2/16, -.5 + pt, -2/16, 2/16, .5 + pt, 2/16}, {-.5 , -.5 , -.5 , .5 , -.5 + pt, .5}, - } + }, } local piston_down_on_box = { type = "fixed", fixed = { {-.5, -.5+pt, -.5 , .5, .5, .5} - } + }, } @@ -641,18 +664,20 @@ minetest.register_node("mesecons_pistons:piston_down_normal_off", { "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", - }, - groups = {handy=1, piston=1, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=1, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, drop = "mesecons_pistons:piston_normal_off", mesecons_piston = pistonspec_normal_down, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_on = piston_on, - rules = piston_down_rules, - }}, + mesecons = { + effector = { + action_on = piston_on, + rules = piston_down_rules, + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = function(pos, node, user, mode) @@ -674,8 +699,8 @@ minetest.register_node("mesecons_pistons:piston_down_normal_on", { "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", - }, - groups = {handy=1, piston=1, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=1, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -685,10 +710,12 @@ minetest.register_node("mesecons_pistons:piston_down_normal_on", { selection_box = piston_down_on_box, mesecons_piston = pistonspec_normal_down, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_off = piston_off, - rules = piston_down_rules, - }}, + mesecons = { + effector = { + action_off = piston_off, + rules = piston_down_rules, + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = false, @@ -704,10 +731,10 @@ minetest.register_node("mesecons_pistons:piston_down_pusher_normal", { "mesecons_piston_pusher_right.png^[transformR270", "mesecons_piston_pusher_bottom.png^[transformR180", "mesecons_piston_pusher_top.png", - }, + }, paramtype = "light", paramtype2 = "facedir", - groups = { piston_pusher = 1 }, + groups = {piston_pusher=1}, is_ground_content = false, after_destruct = piston_remove_base, diggable = false, @@ -727,7 +754,7 @@ local pistonspec_sticky_down = { offname = "mesecons_pistons:piston_down_sticky_off", dir = {x = 0, y = -1, z = 0}, pusher = "mesecons_pistons:piston_down_pusher_sticky", - sticky = true + sticky = true, } -- offstate @@ -739,7 +766,7 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_off", { "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", - }, + }, groups = {handy=1, piston=2, not_in_creative_inventory = 1}, paramtype = "light", paramtype2 = "facedir", @@ -747,10 +774,12 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_off", { drop = "mesecons_pistons:piston_sticky_off", mesecons_piston = pistonspec_sticky_down, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_on = piston_on, - rules = piston_down_rules, - }}, + mesecons = { + effector = { + action_on = piston_on, + rules = piston_down_rules, + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = function(pos, node, user, mode) @@ -772,8 +801,8 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_on", { "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", "mesecons_piston_bottom.png^[transformR180", - }, - groups = {handy=1, piston=1, not_in_creative_inventory = 1}, + }, + groups = {handy=1, piston=1, not_in_creative_inventory=1}, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -783,10 +812,12 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_on", { selection_box = piston_down_on_box, mesecons_piston = pistonspec_sticky_down, sounds = mcl_sounds.node_sound_stone_defaults(), - mesecons = {effector={ - action_off = piston_off, - rules = piston_down_rules, - }}, + mesecons = { + effector = { + action_off = piston_off, + rules = piston_down_rules, + }, + }, _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, on_rotate = false, @@ -802,10 +833,10 @@ minetest.register_node("mesecons_pistons:piston_down_pusher_sticky", { "mesecons_piston_pusher_right.png^[transformR270", "mesecons_piston_pusher_bottom.png^[transformR180", "mesecons_piston_pusher_top.png", - }, + }, paramtype = "light", paramtype2 = "facedir", - groups = { piston_pusher = 2 }, + groups = {piston_pusher=2}, is_ground_content = false, after_destruct = piston_remove_base, diggable = false, @@ -839,7 +870,7 @@ minetest.register_craft({ {"group:wood", "group:wood", "group:wood"}, {"mcl_core:cobble", "mcl_core:iron_ingot", "mcl_core:cobble"}, {"mcl_core:cobble", "mesecons:redstone", "mcl_core:cobble"}, - } + }, }) minetest.register_craft({ @@ -847,7 +878,7 @@ minetest.register_craft({ recipe = { {"mcl_mobitems:slimeball"}, {"mesecons_pistons:piston_normal_off"}, - } + }, }) -- Add entry aliases for the Help diff --git a/mods/ITEMS/REDSTONE/mesecons_pressureplates/init.lua b/mods/ITEMS/REDSTONE/mesecons_pressureplates/init.lua index 2e161ae4d..34730760d 100644 --- a/mods/ITEMS/REDSTONE/mesecons_pressureplates/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_pressureplates/init.lua @@ -116,7 +116,7 @@ function mesecon.register_pressure_plate(basename, description, textures_off, te wield_image = image_w, paramtype = "light", walkable = false, - description = description, + description = description, on_timer = pp_on_timer, on_construct = function(pos) minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) diff --git a/mods/ITEMS/REDSTONE/mesecons_wires/init.lua b/mods/ITEMS/REDSTONE/mesecons_wires/init.lua index e0c5ac531..3d00e5f20 100644 --- a/mods/ITEMS/REDSTONE/mesecons_wires/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_wires/init.lua @@ -33,7 +33,7 @@ local wire_getconnect = function (from_pos, self_pos) if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].mesecons then -- rules of node to possibly connect to - local rules = {} + local rules if (minetest.registered_nodes[node.name].mesecon_wire) then rules = wire_rules else @@ -214,8 +214,7 @@ local function register_wires() local dot_off = "redstone_redstone_dust_dot.png^[colorize:#FF0000:"..ratio_off local dot_on = "redstone_redstone_dust_dot.png^[colorize:#FF0000:"..ratio_on - local tiles_off = { crossing_off, crossing_off, straight0_off, straight1_off, straight0_off, straight1_off } - local tiles_on = { crossing_on, crossing_on, straight0_on, straight1_on, straight0_on, straight1_on } + local tiles_off, tiles_on local wirehelp, tt, longdesc, usagehelp, img, desc_off, desc_on if nodeid == "00000000" then @@ -238,8 +237,8 @@ S("Read the help entries on the other redstone components to learn how redstone else -- Connected redstone wire table.insert(nodebox, box_center) - tiles_off = { crossing_off, crossing_off, straight0_off, straight1_off, straight0_off, straight1_off, } - tiles_on = { crossing_on, crossing_on, straight0_on, straight1_on, straight0_on, straight1_on, } + tiles_off = { crossing_off, crossing_off, straight0_off, straight1_off, straight0_off, straight1_off } + tiles_on = { crossing_on, crossing_on, straight0_on, straight1_on, straight0_on, straight1_on } wirehelp = false desc_off = S("Redstone Trail (@1)", nodeid) desc_on = S("Powered Redstone Trail (@1)", nodeid) diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index c3c238e7f..09f4d954c 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -41,7 +41,7 @@ end -- needs to be used up to repair the tool. local function get_consumed_materials(tool, material) local wear = tool:get_wear() - local health = (MAX_WEAR - wear) + --local health = (MAX_WEAR - wear) local matsize = material:get_count() local materials_used = 0 for m=1, math.min(4, matsize) do @@ -74,10 +74,9 @@ end local function update_anvil_slots(meta) local inv = meta:get_inventory() local new_name = meta:get_string("set_name") - local input1, input2, output - input1 = inv:get_stack("input", 1) - input2 = inv:get_stack("input", 2) - output = inv:get_stack("output", 1) + local input1 = inv:get_stack("input", 1) + local input2 = inv:get_stack("input", 2) + --local output = inv:get_stack("output", 1) local new_output, name_item local just_rename = false @@ -243,7 +242,6 @@ end -- Returns true if anvil was destroyed. local function damage_anvil(pos) local node = minetest.get_node(pos) - local new if node.name == "mcl_anvils:anvil" then minetest.swap_node(pos, {name="mcl_anvils:anvil_damage_1", param2=node.param2}) damage_particles(pos, node) @@ -278,7 +276,6 @@ local function damage_anvil_by_using(pos) end local function damage_anvil_by_falling(pos, distance) - local chance local r = math.random(1, 100) if distance > 1 then if r <= (5*distance) then diff --git a/mods/ITEMS/mcl_armor/damage.lua b/mods/ITEMS/mcl_armor/damage.lua index f17033495..ed616397d 100644 --- a/mods/ITEMS/mcl_armor/damage.lua +++ b/mods/ITEMS/mcl_armor/damage.lua @@ -68,7 +68,7 @@ mcl_damage.register_modifier(function(obj, damage, reason) if do_irregular_damage or thorns_damage_regular < 4 and math.random() < enchantments.thorns * 0.15 then if do_irregular_damage then - thorns_damage_irregular = thorns_damage_irregular + throrns_level - 10 + thorns_damage_irregular = thorns_damage_irregular + enchantments.thorns - 10 else thorns_damage_regular = math.min(4, thorns_damage_regular + math.random(4)) end diff --git a/mods/ITEMS/mcl_banners/patterncraft.lua b/mods/ITEMS/mcl_banners/patterncraft.lua index fbd0c9e33..516624301 100644 --- a/mods/ITEMS/mcl_banners/patterncraft.lua +++ b/mods/ITEMS/mcl_banners/patterncraft.lua @@ -426,7 +426,6 @@ local banner_pattern_craft = function(itemstack, player, old_craft_grid, craft_i if (pitem == d and minetest.get_item_group(itemname, "dye") == 0) or (pitem == e and itemname ~= e and inv_i ~= banner_index) then pattern_ok = false break - else end inv_i = inv_i + 1 if inv_i > max_i then diff --git a/mods/ITEMS/mcl_beds/api.lua b/mods/ITEMS/mcl_beds/api.lua index c0b25b1c5..ee59bc34b 100644 --- a/mods/ITEMS/mcl_beds/api.lua +++ b/mods/ITEMS/mcl_beds/api.lua @@ -48,7 +48,9 @@ local function rotate(pos, node, user, mode, new_param2) return false end - local new_dir, newp = minetest_facedir_to_dir(new_param2) + local newp + local new_dir = minetest_facedir_to_dir(new_param2) + if bottom then newp = vector_add(pos, new_dir) else @@ -153,7 +155,7 @@ function mcl_beds.register_bed(name, def) paramtype2 = "facedir", is_ground_content = false, stack_max = 1, - groups = {handy=1, flammable = 3, bed = 1, dig_by_piston=1, bouncy=66, fall_damage_add_percent=-50, deco_block = 1, flammable=-1}, + groups = {handy=1, bed = 1, dig_by_piston=1, bouncy=66, fall_damage_add_percent=-50, deco_block = 1, flammable=-1}, _mcl_hardness = 0.2, _mcl_blast_resistance = 1, sounds = def.sounds or default_sounds, diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index ecd749603..fd156757b 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -319,14 +319,14 @@ function mcl_beds.on_rightclick(pos, player, is_top) -- move to bed if not mcl_beds.player[name] then - local success, message + local message if is_top then - success, message = lay_down(player, ppos, pos) + message = select(2, lay_down(player, ppos, pos)) else local node = minetest.get_node(pos) local dir = minetest.facedir_to_dir(node.param2) local other = vector.add(pos, dir) - success, message = lay_down(player, ppos, other) + message = select(2, lay_down(player, ppos, other)) end if message then mcl_tmp_message.message(player, message) diff --git a/mods/ITEMS/mcl_books/init.lua b/mods/ITEMS/mcl_books/init.lua index 95b45e69e..b7bd20d9a 100644 --- a/mods/ITEMS/mcl_books/init.lua +++ b/mods/ITEMS/mcl_books/init.lua @@ -238,11 +238,9 @@ minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craf end local original - local index for i = 1, player:get_inventory():get_size("craft") do if old_craft_grid[i]:get_name() == "mcl_books:written_book" then original = old_craft_grid[i] - index = i end end if not original then diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index c34e93479..a56b2e7cf 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -1,29 +1,32 @@ local S = minetest.get_translator("mcl_bows") +local math = math +local vector = vector + -- Time in seconds after which a stuck arrow is deleted local ARROW_TIMEOUT = 60 -- Time after which stuck arrow is rechecked for being stuck local STUCK_RECHECK_TIME = 5 -local GRAVITY = 9.81 +--local GRAVITY = 9.81 local YAW_OFFSET = -math.pi/2 -local dir_to_pitch = function(dir) - local dir2 = vector.normalize(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) end -local random_arrow_positions = function(positions, placement) - if positions == 'x' then +local function random_arrow_positions(positions, placement) + if positions == "x" then return math.random(-4, 4) - elseif positions == 'y' then + elseif positions == "y" then return math.random(0, 10) end - if placement == 'front' and positions == 'z' then + if placement == "front" and positions == "z" then return 3 - elseif placement == 'back' and positions == 'z' then + elseif placement == "back" and positions == "z" then return -3 end return 0 @@ -257,12 +260,12 @@ ARROW_ENTITY.on_step = function(self, dtime) damage_groups={fleshy=self._damage}, }, self.object:get_velocity()) if obj:is_player() then - local placement = '' + local placement self._placement = math.random(1, 2) if self._placement == 1 then - placement = 'front' + placement = "front" else - placement = 'back' + placement = "back" end self._in_player = true if self._placement == 2 then @@ -393,7 +396,7 @@ ARROW_ENTITY.on_step = function(self, dtime) if not v then v = 0 end - local old_v = self._viscosity + --local old_v = self._viscosity self._viscosity = v local vpenalty = math.max(0.1, 0.98 - 0.1 * v) if math.abs(vel.x) > 0.001 then diff --git a/mods/ITEMS/mcl_bows/bow.lua b/mods/ITEMS/mcl_bows/bow.lua index 8315d9ed5..af26383db 100644 --- a/mods/ITEMS/mcl_bows/bow.lua +++ b/mods/ITEMS/mcl_bows/bow.lua @@ -228,11 +228,10 @@ end controls.register_on_release(function(player, key, time) if key~="RMB" then return end - local inv = minetest.get_inventory({type="player", name=player:get_player_name()}) + --local inv = minetest.get_inventory({type="player", name=player:get_player_name()}) local wielditem = player:get_wielded_item() if (wielditem:get_name()=="mcl_bows:bow_0" or wielditem:get_name()=="mcl_bows:bow_1" or wielditem:get_name()=="mcl_bows:bow_2" or wielditem:get_name()=="mcl_bows:bow_0_enchanted" or wielditem:get_name()=="mcl_bows:bow_1_enchanted" or wielditem:get_name()=="mcl_bows:bow_2_enchanted") then - local has_shot = false local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name()) local speed, damage @@ -272,7 +271,7 @@ controls.register_on_release(function(player, key, time) damage = math.max(1, math.floor(9 * charge_ratio)) end - has_shot = player_shoot_arrow(wielditem, player, speed, damage, is_critical) + local has_shot = player_shoot_arrow(wielditem, player, speed, damage, is_critical) if enchanted then wielditem:set_name("mcl_bows:bow_enchanted") @@ -299,7 +298,7 @@ controls.register_on_hold(function(player, key, time) if key ~= "RMB" or not (creative or get_arrow(player)) then return end - local inv = minetest.get_inventory({type="player", name=name}) + --local inv = minetest.get_inventory({type="player", name=name}) local wielditem = player:get_wielded_item() if bow_load[name] == nil and (wielditem:get_name()=="mcl_bows:bow" or wielditem:get_name()=="mcl_bows:bow_enchanted") and wielditem:get_meta():get("active") and (creative or get_arrow(player)) then local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name()) diff --git a/mods/ITEMS/mcl_brewing/init.lua b/mods/ITEMS/mcl_brewing/init.lua index 617929ff7..1724a982d 100644 --- a/mods/ITEMS/mcl_brewing/init.lua +++ b/mods/ITEMS/mcl_brewing/init.lua @@ -61,14 +61,14 @@ local brewing_formspec = "size[9,8.75]".. "listring[context;stand]" -local function swap_node(pos, name) +--[[local function swap_node(pos, name) local node = minetest.get_node(pos) if node.name == name then return end node.name = name minetest.swap_node(pos, node) -end +end]] local function brewable(inv) @@ -110,12 +110,13 @@ local function brewing_stand_timer(pos, elapsed) local BREW_TIME = 20 -- all brews brew the same local BURN_TIME = BREW_TIME * 10 - local input_item = meta:get_string("input_item") or "" + --local input_item = meta:get_string("input_item") or "" local stand_timer = meta:get_float("stand_timer") or 0 local fuel = meta:get_float("fuel") or 0 local inv = meta:get_inventory() - local input_list, stand_list, fuel_list, brew_output, d + --local input_list, stand_list, fuel_list + local brew_output, d local input_count, fuel_name, fuel_count, formspec, fuel_percent, brew_percent local update = true @@ -124,9 +125,9 @@ local function brewing_stand_timer(pos, elapsed) update = false - input_list = inv:get_list("input") - stand_list = inv:get_list("stand") - fuel_list = inv:get_list("fuel") + --input_list = inv:get_list("input") + --stand_list = inv:get_list("stand") + --fuel_list = inv:get_list("fuel") -- TODO ... fix this. Goal is to reset the process if the stand changes -- for i=1, inv:get_size("stand", i) do -- reset the process due to change @@ -237,7 +238,7 @@ local function brewing_stand_timer(pos, elapsed) end -local function allow_metadata_inventory_put(pos, listname, index, stack, player) +--[[local function allow_metadata_inventory_put(pos, listname, index, stack, player) local name = player:get_player_name() if minetest.is_protected(pos, name) then minetest.record_protection_violation(pos, name) @@ -273,7 +274,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player) elseif listname == "stand" then return 0 end -end +end]] -- Drop input items of brewing_stand at pos with metadata meta @@ -315,12 +316,14 @@ local doc_string = S("When you have found a good combination, the brewing will commence automatically and steam starts to appear, using up the fuel and brewing material. The potions will soon be ready.").."\n".. S("Different combinations of brewing materials and liquids will give different results. Try to experiment!") -local tiles = {"mcl_brewing_top.png", --top - "mcl_brewing_base.png", --bottom - "mcl_brewing_side.png", --right - "mcl_brewing_side.png", --left - "mcl_brewing_side.png", --back - "mcl_brewing_side.png^[transformFX"} --front +local tiles = { + "mcl_brewing_top.png", --top + "mcl_brewing_base.png", --bottom + "mcl_brewing_side.png", --right + "mcl_brewing_side.png", --left + "mcl_brewing_side.png", --back + "mcl_brewing_side.png^[transformFX", --front +} local allow_put = function(pos, listname, index, stack, player) local name = player:get_player_name() @@ -349,11 +352,11 @@ local on_put = function(pos, listname, index, stack, player) --some code here to enforce only potions getting placed on stands end -local after_dig = function(pos, oldnode, oldmetadata, digger) +--[[local after_dig = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) meta:from_table(oldmetadata) drop_brewing_stand_items(pos, meta) -end +end]] local on_destruct = function(pos) local meta = minetest.get_meta(pos) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 0ba68b723..fd07006b7 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -1,8 +1,7 @@ -local S = minetest.get_translator("mcl_buckets") -local modpath = minetest.get_modpath(minetest.get_current_modname()) - --- Minetest 0.4 mod: bucket -- See README.txt for licensing and other information. +local modname = minetest.get_current_modname() +local S = minetest.get_translator(modname) +local modpath = minetest.get_modpath(modname) minetest.register_alias("bucket:bucket_empty", "mcl_buckets:bucket_empty") minetest.register_alias("bucket:bucket_water", "mcl_buckets:bucket_water") @@ -10,7 +9,7 @@ minetest.register_alias("bucket:bucket_lava", "mcl_buckets:bucket_lava") local mod_doc = minetest.get_modpath("doc") local mod_mcl_core = minetest.get_modpath("mcl_core") -local mod_mclx_core = minetest.get_modpath("mclx_core") +--local mod_mclx_core = minetest.get_modpath("mclx_core") if mod_mcl_core then minetest.register_craft({ @@ -51,6 +50,7 @@ function mcl_buckets.register_liquid(def) mcl_buckets.liquids[def.source_take[i]] = { source_place = def.source_place, source_take = def.source_take[i], + on_take = def.on_take, itemname = def.itemname, } if type(def.source_place) == "string" then @@ -76,10 +76,11 @@ function mcl_buckets.register_liquid(def) local node = minetest.get_node(pointed_thing.under) local place_pos = pointed_thing.under local nn = node.name + local nodedef = minetest.registered_nodes[nn] -- Call on_rightclick if the pointed node defines it if user and not user:get_player_control().sneak then - if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then - return minetest.registered_nodes[nn].on_rightclick(place_pos, node, user, itemstack) or itemstack + if nodedef and nodedef.on_rightclick then + return nodedef.on_rightclick(place_pos, node, user, itemstack) or itemstack end end @@ -90,11 +91,9 @@ function mcl_buckets.register_liquid(def) node_place = def.source_place end -- Check if pointing to a buildable node - local item = itemstack:get_name() + --local item = itemstack:get_name() - if def.extra_check and def.extra_check(place_pos, user) == false then - -- Fail placement of liquid - elseif minetest.registered_nodes[nn] and minetest.registered_nodes[nn].buildable_to then + if def.extra_check and def.extra_check(place_pos, user) == true and nodedef and nodedef.buildable_to then -- buildable; replace the node local pns = user:get_player_name() if minetest.is_protected(place_pos, pns) then @@ -147,12 +146,12 @@ function mcl_buckets.register_liquid(def) end end, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) - local iname = stack:get_name() + --local iname = stack:get_name() local buildable = minetest.registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" - if def.extra_check and def.extra_check(droppos, nil) == false then + --if def.extra_check and def.extra_check(droppos, nil) == false then -- Fail placement of liquid - elseif buildable then + if def.extra_check and def.extra_check(droppos, nil) == true and buildable then -- buildable; replace the node local node_place if type(def.source_place) == "function" then @@ -207,8 +206,8 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { -- Fill bucket, but not in Creative Mode if not minetest.is_creative_enabled(user:get_player_name()) then new_bucket = ItemStack({name = liquiddef.itemname}) - if liquiddef.itemname == "mcl_buckets:bucket_lava" and awards and awards.unlock and user and user:is_player() then - awards.unlock(user:get_player_name(), "mcl:hotStuff") + if liquiddef.on_take then + liquiddef.on_take(user) end end diff --git a/mods/ITEMS/mcl_buckets/register.lua b/mods/ITEMS/mcl_buckets/register.lua index b5d86ac0e..5e46b6ce0 100644 --- a/mods/ITEMS/mcl_buckets/register.lua +++ b/mods/ITEMS/mcl_buckets/register.lua @@ -1,6 +1,7 @@ local S = minetest.get_translator(minetest.get_current_modname()) local mod_mcl_core = minetest.get_modpath("mcl_core") local mod_mclx_core = minetest.get_modpath("mclx_core") +local has_awards = minetest.get_modpath("awards") local sound_place = function(itemname, pos) local def = minetest.registered_nodes[itemname] @@ -9,12 +10,12 @@ local sound_place = function(itemname, pos) end end -local sound_take = function(itemname, pos) +--[[local sound_take = function(itemname, pos) local def = minetest.registered_nodes[itemname] if def and def.sounds and def.sounds.dug then minetest.sound_play(def.sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end -end +end]] if mod_mcl_core then -- Lava bucket @@ -28,6 +29,11 @@ if mod_mcl_core then end end, source_take = {"mcl_core:lava_source", "mcl_nether:nether_lava_source"}, + on_take = function(user) + if has_awards and user and user:is_player() then + awards.unlock(user:get_player_name(), "mcl:hotStuff") + end + end, itemname = "mcl_buckets:bucket_lava", inventory_image = "bucket_lava.png", name = S("Lava Bucket"), diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index 824530eb3..b92ed4c01 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -162,13 +162,14 @@ Value: Otherwise: nil ]] local open_chests = {} -local function back_is_blocked(pos, dir) +--[[local function back_is_blocked(pos, dir) pos = vector.add(pos, dir) local def = minetest.registered_nodes[minetest.get_node(pos).name] pos.y = pos.y + 1 local def2 = minetest.registered_nodes[minetest.get_node(pos).name] return not def or def.groups.opaque == 1 or not def2 or def2.groups.opaque == 1 -end +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 name = player:get_player_name() @@ -696,7 +697,6 @@ minetest.register_node("mcl_chests:"..basename.."_right", { minetest.swap_node(p, { name = small_name, param2 = param2 }) create_entity(p, small_name, small_textures, param2, false, "default_chest", "mcl_chests_chest", "chest") - local meta = minetest.get_meta(pos) end, after_dig_node = drop_items_chest, on_blast = on_chest_blast, @@ -898,7 +898,7 @@ register_chest("trapped_chest_on", "trapped_chest" ) -local function close_if_trapped_chest(pos, player) +--[[local function close_if_trapped_chest(pos, player) local node = minetest.get_node(pos) if node.name == "mcl_chests:trapped_chest_on_small" then @@ -928,7 +928,7 @@ local function close_if_trapped_chest(pos, player) player_chest_close(player) end -end +end]] -- Disable chest when it has been closed minetest.register_on_player_receive_fields(function(player, formname, fields) @@ -1330,7 +1330,6 @@ minetest.register_craft({ -- Save metadata of shulker box when used in crafting minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) - local new = itemstack:get_name() if minetest.get_item_group(itemstack:get_name(), "shulker_box") ~= 1 then return end diff --git a/mods/ITEMS/mcl_clock/init.lua b/mods/ITEMS/mcl_clock/init.lua index 286f4ec5e..b9ae3dd80 100644 --- a/mods/ITEMS/mcl_clock/init.lua +++ b/mods/ITEMS/mcl_clock/init.lua @@ -96,8 +96,6 @@ minetest.register_globalstep(function(dtime) for p, player in pairs(minetest.get_connected_players()) do for s, stack in pairs(player:get_inventory():get_list("main")) do - local dim = mcl_worlds.pos_to_dimension(player:get_pos()) - local frame -- Clocks do not work in certain zones if not mcl_worlds.clock_works(player:get_pos()) then diff --git a/mods/ITEMS/mcl_compass/init.lua b/mods/ITEMS/mcl_compass/init.lua index 8df1e6bbe..7e2f57e1d 100644 --- a/mods/ITEMS/mcl_compass/init.lua +++ b/mods/ITEMS/mcl_compass/init.lua @@ -4,7 +4,8 @@ mcl_compass = {} local compass_frames = 32 -local default_spawn_settings = minetest.settings:get("static_spawnpoint") +--Not sure spawn point should be dymanic (is it in mc?) +--local default_spawn_settings = minetest.settings:get("static_spawnpoint") -- Timer for random compass spinning local random_timer = 0 @@ -84,7 +85,9 @@ for i,img in ipairs(images) do if i == stereotype_frame then inv = 0 end - local use_doc, longdesc, usagehelp, tt + local use_doc, longdesc, tt + --Why is there no usage help? This should be fixed. + --local usagehelp use_doc = i == stereotype_frame if use_doc then tt = S("Points to the world origin") @@ -96,7 +99,7 @@ for i,img in ipairs(images) do _tt_help = tt, _doc_items_create_entry = use_doc, _doc_items_longdesc = longdesc, - _doc_items_usagehelp = usagehelp, + --_doc_items_usagehelp = usagehelp, inventory_image = img, wield_image = img, stack_max = 64, diff --git a/mods/ITEMS/mcl_core/crafting.lua b/mods/ITEMS/mcl_core/crafting.lua index f031c7ca2..cec26e747 100644 --- a/mods/ITEMS/mcl_core/crafting.lua +++ b/mods/ITEMS/mcl_core/crafting.lua @@ -4,7 +4,7 @@ -- Crafting definition -- -local craft_planks = function(output, input) +local function craft_planks(output, input) minetest.register_craft({ output = "mcl_core:"..output.."wood 4", recipe = { diff --git a/mods/ITEMS/mcl_core/craftitems.lua b/mods/ITEMS/mcl_core/craftitems.lua index 2428bb5ea..886535473 100644 --- a/mods/ITEMS/mcl_core/craftitems.lua +++ b/mods/ITEMS/mcl_core/craftitems.lua @@ -28,7 +28,6 @@ minetest.register_craftitem("mcl_core:coal_lump", { description = S("Coal"), _doc_items_longdesc = S("“Coal” refers to coal lumps obtained by digging coal ore which can be found underground. Coal is your standard furnace fuel, but it can also be used to make torches, coal blocks and a few other things."), _doc_items_hidden = false, - groups = { coal=1 }, inventory_image = "default_coal_lump.png", stack_max = 64, groups = { craftitem=1, coal=1 }, @@ -38,7 +37,6 @@ minetest.register_craftitem("mcl_core:charcoal_lump", { description = S("Charcoal"), _doc_items_longdesc = S("Charcoal is an alternative furnace fuel created by cooking wood in a furnace. It has the same burning time as coal and also shares many of its crafting recipes, but it can not be used to create coal blocks."), _doc_items_hidden = false, - groups = { coal=1 }, inventory_image = "mcl_core_charcoal.png", stack_max = 64, groups = { craftitem=1, coal=1 }, diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index 732c386b0..f66240b94 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -23,8 +23,8 @@ minetest.register_abm({ local lavatype = minetest.registered_nodes[node.name].liquidtype for w=1, #water do - local waternode = minetest.get_node(water[w]) - local watertype = minetest.registered_nodes[waternode.name].liquidtype + --local waternode = minetest.get_node(water[w]) + --local watertype = minetest.registered_nodes[waternode.name].liquidtype -- Lava on top of water: Water turns into stone if water[w].y < pos.y and water[w].x == pos.x and water[w].z == pos.z then minetest.set_node(water[w], {name="mcl_core:stone"}) @@ -53,7 +53,7 @@ minetest.register_abm({ -- -- Functions -mcl_core.grow_cactus = function(pos, node) +function mcl_core.grow_cactus(pos, node) pos.y = pos.y-1 local name = minetest.get_node(pos).name if minetest.get_item_group(name, "sand") ~= 0 then @@ -71,7 +71,7 @@ mcl_core.grow_cactus = function(pos, node) end end -mcl_core.grow_reeds = function(pos, node) +function mcl_core.grow_reeds(pos, node) pos.y = pos.y-1 local name = minetest.get_node(pos).name if minetest.get_item_group(name, "soil_sugarcane") ~= 0 then @@ -114,8 +114,8 @@ local function drop_attached_node(p) end -- Helper function for node actions for liquid flow -local liquid_flow_action = function(pos, group, action) - local check_detach = function(pos, xp, yp, zp) +local function liquid_flow_action(pos, group, action) + local function check_detach(pos, xp, yp, zp) local p = {x=pos.x+xp, y=pos.y+yp, z=pos.z+zp} local n = minetest.get_node_or_nil(p) if not n then @@ -336,13 +336,12 @@ end -- oak tree. function mcl_core.generate_tree(pos, tree_type, options) pos.y = pos.y-1 - local nodename = minetest.get_node(pos).name + --local nodename = minetest.get_node(pos).name pos.y = pos.y+1 if not minetest.get_node_light(pos) then return end - local node local two_by_two = options and options.two_by_two local balloon = options and options.balloon @@ -390,7 +389,7 @@ end function mcl_core.generate_v6_oak_tree(pos) local trunk = "mcl_core:tree" local leaves = "mcl_core:leaves" - local node = {name = ""} + local node for dy=1,4 do pos.y = pos.y+dy if minetest.get_node(pos).name ~= "air" then @@ -409,10 +408,10 @@ function mcl_core.generate_v6_oak_tree(pos) node = {name = leaves} pos.y = pos.y+3 - local rarity = 0 + --[[local rarity = 0 if math.random(0, 10) == 3 then rarity = 1 - end + end]] for dx=-2,2 do for dz=-2,2 do for dy=0,3 do @@ -595,13 +594,13 @@ function mcl_core.generate_v6_spruce_tree(pos) vm:write_to_map() end -mcl_core.generate_spruce_tree = function(pos) +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" minetest.place_schematic({ x = pos.x - 3, y = pos.y - 1, z = pos.z - 3 }, path, "0", nil, false) end -mcl_core.generate_huge_spruce_tree = function(pos) +function mcl_core.generate_huge_spruce_tree(pos) local r1 = math.random(1, 2) local r2 = math.random(1, 4) local path @@ -787,7 +786,6 @@ minetest.register_abm({ if pos == nil then return end - local can_change = false local above = {x=pos.x, y=pos.y+1, z=pos.z} local abovenode = minetest.get_node(above) if minetest.get_item_group(abovenode.name, "liquid") ~= 0 or minetest.get_item_group(abovenode.name, "opaque") == 1 then @@ -913,7 +911,7 @@ minetest.register_lbm({ -------------------------- local treelight = 9 -local sapling_grow_action = function(tree_id, soil_needed, one_by_one, two_by_two, sapling) +local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, sapling) return function(pos) local meta = minetest.get_meta(pos) if meta:get("grown") then return end @@ -955,7 +953,7 @@ local sapling_grow_action = function(tree_id, soil_needed, one_by_one, two_by_tw -- This sapling grows in a special way when there are 4 saplings in a 2×2 pattern if two_by_two then -- Check 8 surrounding saplings and try to find a 2×2 pattern - local is_sapling = function(pos, sapling) + local function is_sapling(pos, sapling) return minetest.get_node(pos).name == sapling end local p2 = {x=pos.x+1, y=pos.y, z=pos.z} @@ -1021,7 +1019,7 @@ local sapling_grow_action = function(tree_id, soil_needed, one_by_one, two_by_tw if one_by_one and check_tree_growth(pos, tree_id) then -- Single sapling minetest.set_node(pos, {name="air"}) - local r = math.random(1, 12) + --local r = math.random(1, 12) mcl_core.generate_tree(pos, tree_id) return end @@ -1042,7 +1040,7 @@ local grow_birch = sapling_grow_action(BIRCH_TREE_ID, 1, true, false) -- pos: Position -- node: Node table of the node at this position, from minetest.get_node -- Returns true on success and false on failure -mcl_core.grow_sapling = function(pos, node) +function mcl_core.grow_sapling(pos, node) local grow if node.name == "mcl_core:sapling" then grow = grow_oak @@ -1247,7 +1245,7 @@ minetest.register_abm({ end -- Add vines below pos (if empty) - local spread_down = function(origin, target, dir, node) + local function spread_down(origin, target, dir, node) if math.random(1, 2) == 1 then if minetest.get_node(target).name == "air" then minetest.add_node(target, {name = "mcl_core:vine", param2 = node.param2}) @@ -1256,7 +1254,7 @@ minetest.register_abm({ end -- Add vines above pos if it is backed up - local spread_up = function(origin, target, dir, node) + local function spread_up(origin, target, dir, node) local vines_in_area = minetest.find_nodes_in_area({x=origin.x-4, y=origin.y-1, z=origin.z-4}, {x=origin.x+4, y=origin.y+1, z=origin.z+4}, "mcl_core:vine") -- Less then 4 vines blocks around the ticked vines block (remember the ticked block is counted by above function as well) if #vines_in_area < 5 then @@ -1275,7 +1273,7 @@ minetest.register_abm({ end end - local spread_horizontal = function(origin, target, dir, node) + local function spread_horizontal(origin, target, dir, node) local vines_in_area = minetest.find_nodes_in_area({x=origin.x-4, y=origin.y-1, z=origin.z-4}, {x=origin.x+4, y=origin.y+1, z=origin.z+4}, "mcl_core:vine") -- Less then 4 vines blocks around the ticked vines block (remember the ticked block is counted by above function as well) if #vines_in_area < 5 then @@ -1312,7 +1310,7 @@ minetest.register_abm({ }) -- Returns true of the node supports vines -mcl_core.supports_vines = function(nodename) +function mcl_core.supports_vines(nodename) local def = minetest.registered_nodes[nodename] -- Rules: 1) walkable 2) full cube return def.walkable and @@ -1418,7 +1416,7 @@ minetest.register_abm({ for s=1, #surround do local spos = vector.add(p0, surround[s]) local maybe_vine = minetest.get_node(spos) - local surround_inverse = vector.multiply(surround[s], -1) + --local surround_inverse = vector.multiply(surround[s], -1) if maybe_vine.name == "mcl_core:vine" and (not mcl_core.check_vines_supported(spos, maybe_vine)) then minetest.remove_node(spos) vinedecay_particles(spos, maybe_vine) @@ -1532,7 +1530,7 @@ end -- -- The snowable nodes also MUST have _mcl_snowed defined to contain the name -- of the snowed node. -mcl_core.register_snowed_node = function(itemstring_snowed, itemstring_clear, tiles, sounds, clear_colorization, desc) +function mcl_core.register_snowed_node(itemstring_snowed, itemstring_clear, tiles, sounds, clear_colorization, desc) local def = table.copy(minetest.registered_nodes[itemstring_clear]) local create_doc_alias if def.description then @@ -1595,7 +1593,7 @@ end -- Reverts a snowed dirtlike node at pos to its original snow-less form. -- This function assumes there is no snow cover node above. This function -- MUST NOT be called if there is a snow cover node above pos. -mcl_core.clear_snow_dirt = function(pos, node) +function mcl_core.clear_snow_dirt(pos, node) local def = minetest.registered_nodes[node.name] if def._mcl_snowless then minetest.swap_node(pos, {name = def._mcl_snowless, param2=node.param2}) @@ -1607,7 +1605,7 @@ end -- on_construct -- Makes constructed snowable node snowed if placed below a snow cover node. -mcl_core.on_snowable_construct = function(pos) +function mcl_core.on_snowable_construct(pos) -- Myself local node = minetest.get_node(pos) @@ -1635,7 +1633,7 @@ end -- on_construct -- Makes snowable node below snowed. -mcl_core.on_snow_construct = function(pos) +function mcl_core.on_snow_construct(pos) local npos = {x=pos.x, y=pos.y-1, z=pos.z} local node = minetest.get_node(npos) local def = minetest.registered_nodes[node.name] @@ -1645,7 +1643,7 @@ mcl_core.on_snow_construct = function(pos) end -- after_destruct -- Clears snowed dirtlike node below. -mcl_core.after_snow_destruct = function(pos) +function mcl_core.after_snow_destruct(pos) local nn = minetest.get_node(pos).name -- No-op if snow was replaced with snow if minetest.get_item_group(nn, "snow_cover") == 1 then diff --git a/mods/ITEMS/mcl_core/nodes_base.lua b/mods/ITEMS/mcl_core/nodes_base.lua index 4477f0377..9baa6c33e 100644 --- a/mods/ITEMS/mcl_core/nodes_base.lua +++ b/mods/ITEMS/mcl_core/nodes_base.lua @@ -86,7 +86,7 @@ minetest.register_node("mcl_core:stone_with_gold", { }) local redstone_timer = 68.28 -local redstone_ore_activate = function(pos) +local function redstone_ore_activate(pos) minetest.swap_node(pos, {name="mcl_core:stone_with_redstone_lit"}) local t = minetest.get_node_timer(pos) t:start(redstone_timer) @@ -124,7 +124,7 @@ minetest.register_node("mcl_core:stone_with_redstone", { } }) -local redstone_ore_reactivate = function(pos) +local function redstone_ore_reactivate(pos) local t = minetest.get_node_timer(pos) t:start(redstone_timer) end @@ -864,7 +864,7 @@ minetest.register_node("mcl_core:packed_ice", { -- Frosted Ice (4 nodes) for i=0,3 do local ice = {} - ice.increase_age = function(pos, ice_near, first_melt) + function ice.increase_age(pos, ice_near, first_melt) -- Increase age of frosted age or turn to water source if too old local nn = minetest.get_node(pos).name local age = tonumber(string.sub(nn, -1)) @@ -990,9 +990,8 @@ for i=1,8 do local itemcount = itemstack:get_count() local fakestack = ItemStack(itemstring.." "..itemcount) fakestack:set_name("mcl_core:snow_"..math.min(8, (i+g))) - local success - itemstack, success = minetest.item_place(fakestack, placer, pointed_thing) - minetest.sound_play(mcl_sounds.node_sound_snow_defaults().place, {pos = below}, true) + itemstack = minetest.item_place(fakestack, placer, pointed_thing) + minetest.sound_play(mcl_sounds.node_sound_snow_defaults().place, {pos = pointed_thing.under}, true) itemstack:set_name(itemstring) return itemstack end diff --git a/mods/ITEMS/mcl_core/nodes_climb.lua b/mods/ITEMS/mcl_core/nodes_climb.lua index d9ecd76d3..ad861b4f2 100644 --- a/mods/ITEMS/mcl_core/nodes_climb.lua +++ b/mods/ITEMS/mcl_core/nodes_climb.lua @@ -1,7 +1,7 @@ -- Climbable nodes local S = minetest.get_translator("mcl_core") -local rotate_climbable = function(pos, node, user, mode) +local function rotate_climbable(pos, node, user, mode) if mode == screwdriver.ROTATE_FACE then local r = screwdriver.rotate.wallmounted(pos, node, mode) node.param2 = r @@ -120,7 +120,6 @@ minetest.register_node("mcl_core:vine", { local node = minetest.get_node(under) local def = minetest.registered_nodes[node.name] if not def then return itemstack end - local groups = def.groups -- Check special rightclick action of pointed node if def and def.on_rightclick then diff --git a/mods/ITEMS/mcl_core/nodes_glass.lua b/mods/ITEMS/mcl_core/nodes_glass.lua index 85bf614f4..8c12d8b93 100644 --- a/mods/ITEMS/mcl_core/nodes_glass.lua +++ b/mods/ITEMS/mcl_core/nodes_glass.lua @@ -20,7 +20,7 @@ minetest.register_node("mcl_core:glass", { }) ------------------------ --- Create Color Glass -- +-- Create Color Glass -- ------------------------ local canonical_color = "yellow" function mcl_core.add_stained_glass(desc, recipeitem, colorgroup, color) @@ -54,7 +54,7 @@ function mcl_core.add_stained_glass(desc, recipeitem, colorgroup, color) _mcl_hardness = 0.3, _mcl_silk_touch_drop = true, }) - + minetest.register_craft({ output = 'mcl_core:glass_'..color..' 8', recipe = { diff --git a/mods/ITEMS/mcl_core/nodes_liquid.lua b/mods/ITEMS/mcl_core/nodes_liquid.lua index c49b685eb..42276685e 100644 --- a/mods/ITEMS/mcl_core/nodes_liquid.lua +++ b/mods/ITEMS/mcl_core/nodes_liquid.lua @@ -3,7 +3,10 @@ local S = minetest.get_translator("mcl_core") local N = function(s) return s end -local WATER_ALPHA = 179 +local vector = vector +local math = math + +--local WATER_ALPHA = 179 local WATER_VISC = 1 local LAVA_VISC = 7 local LIGHT_LAVA = minetest.LIGHT_MAX @@ -209,13 +212,13 @@ S("• When lava is directly above water, the water turns into stone."), _mcl_hardness = -1, }) -local emit_lava_particle = function(pos) +local function emit_lava_particle(pos) local node = minetest.get_node(pos) if minetest.get_item_group(node.name, "lava_source") == 0 then return end local ppos = vector.add(pos, { x = math.random(-7, 7)/16, y = 0.45, z = math.random(-7, 7)/16}) - local spos = vector.add(ppos, { x = 0, y = -0.2, z = 0 }) + --local spos = vector.add(ppos, { x = 0, y = -0.2, z = 0 }) local vel = { x = math.random(-3, 3)/10, y = math.random(4, 7), z = math.random(-3, 3)/10 } local acc = { x = 0, y = -9.81, z = 0 } -- Lava droplet diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 8b36f0696..a8188350a 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -31,7 +31,7 @@ minetest.register_node("mcl_core:slimeblock", { node_box = { type = "fixed", fixed = { - {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25}, + {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25}, {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, } }, @@ -39,7 +39,6 @@ minetest.register_node("mcl_core:slimeblock", { type = "regular", }, tiles = {"mcl_core_slime.png"}, - paramtype = "light", use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "blend" or true, stack_max = 64, -- According to Minecraft Wiki, bouncing off a slime block from a height off 255 blocks should result in a bounce height of 50 blocks @@ -213,7 +212,7 @@ minetest.register_node("mcl_core:barrier", { -- Same as barrier, but non-pointable. This node is only to be used internally to separate realms. -- It must NOT be used for anything else. -- This node only exists because Minetest does not have support for “dimensions” yet and needs to --- be removed when support for this is implemented. +-- be removed when support for this is implemented. minetest.register_node("mcl_core:realm_barrier", { description = S("Realm Barrier"), _doc_items_create_entry = false, diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index 801810dbd..a72935f05 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -8,7 +8,7 @@ if mod_screwdriver then end -- Register tree trunk (wood) and bark -local register_tree_trunk = function(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark, stripped_varient) +local function register_tree_trunk(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark, stripped_varient) minetest.register_node("mcl_core:"..subname, { description = description_trunk, _doc_items_longdesc = longdesc, @@ -81,7 +81,7 @@ local register_stripped_trunk = function(subname, description_stripped_trunk, de _mcl_blast_resistance = 2, _mcl_hardness = 2, }) - + minetest.register_craft({ output = "mcl_core:"..subname.."_bark 3", recipe = { @@ -91,7 +91,7 @@ local register_stripped_trunk = function(subname, description_stripped_trunk, de }) end -local register_wooden_planks = function(subname, description, tiles) +local function register_wooden_planks(subname, description, tiles) minetest.register_node("mcl_core:"..subname, { description = description, _doc_items_longdesc = doc.sub.items.temp.build, @@ -106,14 +106,13 @@ local register_wooden_planks = function(subname, description, tiles) }) end -local register_leaves = function(subname, description, longdesc, tiles, sapling, drop_apples, sapling_chances, leafdecay_distance) - local drop +local function register_leaves(subname, description, longdesc, tiles, sapling, drop_apples, sapling_chances, leafdecay_distance) if leafdecay_distance == nil then leafdecay_distance = 4 end local apple_chances = {200, 180, 160, 120, 40} local stick_chances = {50, 45, 30, 35, 10} - + local function get_drops(fortune_level) local drop = { max_items = 1, @@ -174,7 +173,7 @@ local register_leaves = function(subname, description, longdesc, tiles, sapling, }) end -local register_sapling = function(subname, description, longdesc, tt_help, texture, selbox) +local function register_sapling(subname, description, longdesc, tt_help, texture, selbox) minetest.register_node("mcl_core:"..subname, { description = description, _tt_help = tt_help, diff --git a/mods/ITEMS/mcl_doors/api_trapdoors.lua b/mods/ITEMS/mcl_doors/api_trapdoors.lua index c8f769c67..3999ad0bf 100644 --- a/mods/ITEMS/mcl_doors/api_trapdoors.lua +++ b/mods/ITEMS/mcl_doors/api_trapdoors.lua @@ -98,13 +98,11 @@ function mcl_doors:register_trapdoor(name, def) if not usagehelp and not def.only_redstone_can_open then usagehelp = S("To open or close this trapdoor, rightclick it or send a redstone signal to it.") end - if not tt_help then - if def.only_redstone_can_open then - tt_help = S("Openable by redstone power") - else - tt_help = S("Openable by players and redstone power") - end - end + if def.only_redstone_can_open then + tt_help = S("Openable by redstone power") + else + tt_help = S("Openable by players and redstone power") + end -- Closed trapdoor @@ -164,7 +162,7 @@ function mcl_doors:register_trapdoor(name, def) local fpos = get_fpos(placer, pointed_thing) - local origname = itemstack:get_name() + --local origname = itemstack:get_name() if p0.y - 1 == p1.y or (fpos > 0 and fpos < 0.5) or (fpos < -0.5 and fpos > -0.999999999) then param2 = param2 + 20 diff --git a/mods/ITEMS/mcl_dye/init.lua b/mods/ITEMS/mcl_dye/init.lua index 2897e96ec..863abd3d2 100644 --- a/mods/ITEMS/mcl_dye/init.lua +++ b/mods/ITEMS/mcl_dye/init.lua @@ -327,7 +327,7 @@ minetest.register_craftitem("mcl_dye:white", { _doc_items_usagehelp = S("Rightclick a sheep to turn its wool white. Rightclick a plant to speed up its growth. Note that not all plants can be fertilized like this. When you rightclick a grass block, tall grass and flowers will grow all over the place."), stack_max = 64, groups = dyelocal.dyes[1][4], - on_place = function(itemstack, user, pointed_thing) + on_place = function(itemstack, user, pointed_thing) -- Use pointed node's on_rightclick function first, if present local node = minetest.get_node(pointed_thing.under) if user and not user:get_player_control().sneak then diff --git a/mods/ITEMS/mcl_enchanting/engine.lua b/mods/ITEMS/mcl_enchanting/engine.lua index 89fdc393d..d2db2281a 100644 --- a/mods/ITEMS/mcl_enchanting/engine.lua +++ b/mods/ITEMS/mcl_enchanting/engine.lua @@ -7,7 +7,7 @@ end function mcl_enchanting.get_enchantments(itemstack) if not itemstack then - return({}) + return {} end return minetest.deserialize(itemstack:get_meta():get_string("mcl_enchanting:enchantments")) or {} end @@ -250,7 +250,7 @@ local function get_after_use_callback(itemdef) itemstack:add_wear(digparams.wear) end - local enchantments = mcl_enchanting.get_enchantments(itemstack) + --local enchantments = mcl_enchanting.get_enchantments(itemstack) mcl_enchanting.update_groupcaps(itemstack) end end @@ -292,7 +292,7 @@ end function mcl_enchanting.get_possible_enchantments(itemstack, enchantment_level, treasure) local possible_enchantments, weights, accum_weight = {}, {}, 0 for enchantment, enchantment_def in pairs(mcl_enchanting.enchantments) do - local supported, _, _, primary = mcl_enchanting.can_enchant(itemstack, enchantment, 1) + local _, _, _, primary = mcl_enchanting.can_enchant(itemstack, enchantment, 1) if primary or treasure then table.insert(possible_enchantments, enchantment) accum_weight = accum_weight + enchantment_def.weight diff --git a/mods/ITEMS/mcl_enchanting/init.lua b/mods/ITEMS/mcl_enchanting/init.lua index 26fd5e19d..06f9b0f75 100644 --- a/mods/ITEMS/mcl_enchanting/init.lua +++ b/mods/ITEMS/mcl_enchanting/init.lua @@ -1,6 +1,9 @@ local modpath = minetest.get_modpath("mcl_enchanting") local S = minetest.get_translator("mcl_enchanting") +local math = math +local vector = vector + mcl_enchanting = { book_offset = vector.new(0, 0.75, 0), book_animations = {["close"] = 1, ["opening"] = 2, ["open"] = 3, ["closing"] = 4}, @@ -122,7 +125,7 @@ minetest.register_chatcommand("forceenchant", { return false, S("Player '@1' cannot be found.", target_name) end local itemstack = target:get_wielded_item() - local can_enchant, errorstring, extra_info = mcl_enchanting.can_enchant(itemstack, enchantment, level) + local _, errorstring = mcl_enchanting.can_enchant(itemstack, enchantment, level) if errorstring == "enchantment invalid" then return false, S("There is no such enchantment '@1'.", enchantment) elseif errorstring == "item missing" then @@ -242,9 +245,9 @@ minetest.register_node("mcl_enchanting:table", { on_rotate = rotate, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) local player_meta = clicker:get_meta() - local table_meta = minetest.get_meta(pos) - local num_bookshelves = table_meta:get_int("mcl_enchanting:num_bookshelves") - local table_name = table_meta:get_string("name") + --local table_meta = minetest.get_meta(pos) + --local num_bookshelves = table_meta:get_int("mcl_enchanting:num_bookshelves") + local table_name = minetest.get_meta(pos):get_string("name") if table_name == "" then table_name = S("Enchant") end diff --git a/mods/ITEMS/mcl_end/chorus_plant.lua b/mods/ITEMS/mcl_end/chorus_plant.lua index 597842867..0e35ff286 100644 --- a/mods/ITEMS/mcl_end/chorus_plant.lua +++ b/mods/ITEMS/mcl_end/chorus_plant.lua @@ -29,7 +29,7 @@ local no_detach = {} -- This detaches all chorus plants that are/were attached -- at start_pos. -mcl_end.detach_chorus_plant = function(start_pos, digger) +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 @@ -106,11 +106,11 @@ mcl_end.detach_chorus_plant = function(start_pos, digger) no_detach = {} end -mcl_end.check_detach_chorus_plant = function(pos, oldnode, oldmetadata, digger) +function mcl_end.check_detach_chorus_plant(pos, oldnode, oldmetadata, digger) mcl_end.detach_chorus_plant(pos, digger) end -mcl_end.check_blast_chorus_plant = function(pos) +function mcl_end.check_blast_chorus_plant(pos) minetest.remove_node(pos) mcl_end.detach_chorus_plant(pos) end @@ -139,7 +139,7 @@ minetest.register_node("mcl_end:chorus_flower", { node_placement_prediction = "", on_place = function(itemstack, placer, pointed_thing) local node_under = minetest.get_node(pointed_thing.under) - local node_above = minetest.get_node(pointed_thing.above) + --local node_above = minetest.get_node(pointed_thing.above) if placer and not placer:get_player_control().sneak then -- Use pointed node's on_rightclick function first, if present if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then @@ -309,7 +309,7 @@ minetest.register_node("mcl_end:chorus_plant", { }) -- Grow a complete chorus plant at pos -mcl_end.grow_chorus_plant = function(pos, node, pr) +function mcl_end.grow_chorus_plant(pos, node, pr) local flowers = { pos } -- Plant initial flower (if it isn't there already) if not node then @@ -340,7 +340,7 @@ end -- Grow a single step of a chorus plant at pos. -- Pos must be a chorus flower. -mcl_end.grow_chorus_plant_step = function(pos, node, pr) +function mcl_end.grow_chorus_plant_step(pos, node, pr) local new_flower_buds = {} local above = { x = pos.x, y = pos.y + 1, z = pos.z } local node_above = minetest.get_node(above) @@ -408,7 +408,6 @@ mcl_end.grow_chorus_plant_step = function(pos, node, pr) elseif branching == true then branches = pr:next(0, 3) end - local branch_grown = false for b=1, branches do local next_branch = pr:next(1, #around) local branch = vector.add(pos, around[next_branch]) @@ -451,6 +450,8 @@ mcl_end.grow_chorus_plant_step = function(pos, node, pr) end --- ABM --- +local seed = minetest.get_mapgen_params().seed +local pr = PseudoRandom(seed) minetest.register_abm({ label = "Chorus plant growth", nodenames = { "mcl_end:chorus_flower" }, diff --git a/mods/ITEMS/mcl_end/end_crystal.lua b/mods/ITEMS/mcl_end/end_crystal.lua index 78fcc0e21..a188be383 100644 --- a/mods/ITEMS/mcl_end/end_crystal.lua +++ b/mods/ITEMS/mcl_end/end_crystal.lua @@ -1,5 +1,7 @@ local S = minetest.get_translator("mcl_end") +local vector = vector + local explosion_strength = 6 local directions = { @@ -45,7 +47,7 @@ local function set_crystal_animation(self) end local function spawn_crystal(pos) - local crystal = minetest.add_entity(pos, "mcl_end:crystal") + minetest.add_entity(pos, "mcl_end:crystal") if not vector.equals(pos, vector.floor(pos)) then return end if mcl_worlds.pos_to_dimension(pos) ~= "end" then return end local portal_center diff --git a/mods/ITEMS/mcl_farming/shared_functions.lua b/mods/ITEMS/mcl_farming/shared_functions.lua index c4cb2fd71..025894a11 100644 --- a/mods/ITEMS/mcl_farming/shared_functions.lua +++ b/mods/ITEMS/mcl_farming/shared_functions.lua @@ -161,7 +161,7 @@ function mcl_farming:place_seed(itemstack, placer, pointed_thing, plantname) if string.find(farmland.name, "mcl_farming:soil") and string.find(place_s.name, "air") then minetest.sound_play(minetest.registered_nodes[plantname].sounds.place, {pos = pos}, true) minetest.add_node(pos, {name=plantname, param2 = minetest.registered_nodes[plantname].place_param2}) - local intervals_counter = get_intervals_counter(pos, 1, 1) + --local intervals_counter = get_intervals_counter(pos, 1, 1) else return end @@ -190,7 +190,7 @@ end function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, stem_itemstring, stem_def, stem_drop, gourd_itemstring, gourd_def, grow_interval, grow_chance, connected_stem_texture, gourd_on_construct_extra) - local connected_stem_names = { + local connected_stem_names = { connected_stem_basename .. "_r", connected_stem_basename .. "_l", connected_stem_basename .. "_t", diff --git a/mods/ITEMS/mcl_fences/init.lua b/mods/ITEMS/mcl_fences/init.lua index e60782215..ddd85d470 100644 --- a/mods/ITEMS/mcl_fences/init.lua +++ b/mods/ITEMS/mcl_fences/init.lua @@ -20,7 +20,7 @@ local cz2 = {-2/16, -0.5, 2/16, 2/16, 1.01, 0.5} --unten(quer) z mcl_fences = {} -mcl_fences.register_fence = function(id, fence_name, texture, groups, hardness, blast_resistance, connects_to, sounds) +function mcl_fences.register_fence(id, fence_name, texture, groups, hardness, blast_resistance, connects_to, sounds) local cgroups = table.copy(groups) if cgroups == nil then cgroups = {} end cgroups.fence = 1 @@ -72,7 +72,7 @@ mcl_fences.register_fence = function(id, fence_name, texture, groups, hardness, return fence_id end -mcl_fences.register_fence_gate = function(id, fence_gate_name, texture, groups, hardness, blast_resistance, sounds, sound_open, sound_close, sound_gain_open, sound_gain_close) +function mcl_fences.register_fence_gate(id, fence_gate_name, texture, groups, hardness, blast_resistance, sounds, sound_open, sound_close, sound_gain_open, sound_gain_close) local meta2 local state2 = 0 diff --git a/mods/ITEMS/mcl_fire/init.lua b/mods/ITEMS/mcl_fire/init.lua index 86a1509e6..b4e7b404a 100644 --- a/mods/ITEMS/mcl_fire/init.lua +++ b/mods/ITEMS/mcl_fire/init.lua @@ -536,7 +536,7 @@ end -- * pointed_thing: Pointed thing to ignite -- * player: Player who sets fire or nil if nobody -- * allow_on_fire: If false, can't ignite fire on fire (default: true) -mcl_fire.set_fire = function(pointed_thing, player, allow_on_fire) +function mcl_fire.set_fire(pointed_thing, player, allow_on_fire) local pname if player == nil then pname = "" diff --git a/mods/ITEMS/mcl_fireworks/register.lua b/mods/ITEMS/mcl_fireworks/register.lua index 6ab55442c..c441254cb 100644 --- a/mods/ITEMS/mcl_fireworks/register.lua +++ b/mods/ITEMS/mcl_fireworks/register.lua @@ -1,7 +1,5 @@ local S = minetest.get_translator("mcl_fireworks") -local player_rocketing = {} - 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 76526ee72..567e96e96 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -2,6 +2,8 @@ local S = minetest.get_translator("mcl_fishing") +local math = math + local bobber_ENTITY={ physical = false, timer=0, @@ -31,143 +33,141 @@ local fish = function(itemstack, player, pointed_thing) end end - local pos = player:get_pos() + local pos = player:get_pos() - local objs = minetest.get_objects_inside_radius(pos, 125) - local num = 0 - local ent = nil - local noent = true - - local durability = 65 - local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking") - if unbreaking > 0 then - durability = durability * (unbreaking + 1) - end + local objs = minetest.get_objects_inside_radius(pos, 125) + local ent + local noent = false - --Check for bobber if so handle. - for n = 1, #objs do - ent = objs[n]:get_luaentity() - if ent then - if ent.player and ent.objtype=="fishing" then - if (player:get_player_name() == ent.player) then - noent = false - if ent._dive == true then - local itemname - local items - local itemcount = 1 - local pr = PseudoRandom(os.time() * math.random(1, 100)) - local r = pr:next(1, 100) - local fish_values = {85, 84.8, 84.7, 84.5} - local junk_values = {10, 8.1, 6.1, 4.2} - local luck_of_the_sea = math.min(mcl_enchanting.get_enchantment(itemstack, "luck_of_the_sea"), 3) - local index = luck_of_the_sea + 1 - local fish_value = fish_values[index] - local junk_value = junk_values[index] + fish_value - if r <= fish_value then - -- Fish - items = mcl_loot.get_loot({ - items = { - { itemstring = "mcl_fishing:fish_raw", weight = 60 }, - { itemstring = "mcl_fishing:salmon_raw", weight = 25 }, - { itemstring = "mcl_fishing:clownfish_raw", weight = 2 }, - { itemstring = "mcl_fishing:pufferfish_raw", weight = 13 }, - } - }, pr) - elseif r <= junk_value then - -- Junk - items = mcl_loot.get_loot({ - items = { - { itemstring = "mcl_core:bowl", weight = 10 }, - { itemstring = "mcl_fishing:fishing_rod", weight = 2, wear_min = 6554, wear_max = 65535 }, -- 10%-100% damage - { itemstring = "mcl_mobitems:leather", weight = 10 }, - { itemstring = "mcl_armor:boots_leather", weight = 10, wear_min = 6554, wear_max = 65535 }, -- 10%-100% damage - { itemstring = "mcl_mobitems:rotten_flesh", weight = 10 }, - { itemstring = "mcl_core:stick", weight = 5 }, - { itemstring = "mcl_mobitems:string", weight = 5 }, - { itemstring = "mcl_potions:water", weight = 10 }, - { itemstring = "mcl_mobitems:bone", weight = 10 }, - { itemstring = "mcl_dye:black", weight = 1, amount_min = 10, amount_max = 10 }, - { itemstring = "mcl_mobitems:string", weight = 10 }, -- TODO: Tripwire Hook - } - }, pr) - else - -- Treasure - items = mcl_loot.get_loot({ - items = { - -- TODO: Enchanted Bow - { itemstring = "mcl_bows:bow", wear_min = 49144, wear_max = 65535 }, -- 75%-100% damage - { itemstack = mcl_enchanting.get_randomly_enchanted_book(30, true, true)}, - -- TODO: Enchanted Fishing Rod - { itemstring = "mcl_fishing:fishing_rod", wear_min = 49144, wear_max = 65535 }, -- 75%-100% damage - { itemstring = "mcl_mobs:nametag", }, - { itemstring = "mcl_mobitems:saddle", }, - { itemstring = "mcl_flowers:waterlily", }, - } - }, pr) - end - local item - if #items >= 1 then - item = ItemStack(items[1]) - else - item = ItemStack() - end - local inv = player:get_inventory() - if inv:room_for_item("main", item) then - inv:add_item("main", item) - else - minetest.add_item(pos, item) - end - if mcl_experience.throw_experience then - mcl_experience.throw_experience(pos, math.random(1,6)) - end + local durability = 65 + local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking") + if unbreaking > 0 then + durability = durability * (unbreaking + 1) + end - if not minetest.is_creative_enabled(player:get_player_name()) then - local idef = itemstack:get_definition() - itemstack:add_wear(65535/durability) -- 65 uses - if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then - minetest.sound_play(idef.sound.breaks, {pos=player:get_pos(), gain=0.5}, true) - end + --Check for bobber if so handle. + for n = 1, #objs do + ent = objs[n]:get_luaentity() + if ent then + if ent.player and ent.objtype=="fishing" then + if (player:get_player_name() == ent.player) then + if ent._dive == true then + local items + local pr = PseudoRandom(os.time() * math.random(1, 100)) + local r = pr:next(1, 100) + local fish_values = {85, 84.8, 84.7, 84.5} + local junk_values = {10, 8.1, 6.1, 4.2} + local luck_of_the_sea = math.min(mcl_enchanting.get_enchantment(itemstack, "luck_of_the_sea"), 3) + local index = luck_of_the_sea + 1 + local fish_value = fish_values[index] + local junk_value = junk_values[index] + fish_value + if r <= fish_value then + -- Fish + items = mcl_loot.get_loot({ + items = { + { itemstring = "mcl_fishing:fish_raw", weight = 60 }, + { itemstring = "mcl_fishing:salmon_raw", weight = 25 }, + { itemstring = "mcl_fishing:clownfish_raw", weight = 2 }, + { itemstring = "mcl_fishing:pufferfish_raw", weight = 13 }, + } + }, pr) + elseif r <= junk_value then + -- Junk + items = mcl_loot.get_loot({ + items = { + { itemstring = "mcl_core:bowl", weight = 10 }, + { itemstring = "mcl_fishing:fishing_rod", weight = 2, wear_min = 6554, wear_max = 65535 }, -- 10%-100% damage + { itemstring = "mcl_mobitems:leather", weight = 10 }, + { itemstring = "mcl_armor:boots_leather", weight = 10, wear_min = 6554, wear_max = 65535 }, -- 10%-100% damage + { itemstring = "mcl_mobitems:rotten_flesh", weight = 10 }, + { itemstring = "mcl_core:stick", weight = 5 }, + { itemstring = "mcl_mobitems:string", weight = 5 }, + { itemstring = "mcl_potions:water", weight = 10 }, + { itemstring = "mcl_mobitems:bone", weight = 10 }, + { itemstring = "mcl_dye:black", weight = 1, amount_min = 10, amount_max = 10 }, + { itemstring = "mcl_mobitems:string", weight = 10 }, -- TODO: Tripwire Hook + } + }, pr) + else + -- Treasure + items = mcl_loot.get_loot({ + items = { + -- TODO: Enchanted Bow + { itemstring = "mcl_bows:bow", wear_min = 49144, wear_max = 65535 }, -- 75%-100% damage + { itemstack = mcl_enchanting.get_randomly_enchanted_book(30, true, true)}, + -- TODO: Enchanted Fishing Rod + { itemstring = "mcl_fishing:fishing_rod", wear_min = 49144, wear_max = 65535 }, -- 75%-100% damage + { itemstring = "mcl_mobs:nametag", }, + { itemstring = "mcl_mobitems:saddle", }, + { itemstring = "mcl_flowers:waterlily", }, + } + }, pr) + end + local item + if #items >= 1 then + item = ItemStack(items[1]) + else + item = ItemStack() + end + local inv = player:get_inventory() + if inv:room_for_item("main", item) then + inv:add_item("main", item) + else + minetest.add_item(pos, item) + end + if mcl_experience.throw_experience then + mcl_experience.throw_experience(pos, math.random(1,6)) + end + + if not minetest.is_creative_enabled(player:get_player_name()) then + local idef = itemstack:get_definition() + itemstack:add_wear(65535/durability) -- 65 uses + if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then + minetest.sound_play(idef.sound.breaks, {pos=player:get_pos(), gain=0.5}, true) end end - --Check if object is on land. - local epos = ent.object:get_pos() - epos.y = math.floor(epos.y) - local node = minetest.get_node(epos) - local def = minetest.registered_nodes[node.name] - if def.walkable then - if not minetest.is_creative_enabled(player:get_player_name()) then - local idef = itemstack:get_definition() - itemstack:add_wear((65535/durability)*2) -- if so and not creative then wear double like in MC. - if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then - minetest.sound_play(idef.sound.breaks, {pos=player:get_pos(), gain=0.5}, true) - end - end - end - --Destroy bobber. - ent.object:remove() - return itemstack end + --Check if object is on land. + local epos = ent.object:get_pos() + epos.y = math.floor(epos.y) + local node = minetest.get_node(epos) + local def = minetest.registered_nodes[node.name] + if def.walkable then + if not minetest.is_creative_enabled(player:get_player_name()) then + local idef = itemstack:get_definition() + itemstack:add_wear((65535/durability)*2) -- if so and not creative then wear double like in MC. + if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then + minetest.sound_play(idef.sound.breaks, {pos=player:get_pos(), gain=0.5}, true) + end + end + end + --Destroy bobber. + ent.object:remove() + noent = false + break end end end - --Check for flying bobber. - for n = 1, #objs do - ent = objs[n]:get_luaentity() - if ent then - if ent._thrower and ent.objtype=="fishing" then - if player:get_player_name() == ent._thrower then - noent = false - break - end + end + --Check for flying bobber. + for n = 1, #objs do + ent = objs[n]:get_luaentity() + if ent then + if ent._thrower and ent.objtype=="fishing" then + if player:get_player_name() == ent._thrower then + noent = false + break end end end - --If no bobber or flying_bobber exists then throw bobber. - if noent == true then - local playerpos = player:get_pos() - local dir = player:get_look_dir() - mcl_throwing.throw("mcl_fishing:flying_bobber", {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, 15, player:get_player_name()) - end + end + --If no bobber or flying_bobber exists then throw bobber. + if noent then + local playerpos = player:get_pos() + local dir = player:get_look_dir() + mcl_throwing.throw("mcl_fishing:flying_bobber", {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, 15, player:get_player_name()) + end + return itemstack end -- Movement function of bobber @@ -305,7 +305,7 @@ local flying_bobber_ENTITY={ } -- Movement function of flying bobber -local flying_bobber_on_step = function(self, dtime) +local function flying_bobber_on_step(self, dtime) self.timer=self.timer+dtime local pos = self.object:get_pos() local node = minetest.get_node(pos) @@ -315,12 +315,9 @@ local flying_bobber_on_step = function(self, dtime) -- Destroy when hitting a solid node if self._lastpos.x~=nil then if (def and (def.walkable or def.liquidtype == "flowing" or def.liquidtype == "source")) or not def then - local make_child= function(object) - local ent = object:get_luaentity() - ent.player = self._thrower - ent.child = true - end - make_child(minetest.add_entity(self._lastpos, "mcl_fishing:bobber_entity")) + local ent = minetest.add_entity(self._lastpos, "mcl_fishing:bobber_entity"):get_luaentity() + ent.player = self._thrower + ent.child = true self.object:remove() return end @@ -334,13 +331,11 @@ minetest.register_entity("mcl_fishing:flying_bobber_entity", flying_bobber_ENTIT mcl_throwing.register_throwable_object("mcl_fishing:flying_bobber", "mcl_fishing:flying_bobber_entity", 5) --- If player leaves area, remove bobber. -minetest.register_on_leaveplayer(function(player) +local function remove_bobber(player) local objs = minetest.get_objects_inside_radius(player:get_pos(), 250) - local ent = nil - local noent = true + for n = 1, #objs do - ent = objs[n]:get_luaentity() + local ent = objs[n]:get_luaentity() if ent then if ent.player and ent.objtype=="fishing" then ent.object:remove() @@ -349,26 +344,13 @@ minetest.register_on_leaveplayer(function(player) end end end -end) +end + +-- If player leaves area, remove bobber. +minetest.register_on_leaveplayer(remove_bobber) -- If player dies, remove bobber. -minetest.register_on_dieplayer(function(player) - local objs = minetest.get_objects_inside_radius(player:get_pos(), 250) - local num = 0 - local ent = nil - local noent = true - - for n = 1, #objs do - ent = objs[n]:get_luaentity() - if ent then - if ent.player and ent.objtype=="fishing" then - ent.object:remove() - elseif ent._thrower and ent.objtype=="fishing" then - ent.object:remove() - end - end - end -end) +minetest.register_on_dieplayer(remove_bobber) -- Fishing Rod minetest.register_tool("mcl_fishing:fishing_rod", { diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index 7a2501f25..d07a125cb 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -180,12 +180,12 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im if not inv_img then inv_img = top_img end - local noncreative, create_entry, paramtype2, palette + local create_entry, paramtype2, palette if is_flower == nil then is_flower = true end - local bottom_groups = {flammable=2,fire_encouragement=60,fire_flammability=100, non_mycelium_plant=1,attached_node=1, dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1, plant=1,double_plant=1,deco_block=1,not_in_creative_inventory=noncreative} + local bottom_groups = {flammable=2, fire_encouragement=60, fire_flammability=100, non_mycelium_plant=1, attached_node=1, dig_by_water=1, destroy_by_lava_flow=1, dig_by_piston=1, plant=1, double_plant=1, deco_block=1} if is_flower then bottom_groups.flower = 1 bottom_groups.place_flowerlike = 1 @@ -200,7 +200,7 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im palette = "mcl_core_palette_grass.png" end if longdesc == nil then - noncreative = 1 + bottom_groups.not_in_creative_inventory = 1 create_entry = false end -- Drop itself by default diff --git a/mods/ITEMS/mcl_heads/init.lua b/mods/ITEMS/mcl_heads/init.lua index 0f41adb89..4bcee2279 100644 --- a/mods/ITEMS/mcl_heads/init.lua +++ b/mods/ITEMS/mcl_heads/init.lua @@ -91,7 +91,7 @@ local function addhead(name, texture, desc, longdesc, rangemob, rangefactor) local itemstring = itemstack:get_name() local fakestack = ItemStack(itemstack) - local idef = fakestack:get_definition() + --local idef = fakestack:get_definition() local retval if wdir == 0 or wdir == 1 then return minetest.item_place(itemstack, placer, pointed_thing) @@ -101,7 +101,7 @@ local function addhead(name, texture, desc, longdesc, rangemob, rangefactor) if not retval then return itemstack end - itemstack,_ = minetest.item_place(fakestack, placer, pointed_thing, wdir) + itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir) itemstack:set_name(itemstring) return itemstack end, diff --git a/mods/ITEMS/mcl_itemframes/init.lua b/mods/ITEMS/mcl_itemframes/init.lua index e0f9f9043..fbd4d545a 100644 --- a/mods/ITEMS/mcl_itemframes/init.lua +++ b/mods/ITEMS/mcl_itemframes/init.lua @@ -276,12 +276,12 @@ minetest.register_node("mcl_itemframes:item_frame",{ on_rotate = function(pos, node, user, mode, param2) if mode == screwdriver.ROTATE_FACE then -- Rotate face - local meta = minetest.get_meta(pos) + --local meta = minetest.get_meta(pos) local node = minetest.get_node(pos) local objs = nil if node.name == "mcl_itemframes:item_frame" then - objs = minetest.get_objects_inside_radius(pos, .5) + objs = minetest.get_objects_inside_radius(pos, 0.5) end if objs then for _, obj in ipairs(objs) do diff --git a/mods/ITEMS/mcl_jukebox/init.lua b/mods/ITEMS/mcl_jukebox/init.lua index 067848f50..249603b58 100644 --- a/mods/ITEMS/mcl_jukebox/init.lua +++ b/mods/ITEMS/mcl_jukebox/init.lua @@ -72,7 +72,6 @@ local function now_playing(player, name) active_huds[playername] = nil end end, {playername, id, hud_sequence_numbers[playername]}) - end minetest.register_on_leaveplayer(function(player) diff --git a/mods/ITEMS/mcl_maps/init.lua b/mods/ITEMS/mcl_maps/init.lua index cc3018be1..9d1eedc6c 100644 --- a/mods/ITEMS/mcl_maps/init.lua +++ b/mods/ITEMS/mcl_maps/init.lua @@ -5,7 +5,7 @@ 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 +--local last_finished_id = storage:get_int("next_id") - 1 minetest.mkdir(map_textures_path) diff --git a/mods/ITEMS/mcl_mobspawners/init.lua b/mods/ITEMS/mcl_mobspawners/init.lua index fe01f4c52..bd9d0c53a 100644 --- a/mods/ITEMS/mcl_mobspawners/init.lua +++ b/mods/ITEMS/mcl_mobspawners/init.lua @@ -1,11 +1,14 @@ local S = minetest.get_translator("mcl_mobspawners") +local math = math +local table = table + mcl_mobspawners = {} local default_mob = "mobs_mc:pig" -- Mob spawner -local spawner_default = default_mob.." 0 15 4 15" +--local spawner_default = default_mob.." 0 15 4 15" local function get_mob_textures(mob) local list = minetest.registered_entities[mob].texture_list @@ -160,7 +163,7 @@ local spawn_mobs = function(pos, elapsed) -- check objects inside 8×8 area around spawner local objs = minetest.get_objects_inside_radius(pos, 8) local count = 0 - local ent = nil + local ent local timer = minetest.get_node_timer(pos) diff --git a/mods/ITEMS/mcl_nether/lava.lua b/mods/ITEMS/mcl_nether/lava.lua index da85b8e3c..035a50322 100644 --- a/mods/ITEMS/mcl_nether/lava.lua +++ b/mods/ITEMS/mcl_nether/lava.lua @@ -1,12 +1,6 @@ -- Lava in the Nether -local S = minetest.get_translator("mcl_nether") -local N = function(s) return s end - -local msg = { - N("@1 has become one with the lava."), - N("@1 has been consumed by the lava."), -} +local S = minetest.get_translator(minetest.get_current_modname()) -- TODO: Increase flow speed. This could be done by reducing viscosity, -- but this would also allow players to swim faster in lava. @@ -20,7 +14,6 @@ lava_src_def._doc_items_usagehelp = nil lava_src_def.liquid_range = 7 lava_src_def.liquid_alternative_source = "mcl_nether:nether_lava_source" lava_src_def.liquid_alternative_flowing = "mcl_nether:nether_lava_flowing" -lava_src_def._mcl_node_death_message = msg, minetest.register_node("mcl_nether:nether_lava_source", lava_src_def) local lava_flow_def = table.copy(minetest.registered_nodes["mcl_core:lava_flowing"]) @@ -29,7 +22,6 @@ lava_flow_def._doc_items_create_entry = false lava_flow_def.liquid_range = 7 lava_flow_def.liquid_alternative_flowing = "mcl_nether:nether_lava_flowing" lava_flow_def.liquid_alternative_source = "mcl_nether:nether_lava_source" -lava_flow_def._mcl_node_death_message = msg, minetest.register_node("mcl_nether:nether_lava_flowing", lava_flow_def) -- Add entry aliases for the Help diff --git a/mods/ITEMS/mcl_nether/locale/mcl_nether.de.tr b/mods/ITEMS/mcl_nether/locale/mcl_nether.de.tr index bfa62488c..f81f381e2 100644 --- a/mods/ITEMS/mcl_nether/locale/mcl_nether.de.tr +++ b/mods/ITEMS/mcl_nether/locale/mcl_nether.de.tr @@ -38,5 +38,3 @@ Place this item on soul sand to plant it and watch it grow.=Platzieren Sie den G Burns your feet=Verbrennt Ihre Füße Grows on soul sand=Wächst auf Seelensand Reduces walking speed=Reduziert das Schritttempo -@1 has become one with the lava.=@1 wurde eins mit der Lava. -@1 has been consumed by the lava.=@1 wurde von der Lava verzehrt. diff --git a/mods/ITEMS/mcl_nether/locale/mcl_nether.fr.tr b/mods/ITEMS/mcl_nether/locale/mcl_nether.fr.tr index 11a046374..3e3583355 100644 --- a/mods/ITEMS/mcl_nether/locale/mcl_nether.fr.tr +++ b/mods/ITEMS/mcl_nether/locale/mcl_nether.fr.tr @@ -37,6 +37,4 @@ Nether warts are plants home to the Nether. They can be planted on soul sand and Place this item on soul sand to plant it and watch it grow.=Placez cet article sur du sable d'âme pour le planter et regardez-le grandir. Burns your feet=Vous brûle les pieds Grows on soul sand=Pousse sur le sable de l'âme -Reduces walking speed=Réduit la vitesse de marche -@1 has become one with the lava.=@1 est devenu un avec la lave. -@1 has been consumed by the lava.=@1 a été consumé par la lave. \ No newline at end of file +Reduces walking speed=Réduit la vitesse de marche \ No newline at end of file diff --git a/mods/ITEMS/mcl_nether/locale/mcl_nether.ru.tr b/mods/ITEMS/mcl_nether/locale/mcl_nether.ru.tr index 2cfdd370b..f546d16ca 100644 --- a/mods/ITEMS/mcl_nether/locale/mcl_nether.ru.tr +++ b/mods/ITEMS/mcl_nether/locale/mcl_nether.ru.tr @@ -38,5 +38,3 @@ Place this item on soul sand to plant it and watch it grow.=Поместите Burns your feet=Обжигает ваши ноги Grows on soul sand=Растёт на песке душ Reduces walking speed=Уменьшает скорость ходьбы -@1 has become one with the lava.=@1 породнился(лась) с лавой. -@1 has been consumed by the lava.=@1 был(а) поглощен(а) лавой. diff --git a/mods/ITEMS/mcl_nether/locale/template.txt b/mods/ITEMS/mcl_nether/locale/template.txt index 7b5052166..0e69ad520 100644 --- a/mods/ITEMS/mcl_nether/locale/template.txt +++ b/mods/ITEMS/mcl_nether/locale/template.txt @@ -37,6 +37,4 @@ Nether warts are plants home to the Nether. They can be planted on soul sand and Place this item on soul sand to plant it and watch it grow.= Burns your feet= Grows on soul sand= -Reduces walking speed= -@1 has become one with the lava.= -@1 has been consumed by the lava.= +Reduces walking speed= \ No newline at end of file diff --git a/mods/ITEMS/mcl_ocean/kelp.lua b/mods/ITEMS/mcl_ocean/kelp.lua index 326b08a81..fb6045e78 100644 --- a/mods/ITEMS/mcl_ocean/kelp.lua +++ b/mods/ITEMS/mcl_ocean/kelp.lua @@ -38,7 +38,7 @@ local mt_is_creative_enabled = minetest.is_creative_enabled local mt_sound_play = minetest.sound_play local math = math -local string = string +--local string = string local table = table -- DEBUG: functions @@ -422,7 +422,7 @@ end function kelp.surface_after_dig_node(pos, node) - return mt_set_node(pos, {name=registred_nodes[node.name].node_dig_prediction}) + return mt_set_node(pos, {name=minetest.registered_nodes[node.name].node_dig_prediction}) end @@ -759,7 +759,6 @@ minetest.register_craftitem("mcl_ocean:dried_kelp", { groups = { food = 2, eatable = 1 }, on_place = minetest.item_eat(1), on_secondary_use = minetest.item_eat(1), - groups = { food = 2, eatable = 1 }, _mcl_saturation = 0.6, }) diff --git a/mods/ITEMS/mcl_ocean/sea_pickle.lua b/mods/ITEMS/mcl_ocean/sea_pickle.lua index 45b934a92..067bb39a3 100644 --- a/mods/ITEMS/mcl_ocean/sea_pickle.lua +++ b/mods/ITEMS/mcl_ocean/sea_pickle.lua @@ -12,7 +12,7 @@ local function sea_pickle_on_place(itemstack, placer, pointed_thing) local node_under = minetest.get_node(pos_under) local node_above = minetest.get_node(pos_above) local def_under = minetest.registered_nodes[node_under.name] - local def_above = minetest.registered_nodes[node_above.name] + --local def_above = minetest.registered_nodes[node_above.name] if def_under and def_under.on_rightclick and not placer:get_player_control().sneak then return def_under.on_rightclick(pos_under, node_under, diff --git a/mods/ITEMS/mcl_ocean/seagrass.lua b/mods/ITEMS/mcl_ocean/seagrass.lua index 492205138..bd6400a32 100644 --- a/mods/ITEMS/mcl_ocean/seagrass.lua +++ b/mods/ITEMS/mcl_ocean/seagrass.lua @@ -105,7 +105,7 @@ for s=1, #surfaces do doc_longdesc = S("Seagrass grows inside water on top of dirt, sand or gravel.") desc = S("Seagrass") doc_create = true - doc_img = "mcl_ocean_seagrass.png" + doc_img = "mcl_ocean_seagrass.png^[verticalframe:12:0" else doc_create = false end @@ -113,7 +113,7 @@ for s=1, #surfaces do _doc_items_entry_name = desc, _doc_items_longdesc = doc_longdesc, _doc_items_create_entry = doc_create, - _doc_items_image = "mcl_ocean_seagrass.png^[verticalframe:12:0", + _doc_items_image = doc_img, drawtype = "plantlike_rooted", paramtype = "light", paramtype2 = "meshoptions", diff --git a/mods/ITEMS/mcl_portals/portal_end.lua b/mods/ITEMS/mcl_portals/portal_end.lua index 192f5001c..5b402bdc0 100644 --- a/mods/ITEMS/mcl_portals/portal_end.lua +++ b/mods/ITEMS/mcl_portals/portal_end.lua @@ -1,10 +1,14 @@ local S = minetest.get_translator("mcl_portals") --- Parameters -local SPAWN_MIN = mcl_vars.mg_end_min+70 -local SPAWN_MAX = mcl_vars.mg_end_min+98 +local table = table +local vector = vector +local math = math -local mg_name = minetest.get_mapgen_setting("mg_name") +-- Parameters +--local SPAWN_MIN = mcl_vars.mg_end_min+70 +--local SPAWN_MAX = mcl_vars.mg_end_min+98 + +--local mg_name = minetest.get_mapgen_setting("mg_name") local destroy_portal = function(pos) local neighbors = { @@ -196,7 +200,6 @@ function mcl_portals.end_teleport(obj, pos) end end - local platform build_end_portal_destination(platform_pos) check_and_build_end_portal_destination(platform_pos) diff --git a/mods/ITEMS/mcl_portals/portal_nether.lua b/mods/ITEMS/mcl_portals/portal_nether.lua index a121f719c..ec8e40d22 100644 --- a/mods/ITEMS/mcl_portals/portal_nether.lua +++ b/mods/ITEMS/mcl_portals/portal_nether.lua @@ -137,8 +137,20 @@ local function find_exit(p, dx, dy, dz) if not p or not p.y or not p.z or not p.x then return end local dx, dy, dz = dx or DISTANCE_MAX, dy or DISTANCE_MAX, dz or DISTANCE_MAX if dx < 1 or dy < 1 or dz < 1 then return false end - local x, y, z = floor(p.x), floor(p.y), floor(p.z) - local x1, y1, z1, x2, y2, z2 = x-dx+1, y-dy+1, z-dz+1, x+dx-1, y+dy-1, z+dz-1 + + --y values aren't used + local x = floor(p.x) + --local y = floor(p.y) + local z = floor(p.z) + + local x1 = x-dx+1 + --local y1 = y-dy+1 + local z1 = z-dz+1 + + local x2 = x+dx-1 + --local y2 = y+dy-1 + local z2 = z+dz-1 + local k1x, k2x = floor(x1/256), floor(x2/256) local k1z, k2z = floor(z1/256), floor(z2/256) @@ -371,7 +383,7 @@ local function finalize_teleport(obj, exit) if is_player then name = obj:get_player_name() end - local y, dim = mcl_worlds.y_to_layer(exit.y) + local _, dim = mcl_worlds.y_to_layer(exit.y) -- If player stands, player is at ca. something+0.5 which might cause precision problems, so we used ceil for objpos.y diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index b4e1d9448..09b95115a 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -558,8 +558,8 @@ function mcl_potions.make_invisible(player, toggle) local is_player = player:is_player() local entity = player:get_luaentity() - local playername = player:get_player_name() - local skin_file = "" + --local playername = player:get_player_name() + local skin_file if toggle then -- hide player @@ -567,22 +567,22 @@ function mcl_potions.make_invisible(player, toggle) if entity then EF.invisible[player].old_size = entity.visual_size - elseif not player:is_player() then -- if not a player or entity, do nothing + elseif not is_player then -- if not a player or entity, do nothing return end - if player:is_player() then - mcl_player.player_set_skin(player, "mobs_mc_empty.png") - elseif not player:is_player() then + if is_player then + mcl_player.player_set_skin(player, skin_file) + elseif not is_player then player:set_properties({visual_size = {x = 0, y = 0}}) end player:set_nametag_attributes({color = {a = 0}}) elseif EF.invisible[player] then -- show player - if player:is_player() then + if is_player then mcl_skins.update_player_skin(player) - elseif not player:is_player() then + elseif not is_player then player:set_properties({visual_size = EF.invisible[player].old_size}) end player:set_nametag_attributes({color = {r = 255, g = 255, b = 255, a = 255}}) diff --git a/mods/ITEMS/mcl_tnt/init.lua b/mods/ITEMS/mcl_tnt/init.lua index 19bd04a18..40455f8d0 100644 --- a/mods/ITEMS/mcl_tnt/init.lua +++ b/mods/ITEMS/mcl_tnt/init.lua @@ -114,7 +114,7 @@ function TNT:on_activate(staticdata) self.object:set_texture_mod("^mcl_tnt_blink.png") end -local function add_effects(pos, radius, drops) +--[[local function add_effects(pos, radius, drops) minetest.add_particlespawner({ amount = 64, time = 0.5, @@ -161,7 +161,7 @@ local function add_effects(pos, radius, drops) texture = texture, collisiondetection = true, }) -end +end]] function TNT:on_step(dtime) local pos = self.object:get_pos() diff --git a/mods/ITEMS/xpanes/init.lua b/mods/ITEMS/xpanes/init.lua index b7faffb3b..472b3efdf 100644 --- a/mods/ITEMS/xpanes/init.lua +++ b/mods/ITEMS/xpanes/init.lua @@ -170,7 +170,7 @@ end local canonical_color = "yellow" -- Register glass pane (stained and unstained) -local pane = function(description, node, append) +local function pane(description, node, append) local texture1, longdesc, entry_name, create_entry local is_canonical = true -- Special case: Default (unstained) glass texture diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index d4ebe00d3..9108b75c1 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -1775,7 +1775,7 @@ local function register_biomelike_ores() -- Mesa strata (registered as sheet ores) -- Helper function to create strata. - local stratum = function(y_min, height, color, seed, is_perfect) + local function stratum(y_min, height, color, seed, is_perfect) if not height then height = 1 end @@ -3079,7 +3079,7 @@ local function register_decorations() }) -- Doubletall grass - local register_doubletall_grass = function(offset, scale, biomes) + local function register_doubletall_grass(offset, scale, biomes) for b=1, #biomes do local param2 = minetest.registered_biomes[biomes[b]]._mcl_palette_index @@ -3115,7 +3115,7 @@ local function register_decorations() register_doubletall_grass(-0.0005, -0.03, {"Savanna", "SavannaM"}) -- Large ferns - local register_double_fern = function(offset, scale, biomes) + local function register_double_fern(offset, scale, biomes) for b=1, #biomes do local param2 = minetest.registered_biomes[biomes[b]]._mcl_palette_index minetest.register_decoration({ @@ -3149,7 +3149,7 @@ local function register_decorations() register_double_fern(0.15, 0.1, { "JungleM" }) -- Large flowers - local register_large_flower = function(name, biomes, seed, offset, flower_forest_offset) + local function register_large_flower(name, biomes, seed, offset, flower_forest_offset) local maxi if flower_forest_offset then maxi = 2 @@ -3580,7 +3580,8 @@ local function register_decorations() local fern_minimal = { "Jungle", "JungleM", "JungleEdge", "JungleEdgeM", "Taiga", "MegaTaiga", "MegaSpruceTaiga", "ColdTaiga" } local fern_low = { "Jungle", "JungleM", "JungleEdge", "JungleEdgeM", "Taiga", "MegaTaiga", "MegaSpruceTaiga" } local fern_Jungle = { "Jungle", "JungleM", "JungleEdge", "JungleEdgeM" } - local fern_JungleM = { "JungleM" }, + --local fern_JungleM = { "JungleM" }, + register_grass_decoration("fern", -0.03, 0.09, fern_minimal) register_grass_decoration("fern", -0.015, 0.075, fern_minimal) register_grass_decoration("fern", 0, 0.06, fern_minimal) @@ -3591,7 +3592,7 @@ local function register_decorations() register_grass_decoration("fern", 0.05, 0.01, fern_Jungle) register_grass_decoration("fern", 0.07, -0.01, fern_Jungle) register_grass_decoration("fern", 0.09, -0.03, fern_Jungle) - register_grass_decoration("fern", 0.12, -0.03, fern_JungleM) + register_grass_decoration("fern", 0.12, -0.03, {"JungleM"}) local b_seagrass = {"ColdTaiga_ocean","ExtremeHills_ocean","ExtremeHillsM_ocean","ExtremeHills+_ocean","Taiga_ocean","MegaTaiga_ocean","MegaSpruceTaiga_ocean","StoneBeach_ocean","Plains_ocean","SunflowerPlains_ocean","Forest_ocean","FlowerForest_ocean","BirchForest_ocean","BirchForestM_ocean","RoofedForest_ocean","Swampland_ocean","Jungle_ocean","JungleM_ocean","JungleEdge_ocean","JungleEdgeM_ocean","MushroomIsland_ocean","Desert_ocean","Savanna_ocean","SavannaM_ocean","Mesa_ocean","MesaBryce_ocean","MesaPlateauF_ocean","MesaPlateauFM_ocean", "ColdTaiga_deep_ocean","ExtremeHills_deep_ocean","ExtremeHillsM_deep_ocean","ExtremeHills+_deep_ocean","Taiga_deep_ocean","MegaTaiga_deep_ocean","MegaSpruceTaiga_deep_ocean","StoneBeach_deep_ocean","Plains_deep_ocean","SunflowerPlains_deep_ocean","Forest_deep_ocean","FlowerForest_deep_ocean","BirchForest_deep_ocean","BirchForestM_deep_ocean","RoofedForest_deep_ocean","Swampland_deep_ocean","Jungle_deep_ocean","JungleM_deep_ocean","JungleEdge_deep_ocean","JungleEdgeM_deep_ocean","MushroomIsland_deep_ocean","Desert_deep_ocean","Savanna_deep_ocean","SavannaM_deep_ocean","Mesa_deep_ocean","MesaBryce_deep_ocean","MesaPlateauF_deep_ocean","MesaPlateauFM_deep_ocean", @@ -3974,7 +3975,7 @@ if mg_name ~= "singlenode" then mcl_mapgen_core.register_generator("chorus_grow", nil, function(minp, maxp, blockseed) local gennotify = minetest.get_mapgen_object("gennotify") --local poslist = {} - pr = PseudoRandom(blockseed + 14) + local pr = PseudoRandom(blockseed + 14) for _, pos in ipairs(gennotify["decoration#"..deco_id_chorus_plant] or {}) do local x, y, z = pos.x, pos.y, pos.z if x < -2 or x > 2 or z < -2 or z > 2 then diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index bdcdb1b4d..b3db122e6 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -765,7 +765,7 @@ local function register_mgv6_decorations() }) -- Large flowers - local register_large_flower = function(name, seed, offset) + local function register_large_flower(name, seed, offset) minetest.register_decoration({ deco_type = "schematic", schematic = { @@ -1169,7 +1169,7 @@ end -- minp and maxp (from an on_generated callback) and returns the real world coordinates -- as X, Z. -- Inverse function of xz_to_biomemap ---[[local biomemap_to_xz = function(index, minp, maxp) +--[[local function biomemap_to_xz(index, minp, maxp) local xwidth = maxp.x - minp.x + 1 local zwidth = maxp.z - minp.z + 1 local x = ((index-1) % xwidth) + minp.x @@ -1180,7 +1180,7 @@ end]] -- Takes x and z coordinates and minp and maxp of a generated chunk -- (in on_generated callback) and returns a biomemap index) -- Inverse function of biomemap_to_xz -local xz_to_biomemap_index = function(x, z, minp, maxp) +local function xz_to_biomemap_index(x, z, minp, maxp) local xwidth = maxp.x - minp.x + 1 local zwidth = maxp.z - minp.z + 1 local minix = x % xwidth @@ -1404,7 +1404,7 @@ local function generate_structures(minp, maxp, blockseed, biomemap) -- TODO: Spawn witch in or around hut when the mob sucks less. - local place_tree_if_free = function(pos, prev_result) + local function place_tree_if_free(pos, prev_result) local nn = minetest.get_node(pos).name if nn == "mcl_flowers:waterlily" or nn == "mcl_core:water_source" or nn == "mcl_core:water_flowing" or nn == "air" then minetest.set_node(pos, {name="mcl_core:tree", param2=0}) @@ -1720,7 +1720,7 @@ end -- Generate mushrooms in caves manually. -- Minetest's API does not support decorations in caves yet. :-( -local generate_underground_mushrooms = function(minp, maxp, seed) +local function generate_underground_mushrooms(minp, maxp, seed) local pr_shroom = PseudoRandom(seed-24359) -- Generate rare underground mushrooms -- TODO: Make them appear in groups, use Perlin noise @@ -1754,7 +1754,7 @@ else end -- Generate Nether decorations manually: Eternal fire, mushrooms, nether wart -- Minetest's API does not support decorations in caves yet. :-( -local generate_nether_decorations = function(minp, maxp, seed) +local function generate_nether_decorations(minp, maxp, seed) local pr_nether = PseudoRandom(seed+667) if minp.y > mcl_vars.mg_nether_max or maxp.y < mcl_vars.mg_nether_min then @@ -1771,7 +1771,7 @@ local generate_nether_decorations = function(minp, maxp, seed) local ssand = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_nether:soul_sand"}) -- Helper function to spawn “fake” decoration - local special_deco = function(nodes, spawn_func) + local function special_deco(nodes, spawn_func) for n = 1, #nodes do bpos = {x = nodes[n].x, y = nodes[n].y + 1, z = nodes[n].z } @@ -1904,7 +1904,7 @@ function mcl_mapgen_core.unregister_generator(id) if rec.vf then lvm = lvm - 1 end if rec.nf then nodes = nodes - 1 end if rec.needs_param2 then param2 = param2 - 1 end - if rec.needs_level0 then level0 = level0 - 1 end + --if rec.needs_level0 then level0 = level0 - 1 end end -- Generate basic layer-based nodes: void, bedrock, realm barrier, lava seas, etc. @@ -1912,7 +1912,7 @@ end local bedrock_check if mcl_vars.mg_bedrock_is_rough then - bedrock_check = function(pos, _, pr) + function bedrock_check(pos, _, pr) local y = pos.y -- Bedrock layers with increasing levels of roughness, until a perfecly flat bedrock later at the bottom layer -- This code assumes a bedrock height of 5 layers. diff --git a/mods/MAPGEN/mcl_strongholds/init.lua b/mods/MAPGEN/mcl_strongholds/init.lua index e465b2e40..083172a3c 100644 --- a/mods/MAPGEN/mcl_strongholds/init.lua +++ b/mods/MAPGEN/mcl_strongholds/init.lua @@ -25,7 +25,7 @@ local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superfl -- The stronghold positions are based on the world seed. -- The actual position might be offset by a few blocks because it might be shifted -- to make sure the end portal room is completely within the boundaries of a mapchunk. -local init_strongholds = function() +local function init_strongholds() if strongholds_inited then return end @@ -67,7 +67,7 @@ local init_strongholds = function() end -- Stronghold generation for register_on_generated. -local generate_strongholds = function(minp, maxp, blockseed) +local function generate_strongholds(minp, maxp, blockseed) local pr = PseudoRandom(blockseed) for s=1, #strongholds do if not strongholds[s].generated then diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index e3f6b4829..dfb7da24b 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -1,5 +1,9 @@ -local S = minetest.get_translator("mcl_structures") -mcl_structures ={} +local modname = minetest.get_current_modname() +local S = minetest.get_translator(modname) +local modpath = minetest.get_modpath(modname) + +mcl_structures = {} + local rotations = { "0", "90", @@ -14,8 +18,9 @@ local function ecb_place(blockpos, action, calls_remaining, param) param.after_placement_callback(param.p1, param.p2, param.size, param.rotation, param.pr, param.callback_param) end end -mcl_structures.place_schematic = function(pos, schematic, rotation, replacements, force_placement, flags, after_placement_callback, pr, callback_param) - local s = loadstring(minetest.serialize_schematic(schematic, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return(schematic)")() + +function mcl_structures.place_schematic(pos, schematic, rotation, replacements, force_placement, flags, after_placement_callback, pr, callback_param) + local s = loadstring(minetest.serialize_schematic(schematic, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return schematic")() if s and s.size then local x, z = s.size.x, s.size.z if rotation then @@ -37,7 +42,7 @@ mcl_structures.place_schematic = function(pos, schematic, rotation, replacements end end -mcl_structures.get_struct = function(file) +function mcl_structures.get_struct(file) local localfile = minetest.get_modpath("mcl_structures").."/schematics/"..file local file, errorload = io.open(localfile, "rb") if errorload ~= nil then @@ -53,7 +58,7 @@ end -- Call on_construct on pos. -- Useful to init chests from formspec. -local init_node_construct = function(pos) +local function init_node_construct(pos) local node = minetest.get_node(pos) local def = minetest.registered_nodes[node.name] if def and def.on_construct then @@ -64,7 +69,7 @@ local init_node_construct = function(pos) end -- The call of Struct -mcl_structures.call_struct = function(pos, struct_style, rotation, pr) +function mcl_structures.call_struct(pos, struct_style, rotation, pr) minetest.log("action","[mcl_structures] call_struct " .. struct_style.." at "..minetest.pos_to_string(pos)) if not rotation then rotation = "random" @@ -96,13 +101,13 @@ mcl_structures.call_struct = function(pos, struct_style, rotation, pr) end end -mcl_structures.generate_desert_well = function(pos, rot) +function mcl_structures.generate_desert_well(pos, rot) local newpos = {x=pos.x,y=pos.y-2,z=pos.z} - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_desert_well.mts" + local path = modpath.."/schematics/mcl_structures_desert_well.mts" return mcl_structures.place_schematic(newpos, path, rot or "0", nil, true) end -mcl_structures.generate_igloo = function(pos, rotation, pr) +function mcl_structures.generate_igloo(pos, rotation, pr) -- Place igloo local success, rotation = mcl_structures.generate_igloo_top(pos, pr) -- Place igloo basement with 50% chance @@ -148,7 +153,7 @@ mcl_structures.generate_igloo = function(pos, rotation, pr) else return success end - local set_brick = function(pos) + local function set_brick(pos) local c = pr:next(1, 3) -- cracked chance local m = pr:next(1, 10) -- chance for monster egg local brick @@ -198,11 +203,11 @@ mcl_structures.generate_igloo = function(pos, rotation, pr) return success end -mcl_structures.generate_igloo_top = function(pos, pr) +function mcl_structures.generate_igloo_top(pos, pr) -- FIXME: This spawns bookshelf instead of furnace. Fix this! -- Furnace does ot work atm because apparently meta is not set. :-( local newpos = {x=pos.x,y=pos.y-1,z=pos.z} - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_igloo_top.mts" + local path = modpath.."/schematics/mcl_structures_igloo_top.mts" local rotation = tostring(pr:next(0,3)*90) return mcl_structures.place_schematic(newpos, path, rotation, nil, true), rotation end @@ -250,22 +255,22 @@ local function igloo_placement_callback(p1, p2, size, orientation, pr) mcl_loot.fill_inventory(inv, "main", lootitems, pr) end -mcl_structures.generate_igloo_basement = function(pos, orientation, pr) +function mcl_structures.generate_igloo_basement(pos, orientation, pr) -- TODO: Add brewing stand -- TODO: Add monster eggs -- TODO: Spawn villager and zombie villager - local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_igloo_basement.mts" + local path = modpath.."/schematics/mcl_structures_igloo_basement.mts" mcl_structures.place_schematic(pos, path, orientation, nil, true, nil, igloo_placement_callback, pr) end -mcl_structures.generate_boulder = function(pos, rotation, pr) +function mcl_structures.generate_boulder(pos, rotation, pr) -- Choose between 2 boulder sizes (2×2×2 or 3×3×3) local r = pr:next(1, 10) local path if r <= 3 then - path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_boulder_small.mts" + path = modpath.."/schematics/mcl_structures_boulder_small.mts" else - path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_boulder.mts" + path = modpath.."/schematics/mcl_structures_boulder.mts" end local newpos = {x=pos.x,y=pos.y-1,z=pos.z} @@ -284,22 +289,22 @@ local function hut_placement_callback(p1, p2, size, orientation, pr) end end -mcl_structures.generate_witch_hut = function(pos, rotation, pr) +function mcl_structures.generate_witch_hut(pos, rotation, pr) local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_witch_hut.mts" mcl_structures.place_schematic(pos, path, rotation, nil, true, nil, hut_placement_callback, pr) end -mcl_structures.generate_ice_spike_small = function(pos, rotation) +function mcl_structures.generate_ice_spike_small(pos, rotation) local path = minetest.get_modpath("mcl_structures").."/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 -mcl_structures.generate_ice_spike_large = function(pos, rotation) +function mcl_structures.generate_ice_spike_large(pos, rotation) local path = minetest.get_modpath("mcl_structures").."/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 -mcl_structures.generate_fossil = function(pos, rotation, pr) +function mcl_structures.generate_fossil(pos, rotation, pr) -- Generates one out of 8 possible fossil pieces local newpos = {x=pos.x,y=pos.y-1,z=pos.z} local fossils = { @@ -317,17 +322,17 @@ mcl_structures.generate_fossil = function(pos, rotation, pr) return mcl_structures.place_schematic(newpos, path, rotation or "random", nil, true) end -mcl_structures.generate_end_exit_portal = function(pos, rot) +function mcl_structures.generate_end_exit_portal(pos, rot) local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts" return mcl_structures.place_schematic(pos, path, rot or "0", {["mcl_portals:portal_end"] = "air"}, true) end -mcl_structures.generate_end_exit_portal_open = function(pos, rot) +function mcl_structures.generate_end_exit_portal_open(pos, rot) local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts" return mcl_structures.place_schematic(pos, path, rot or "0", nil, true) end -mcl_structures.generate_end_gateway_portal = function(pos, rot) +function mcl_structures.generate_end_gateway_portal(pos, rot) local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_gateway_portal.mts" return mcl_structures.place_schematic(pos, path, rot or "0", nil, true) end @@ -410,7 +415,7 @@ local function shrine_placement_callback(p1, p2, size, rotation, pr) end end -mcl_structures.generate_end_portal_shrine = function(pos, rotation, pr) +function mcl_structures.generate_end_portal_shrine(pos, rotation, pr) local offset = {x=6, y=4, z=6} --local size = {x=13, y=8, z=13} local newpos = { x = pos.x - offset.x, y = pos.y, z = pos.z - offset.z } @@ -493,7 +498,7 @@ local function temple_placement_callback(p1, p2, size, rotation, pr) end end -mcl_structures.generate_desert_temple = function(pos, rotation, pr) +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 newpos = {x=pos.x,y=pos.y-12,z=pos.z} @@ -517,7 +522,7 @@ Format of return value: TODO: Implement this function for all other structure types as well. ]] -mcl_structures.get_registered_structures = function(structure_type) +function mcl_structures.get_registered_structures(structure_type) if registered_structures[structure_type] then return table.copy(registered_structures[structure_type]) else @@ -527,7 +532,7 @@ end -- Register a structures table for the given type. The table format is the same as for -- mcl_structures.get_registered_structures. -mcl_structures.register_structures = function(structure_type, structures) +function mcl_structures.register_structures(structure_type, structures) registered_structures[structure_type] = structures end diff --git a/mods/MAPGEN/mcl_villages/buildings.lua b/mods/MAPGEN/mcl_villages/buildings.lua index 9d8e7580f..3f4490bf9 100644 --- a/mods/MAPGEN/mcl_villages/buildings.lua +++ b/mods/MAPGEN/mcl_villages/buildings.lua @@ -14,7 +14,7 @@ function settlements.build_schematic(vm, data, va, pos, building, replace_wall, -- schematic conversion to lua local schem_lua = minetest.serialize_schematic(building, "lua", - {lua_use_comments = false, lua_num_indent_spaces = 0}).." return(schematic)" + {lua_use_comments = false, lua_num_indent_spaces = 0}).." return schematic" -- replace material if replace_wall == "y" then schem_lua = schem_lua:gsub("mcl_core:cobble", material) @@ -228,7 +228,7 @@ function settlements.place_schematics(settlement_info, pr) -- schematic conversion to lua local schem_lua = minetest.serialize_schematic(building, "lua", - {lua_use_comments = false, lua_num_indent_spaces = 0}).." return(schematic)" + {lua_use_comments = false, lua_num_indent_spaces = 0}).." return schematic" schem_lua = schem_lua:gsub("mcl_core:stonebrickcarved", "mcl_villages:stonebrickcarved") -- replace material if replace_wall then diff --git a/mods/MAPGEN/mcl_villages/const.lua b/mods/MAPGEN/mcl_villages/const.lua index e5cbc9b39..eb7806209 100644 --- a/mods/MAPGEN/mcl_villages/const.lua +++ b/mods/MAPGEN/mcl_villages/const.lua @@ -1,5 +1,5 @@ -- switch for debugging -settlements.debug = function(message) +function settlements.debug(message) -- minetest.chat_send_all(message) -- minetest.log("warning", "[mcl_villages] "..message) minetest.log("verbose", "[mcl_villages] "..message) diff --git a/mods/MAPGEN/tsm_railcorridors/gameconfig.lua b/mods/MAPGEN/tsm_railcorridors/gameconfig.lua index 904c3af08..168ecf535 100644 --- a/mods/MAPGEN/tsm_railcorridors/gameconfig.lua +++ b/mods/MAPGEN/tsm_railcorridors/gameconfig.lua @@ -27,7 +27,7 @@ if mg_name == "v6" then } else -- This generates dark oak wood in mesa biomes and oak wood everywhere else. - tsm_railcorridors.nodes.corridor_woods_function = function(pos, node) + function tsm_railcorridors.nodes.corridor_woods_function(pos, node) if minetest.get_item_group(node.name, "hardened_clay") ~= 0 then return "mcl_core:darkwood", "mcl_fences:dark_oak_fence" else diff --git a/mods/MAPGEN/tsm_railcorridors/init.lua b/mods/MAPGEN/tsm_railcorridors/init.lua index 2414cc962..d7a074a00 100644 --- a/mods/MAPGEN/tsm_railcorridors/init.lua +++ b/mods/MAPGEN/tsm_railcorridors/init.lua @@ -114,7 +114,8 @@ if not tsm_railcorridors.nodes.corridor_woods_function then end -- Random Perlin noise generators -local pr, pr_carts, pr_treasures, pr_deco, webperlin_major, webperlin_minor +local pr, pr_carts, pr_deco, webperlin_major, webperlin_minor +--local pr_treasures local function InitRandomizer(seed) -- Mostly used for corridor gen. @@ -124,7 +125,7 @@ local function InitRandomizer(seed) -- Separate randomizer for carts because spawning carts is very timing-dependent pr_carts = PseudoRandom(seed-654) -- Chest contents randomizer - pr_treasures = PseudoRandom(seed+777) + --pr_treasures = PseudoRandom(seed+777) -- Used for cobweb generation, both noises have to reach a high value for cobwebs to appear webperlin_major = PerlinNoise(934, 3, 0.6, 500) webperlin_minor = PerlinNoise(834, 3, 0.6, 50) @@ -680,11 +681,11 @@ local function create_corridor_section(waypoint, axis, sign, up_or_down, up_or_d railsegcount = segcount end for i=1,railsegcount do - local p = {x=waypoint.x+vek.x*i, y=waypoint.y+vek.y*i-1, z=waypoint.z+vek.z*i} + local p = {x = waypoint.x + vek.x * i, y = waypoint.y + vek.y * i-1, z = waypoint.z + vek.z * i} -- Randomly returns either the left or right side of the main rail. -- Also returns offset as second return value. - local left_or_right = function(pos, vek) + local function left_or_right(pos, vek) local off if pr:next(1, 2) == 1 then -- left @@ -764,7 +765,7 @@ local function create_corridor_section(waypoint, axis, sign, up_or_down, up_or_d -- Place cobwebs left and right in the corridor if place_cobwebs and tsm_railcorridors.nodes.cobweb then -- Helper function to place a cobweb at the side (based on chance an Perlin noise) - local cobweb_at_side = function(basepos, vek) + local function cobweb_at_side(basepos, vek) if pr:next(1,5) == 1 then local h = pr:next(0, 2) -- 3 possible cobweb heights local cpos = {x=basepos.x+vek.x, y=basepos.y+h, z=basepos.z+vek.z} diff --git a/mods/PLAYER/mcl_hunger/hunger.lua b/mods/PLAYER/mcl_hunger/hunger.lua index 51d7fdaeb..cf422dbf0 100644 --- a/mods/PLAYER/mcl_hunger/hunger.lua +++ b/mods/PLAYER/mcl_hunger/hunger.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_hunger") +--local S = minetest.get_translator("mcl_hunger") -- 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) diff --git a/mods/PLAYER/mcl_playerinfo/init.lua b/mods/PLAYER/mcl_playerinfo/init.lua index ec59a4463..4d3e2556b 100644 --- a/mods/PLAYER/mcl_playerinfo/init.lua +++ b/mods/PLAYER/mcl_playerinfo/init.lua @@ -1,3 +1,5 @@ +local table = table + -- Player state for public API mcl_playerinfo = {} @@ -21,7 +23,7 @@ end local time = 0 -local get_player_nodes = function(player_pos) +local function get_player_nodes(player_pos) local work_pos = table.copy(player_pos) -- what is around me? diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 7b7920ee0..ceaef6346 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -1,5 +1,3 @@ -local S = minetest.get_translator("mcl_playerplus") - mcl_playerplus = { elytra = {}, } @@ -27,7 +25,7 @@ local mcl_playerplus_internal = {} local time = 0 local look_pitch = 0 -local player_collision = function(player) +local function player_collision(player) local pos = player:get_pos() --local vel = player:get_velocity() @@ -50,8 +48,7 @@ local player_collision = function(player) z = z + (vec.z * force) end end - - return({x,z}) + return {x,z} end -- converts yaw to degrees @@ -59,7 +56,7 @@ local function degrees(rad) return rad * 180.0 / math.pi end -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) diff --git a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.de.tr b/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.de.tr deleted file mode 100644 index 44d486d08..000000000 --- a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.de.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_playerplus -@1 suffocated to death.=@1 erstickte zu Tode. -@1 was prickled to death by a cactus.=@1 wurde von einem Kaktus zu Tode gepiekst. diff --git a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.es.tr b/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.es.tr deleted file mode 100644 index ef7705bce..000000000 --- a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.es.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_playerplus -@1 suffocated to death.=@1 ahogado hasta la muerte. -@1 was prickled to death by a cactus.=@1 fue herido de muerte por un cactus. diff --git a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.fr.tr b/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.fr.tr deleted file mode 100644 index 6482bd736..000000000 --- a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.fr.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_playerplus -@1 suffocated to death.=@1 étouffé à mort. -@1 was prickled to death by a cactus.=@1 a été piqué à mort par un cactus. diff --git a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.ru.tr b/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.ru.tr deleted file mode 100644 index a75bd4bd6..000000000 --- a/mods/PLAYER/mcl_playerplus/locale/mcl_playerplus.ru.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_playerplus -@1 suffocated to death.=@1 задохнулся(ась). -@1 was prickled to death by a cactus.=@1 был(а) до смерти заколот(а) кактусом. diff --git a/mods/PLAYER/mcl_playerplus/locale/template.txt b/mods/PLAYER/mcl_playerplus/locale/template.txt deleted file mode 100644 index 49b1f96ac..000000000 --- a/mods/PLAYER/mcl_playerplus/locale/template.txt +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain: mcl_playerplus -@1 suffocated to death.= -@1 was prickled to death by a cactus.= diff --git a/mods/PLAYER/mcl_skins/init.lua b/mods/PLAYER/mcl_skins/init.lua index 84f147da6..fb91d74d3 100644 --- a/mods/PLAYER/mcl_skins/init.lua +++ b/mods/PLAYER/mcl_skins/init.lua @@ -70,7 +70,7 @@ while true do id = id + 1 end -mcl_skins.cycle_skin = function(player) +function mcl_skins.cycle_skin(player) local skin_id = tonumber(player:get_meta():get_string("mcl_skins:skin_id")) if not skin_id then skin_id = 0 @@ -82,12 +82,12 @@ mcl_skins.cycle_skin = function(player) mcl_skins.set_player_skin(player, skin_id) end -mcl_skins.set_player_skin = function(player, skin_id) +function mcl_skins.set_player_skin(player, skin_id) if not player then return false end local playername = player:get_player_name() - local skin, skin_file, preview + local skin, preview if skin_id == nil or type(skin_id) ~= "number" or skin_id < 0 or skin_id > mcl_skins.skin_count then return false elseif skin_id == 0 then @@ -109,7 +109,7 @@ mcl_skins.set_player_skin = function(player, skin_id) preview = "mcl_skins_player_dummy" end end - skin_file = skin .. ".png" + --local skin_file = skin .. ".png" mcl_skins.skins[playername] = skin mcl_skins.previews[playername] = preview player:get_meta():set_string("mcl_skins:skin_id", tostring(skin_id)) @@ -124,7 +124,7 @@ mcl_skins.set_player_skin = function(player, skin_id) return true end -mcl_skins.update_player_skin = function(player) +function mcl_skins.update_player_skin(player) if not player then return end @@ -134,7 +134,6 @@ end -- load player skin on join minetest.register_on_joinplayer(function(player) - local name = player:get_player_name() local skin_id = player:get_meta():get_string("mcl_skins:skin_id") local set_skin @@ -156,7 +155,7 @@ end) mcl_skins.registered_on_set_skins = {} -mcl_skins.register_on_set_skin = function(func) +function mcl_skins.register_on_set_skin(func) table.insert(mcl_skins.registered_on_set_skins, func) end @@ -231,7 +230,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end end) -mcl_skins.show_formspec = function(playername) +function mcl_skins.show_formspec(playername) local formspec = "size[7,8.5]" formspec = formspec .. "label[2,2;" .. minetest.formspec_escape(minetest.colorize("#383838", S("Select player skin:"))) .. "]" diff --git a/mods/PLAYER/mcl_sprint/init.lua b/mods/PLAYER/mcl_sprint/init.lua index 12d0394e5..546a5f4f0 100644 --- a/mods/PLAYER/mcl_sprint/init.lua +++ b/mods/PLAYER/mcl_sprint/init.lua @@ -16,7 +16,7 @@ local players = {} -- Returns true if the player with the given name is sprinting, false if not. -- Returns nil if player does not exist. -mcl_sprint.is_sprinting = function(playername) +function mcl_sprint.is_sprinting(playername) if players[playername] then return players[playername].sprinting else