1
0
Fork 0

fix many codestyle issues (functions, strings, modpaths)

This commit is contained in:
AFCMS 2021-05-29 16:12:33 +02:00
parent 0d619ec6a8
commit cd33d406b2
248 changed files with 2223 additions and 2099 deletions

View File

@ -83,7 +83,7 @@ local function get_hardness_values_for_groups()
for _, ndef in pairs(minetest.registered_nodes) do for _, ndef in pairs(minetest.registered_nodes) do
for g, _ in pairs(mcl_autogroup.registered_diggroups) do for g, _ in pairs(mcl_autogroup.registered_diggroups) do
if ndef.groups[g] ~= nil then if ndef.groups[g] then
maps[g][ndef._mcl_hardness or 0] = true maps[g][ndef._mcl_hardness or 0] = true
end end
end end

View File

@ -1,6 +1,8 @@
local get_connected_players = minetest.get_connected_players local get_connected_players = minetest.get_connected_players
local clock = os.clock local clock = os.clock
local pairs = pairs
controls = {} controls = {}
controls.players = {} controls.players = {}
@ -20,15 +22,15 @@ function controls.register_on_hold(func)
end end
local known_controls = { local known_controls = {
jump=true, jump = true,
right=true, right = true,
left=true, left = true,
LMB=true, LMB = true,
RMB=true, RMB = true,
sneak=true, sneak = true,
aux1=true, aux1 = true,
down=true, down = true,
up=true, up = true,
} }
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
@ -52,17 +54,17 @@ minetest.register_globalstep(function(dtime)
for cname, cbool in pairs(player_controls) do for cname, cbool in pairs(player_controls) do
if known_controls[cname] == true then if known_controls[cname] == true then
--Press a key --Press a key
if cbool==true and controls.players[player_name][cname][1]==false then if cbool == true and controls.players[player_name][cname][1] == false then
for _, func in pairs(controls.registered_on_press) do for _, func in pairs(controls.registered_on_press) do
func(player, cname) func(player, cname)
end end
controls.players[player_name][cname] = {true, clock()} controls.players[player_name][cname] = {true, clock()}
elseif cbool==true and controls.players[player_name][cname][1]==true then elseif cbool == true and controls.players[player_name][cname][1] == true then
for _, func in pairs(controls.registered_on_hold) do for _, func in pairs(controls.registered_on_hold) do
func(player, cname, clock()-controls.players[player_name][cname][2]) func(player, cname, clock()-controls.players[player_name][cname][2])
end end
--Release a key --Release a key
elseif cbool==false and controls.players[player_name][cname][1]==true then elseif cbool == false and controls.players[player_name][cname][1] == true then
for _, func in pairs(controls.registered_on_release) do for _, func in pairs(controls.registered_on_release) do
func(player, cname, clock()-controls.players[player_name][cname][2]) func(player, cname, clock()-controls.players[player_name][cname][2])
end end

View File

@ -12,9 +12,13 @@ under the LGPLv2.1 license.
mcl_explosions = {} mcl_explosions = {}
local mod_fire = minetest.get_modpath("mcl_fire") ~= nil local mod_fire = minetest.get_modpath("mcl_fire")
--local CONTENT_FIRE = minetest.get_content_id("mcl_fire:fire") --local CONTENT_FIRE = minetest.get_content_id("mcl_fire:fire")
local math = math
local vector = vector
local table = table
local hash_node_position = minetest.hash_node_position local hash_node_position = minetest.hash_node_position
local get_objects_inside_radius = minetest.get_objects_inside_radius local get_objects_inside_radius = minetest.get_objects_inside_radius
local get_position_from_hash = minetest.get_position_from_hash local get_position_from_hash = minetest.get_position_from_hash
@ -24,6 +28,7 @@ local get_voxel_manip = minetest.get_voxel_manip
local bulk_set_node = minetest.bulk_set_node local bulk_set_node = minetest.bulk_set_node
local check_for_falling = minetest.check_for_falling local check_for_falling = minetest.check_for_falling
local add_item = minetest.add_item local add_item = minetest.add_item
local pos_to_string = minetest.pos_to_string
-- Saved sphere explosion shapes for various radiuses -- Saved sphere explosion shapes for various radiuses
local sphere_shapes = {} local sphere_shapes = {}
@ -240,7 +245,7 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc
local ent = obj:get_luaentity() local ent = obj:get_luaentity()
-- Ignore items to lower lag -- Ignore items to lower lag
if (obj:is_player() or (ent and ent.name ~= '__builtin.item')) and obj:get_hp() > 0 then if (obj:is_player() or (ent and ent.name ~= "__builtin.item")) and obj:get_hp() > 0 then
local opos = obj:get_pos() local opos = obj:get_pos()
local collisionbox = nil local collisionbox = nil
@ -356,9 +361,9 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc
local on_blast = node_on_blast[data[idx]] local on_blast = node_on_blast[data[idx]]
local remove = true local remove = true
if do_drop or on_blast ~= nil then if do_drop or on_blast then
local npos = get_position_from_hash(hash) local npos = get_position_from_hash(hash)
if on_blast ~= nil then if on_blast then
on_blast(npos, 1.0, do_drop) on_blast(npos, 1.0, do_drop)
remove = false remove = false
else else
@ -400,8 +405,7 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc
end end
-- Log explosion -- Log explosion
minetest.log('action', 'Explosion at ' .. minetest.pos_to_string(pos) .. minetest.log("action", "Explosion at "..pos_to_string(pos).." with strength "..strength.." and radius "..radius)
' with strength ' .. strength .. ' and radius ' .. radius)
end end
-- Create an explosion with strength at pos. -- Create an explosion with strength at pos.

View File

@ -1,5 +1,7 @@
mcl_worlds = {} mcl_worlds = {}
local get_connected_players = minetest.get_connected_players
-- For a given position, returns a 2-tuple: -- For a given position, returns a 2-tuple:
-- 1st return value: true if pos is in void -- 1st return value: true if pos is in void
-- 2nd return value: true if it is in the deadly part of the void -- 2nd return value: true if it is in the deadly part of the void
@ -44,12 +46,16 @@ function mcl_worlds.y_to_layer(y)
end end
end end
local y_to_layer = mcl_worlds.y_to_layer
-- Takes a pos and returns the dimension it belongs to (same as above) -- Takes a pos and returns the dimension it belongs to (same as above)
function mcl_worlds.pos_to_dimension(pos) function mcl_worlds.pos_to_dimension(pos)
local _, dim = mcl_worlds.y_to_layer(pos.y) local _, dim = y_to_layer(pos.y)
return dim return dim
end end
local pos_to_dimension = mcl_worlds.pos_to_dimension
-- Takes a Minecraft layer and a “dimension” name -- Takes a Minecraft layer and a “dimension” name
-- and returns the corresponding Y coordinate for -- and returns the corresponding Y coordinate for
-- MineClone 2. -- MineClone 2.
@ -119,6 +125,8 @@ function mcl_worlds.dimension_change(player, dimension)
last_dimension[playername] = dimension last_dimension[playername] = dimension
end end
local dimension_change = mcl_worlds.dimension_change
----------------------- INTERNAL STUFF ---------------------- ----------------------- INTERNAL STUFF ----------------------
-- Update the dimension callbacks every DIM_UPDATE seconds -- Update the dimension callbacks every DIM_UPDATE seconds
@ -126,19 +134,19 @@ local DIM_UPDATE = 1
local dimtimer = 0 local dimtimer = 0
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
last_dimension[player:get_player_name()] = mcl_worlds.pos_to_dimension(player:get_pos()) last_dimension[player:get_player_name()] = pos_to_dimension(player:get_pos())
end) end)
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
-- regular updates based on iterval -- regular updates based on iterval
dimtimer = dimtimer + dtime; dimtimer = dimtimer + dtime;
if dimtimer >= DIM_UPDATE then if dimtimer >= DIM_UPDATE then
local players = minetest.get_connected_players() local players = get_connected_players()
for p=1, #players do for p = 1, #players do
local dim = mcl_worlds.pos_to_dimension(players[p]:get_pos()) local dim = pos_to_dimension(players[p]:get_pos())
local name = players[p]:get_player_name() local name = players[p]:get_player_name()
if dim ~= last_dimension[name] then if dim ~= last_dimension[name] then
mcl_worlds.dimension_change(players[p], dim) dimension_change(players[p], dim)
end end
end end
dimtimer = 0 dimtimer = 0

View File

@ -4,6 +4,7 @@ local get_connected_players = minetest.get_connected_players
local get_node = minetest.get_node local get_node = minetest.get_node
local vector_add = vector.add local vector_add = vector.add
local ceil = math.ceil local ceil = math.ceil
local pairs = pairs
walkover = {} walkover = {}
walkover.registered_globals = {} walkover.registered_globals = {}
@ -34,9 +35,9 @@ minetest.register_globalstep(function(dtime)
local pp = player:get_pos() local pp = player:get_pos()
pp.y = ceil(pp.y) pp.y = ceil(pp.y)
local loc = vector_add(pp, {x=0,y=-1,z=0}) local loc = vector_add(pp, {x=0,y=-1,z=0})
if loc ~= nil then if loc then
local nodeiamon = get_node(loc) local nodeiamon = get_node(loc)
if nodeiamon ~= nil then if nodeiamon then
if on_walk[nodeiamon.name] then if on_walk[nodeiamon.name] then
on_walk[nodeiamon.name](loc, nodeiamon, player) on_walk[nodeiamon.name](loc, nodeiamon, player)
end end

View File

@ -1,4 +1,4 @@
local S = minetest.get_translator("mcl_boats") local S = minetest.get_translator(minetest.get_current_modname())
local boat_visual_size = {x = 1, y = 1, z = 1} local boat_visual_size = {x = 1, y = 1, z = 1}
local paddling_speed = 22 local paddling_speed = 22
@ -470,6 +470,6 @@ minetest.register_craft({
burntime = 20, burntime = 20,
}) })
if minetest.get_modpath("doc_identifier") ~= nil then if minetest.get_modpath("doc_identifier") then
doc.sub.identifier.register_object("mcl_boats:boat", "craftitems", "mcl_boats:boat") doc.sub.identifier.register_object("mcl_boats:boat", "craftitems", "mcl_boats:boat")
end end

View File

@ -1,5 +1,10 @@
local modpath = minetest.get_modpath(minetest.get_current_modname()) local modpath = minetest.get_modpath(minetest.get_current_modname())
local pairs = pairs
local get_connected_players = minetest.get_connected_players
local get_item_group = minetest.get_item_group
mcl_burning = { mcl_burning = {
storage = {}, storage = {},
animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8 animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8
@ -8,7 +13,7 @@ mcl_burning = {
dofile(modpath .. "/api.lua") dofile(modpath .. "/api.lua")
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
for _, player in pairs(minetest.get_connected_players()) do for _, player in pairs(get_connected_players()) do
local storage = mcl_burning.storage[player] local storage = mcl_burning.storage[player]
if not mcl_burning.tick(player, dtime, storage) and not mcl_burning.is_affected_by_rain(player) then if not mcl_burning.tick(player, dtime, storage) and not mcl_burning.is_affected_by_rain(player) then
local nodes = mcl_burning.get_touching_nodes(player, {"group:puts_out_fire", "group:set_on_fire"}, storage) local nodes = mcl_burning.get_touching_nodes(player, {"group:puts_out_fire", "group:set_on_fire"}, storage)
@ -16,12 +21,12 @@ minetest.register_globalstep(function(dtime)
for _, pos in pairs(nodes) do for _, pos in pairs(nodes) do
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
if minetest.get_item_group(node.name, "puts_out_fire") > 0 then if get_item_group(node.name, "puts_out_fire") > 0 then
burn_time = 0 burn_time = 0
break break
end end
local value = minetest.get_item_group(node.name, "set_on_fire") local value = get_item_group(node.name, "set_on_fire")
if value > burn_time then if value > burn_time then
burn_time = value burn_time = value
end end

View File

@ -1,5 +1,5 @@
--these are lua locals, used for higher performance --these are lua locals, used for higher performance
local minetest, math, vector, ipairs = minetest, math, vector, ipairs local minetest, math, vector, ipairs, pairs = minetest, math, vector, ipairs, pairs
--this is used for the player pool in the sound buffer --this is used for the player pool in the sound buffer
local pool = {} local pool = {}
@ -233,7 +233,7 @@ function minetest.handle_node_drops(pos, drops, digger)
local dug_node = minetest.get_node(pos) local dug_node = minetest.get_node(pos)
local tooldef local tooldef
local tool local tool
if digger ~= nil then if digger then
tool = digger:get_wielded_item() tool = digger:get_wielded_item()
tooldef = minetest.registered_tools[tool:get_name()] tooldef = minetest.registered_tools[tool:get_name()]
@ -314,7 +314,7 @@ function minetest.handle_node_drops(pos, drops, digger)
end end
-- Spawn item and apply random speed -- Spawn item and apply random speed
local obj = minetest.add_item(dpos, drop_item) local obj = minetest.add_item(dpos, drop_item)
if obj ~= nil then if obj then
local x = math.random(1, 5) local x = math.random(1, 5)
if math.random(1,2) == 1 then if math.random(1,2) == 1 then
x = -x x = -x
@ -394,7 +394,7 @@ minetest.register_entity(":__builtin:item", {
-- The itemstring MUST be set immediately to a non-empty string after creating the entity. -- The itemstring MUST be set immediately to a non-empty string after creating the entity.
-- The hand is NOT permitted as dropped item. ;-) -- The hand is NOT permitted as dropped item. ;-)
-- Item entities will be deleted if they still have an empty itemstring on their first on_step tick. -- Item entities will be deleted if they still have an empty itemstring on their first on_step tick.
itemstring = '', itemstring = "",
-- If true, item will fall -- If true, item will fall
physical_state = true, physical_state = true,
@ -585,7 +585,7 @@ minetest.register_entity(":__builtin:item", {
return return
end end
self.age = self.age + dtime self.age = self.age + dtime
if self._collector_timer ~= nil then if self._collector_timer then
self._collector_timer = self._collector_timer + dtime self._collector_timer = self._collector_timer + dtime
end end
if time_to_live > 0 and self.age > time_to_live then if time_to_live > 0 and self.age > time_to_live then

View File

@ -1,9 +1,10 @@
local S = minetest.get_translator("mcl_minecarts") local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname)
local has_mcl_wip = minetest.get_modpath("mcl_wip") local has_mcl_wip = minetest.get_modpath("mcl_wip")
mcl_minecarts = {} mcl_minecarts = {}
mcl_minecarts.modpath = minetest.get_modpath("mcl_minecarts") mcl_minecarts.modpath = minetest.get_modpath(modname)
mcl_minecarts.speed_max = 10 mcl_minecarts.speed_max = 10
mcl_minecarts.check_float_time = 15 mcl_minecarts.check_float_time = 15
@ -204,7 +205,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o
rou_pos = vector.round(pos) rou_pos = vector.round(pos)
node = minetest.get_node(rou_pos) node = minetest.get_node(rou_pos)
local g = minetest.get_item_group(node.name, "connect_to_raillike") local g = minetest.get_item_group(node.name, "connect_to_raillike")
if g ~= self._railtype and self._railtype ~= nil then if g ~= self._railtype and self._railtype then
-- Detach driver -- Detach driver
if player then if player then
if self._old_pos then if self._old_pos then
@ -523,7 +524,7 @@ function mcl_minecarts.place_minecart(itemstack, pointed_thing, placer)
local cart = minetest.add_entity(railpos, entity_id) local cart = minetest.add_entity(railpos, entity_id)
local railtype = minetest.get_item_group(node.name, "connect_to_raillike") local railtype = minetest.get_item_group(node.name, "connect_to_raillike")
local le = cart:get_luaentity() local le = cart:get_luaentity()
if le ~= nil then if le then
le._railtype = railtype le._railtype = railtype
end end
local cart_dir = mcl_minecarts:get_rail_direction(railpos, {x=1, y=0, z=0}, nil, nil, railtype) local cart_dir = mcl_minecarts:get_rail_direction(railpos, {x=1, y=0, z=0}, nil, nil, railtype)
@ -606,7 +607,7 @@ Register a minecart
local function register_minecart(itemstring, entity_id, description, tt_help, longdesc, usagehelp, mesh, textures, icon, drop, on_rightclick, on_activate_by_rail, creative) local function register_minecart(itemstring, entity_id, description, tt_help, longdesc, usagehelp, mesh, textures, icon, drop, on_rightclick, on_activate_by_rail, creative)
register_entity(entity_id, mesh, textures, drop, on_rightclick, on_activate_by_rail) register_entity(entity_id, mesh, textures, drop, on_rightclick, on_activate_by_rail)
register_craftitem(itemstring, entity_id, description, tt_help, longdesc, usagehelp, icon, creative) register_craftitem(itemstring, entity_id, description, tt_help, longdesc, usagehelp, icon, creative)
if minetest.get_modpath("doc_identifier") ~= nil then if minetest.get_modpath("doc_identifier") then
doc.sub.identifier.register_object(entity_id, "craftitems", itemstring) doc.sub.identifier.register_object(entity_id, "craftitems", itemstring)
end end
end end

View File

@ -1,4 +1,4 @@
local S = minetest.get_translator("mcl_minecarts") local S = minetest.get_translator(minetest.get_current_modname())
-- Template rail function -- Template rail function
local function register_rail(itemstring, tiles, def_extras, creative) local function register_rail(itemstring, tiles, def_extras, creative)
@ -206,11 +206,11 @@ register_rail("mcl_minecarts:detector_rail_on",
-- Crafting -- Crafting
minetest.register_craft({ minetest.register_craft({
output = 'mcl_minecarts:rail 16', output = "mcl_minecarts:rail 16",
recipe = { recipe = {
{'mcl_core:iron_ingot', '', 'mcl_core:iron_ingot'}, {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"},
{'mcl_core:iron_ingot', 'mcl_core:stick', 'mcl_core:iron_ingot'}, {"mcl_core:iron_ingot", "mcl_core:stick", "mcl_core:iron_ingot"},
{'mcl_core:iron_ingot', '', 'mcl_core:iron_ingot'}, {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"},
} }
}) })

View File

@ -96,7 +96,7 @@ local mod_mobspawners = minetest_get_modpath("mcl_mobspawners")
--local height_switcher = false --local height_switcher = false
-- Get translator -- Get translator
local S = minetest.get_translator("mcl_mobs") local S = minetest.get_translator(minetest.get_current_modname())
-- CMI support check -- CMI support check
--local use_cmi = minetest.global_exists("cmi") --local use_cmi = minetest.global_exists("cmi")
@ -429,7 +429,7 @@ function mobs:register_mob(name, def)
--harmed_by_heal = def.harmed_by_heal, --harmed_by_heal = def.harmed_by_heal,
}) })
if minetest_get_modpath("doc_identifier") ~= nil then if minetest_get_modpath("doc_identifier") then
doc.sub.identifier.register_object(name, "basics", "mobs") doc.sub.identifier.register_object(name, "basics", "mobs")
end end

View File

@ -990,7 +990,7 @@ function mobs.mob_step(self, dtime)
if self.memory <= 0 then if self.memory <= 0 then
--reset states when coming out of hostile state --reset states when coming out of hostile state
if self.attacking ~= nil then if self.attacking then
self.state_timer = -1 self.state_timer = -1
end end

View File

@ -41,7 +41,7 @@ mobs.explode_attack_walk = function(self,dtime)
--make mob walk up to player within 2 nodes distance then start exploding --make mob walk up to player within 2 nodes distance then start exploding
if distance_from_attacking >= self.reach and if distance_from_attacking >= self.reach and
--don't allow explosion to cancel unless out of the reach boundary --don't allow explosion to cancel unless out of the reach boundary
not (self.explosion_animation ~= nil and self.explosion_animation > 0 and distance_from_attacking <= self.defuse_reach) then not (self.explosion_animation and self.explosion_animation > 0 and distance_from_attacking <= self.defuse_reach) then
mobs.set_velocity(self, self.run_velocity) mobs.set_velocity(self, self.run_velocity)
mobs.set_mob_animation(self,"run") mobs.set_mob_animation(self,"run")
@ -85,9 +85,8 @@ end
--this is a small helper function to make working with explosion animations easier --this is a small helper function to make working with explosion animations easier
mobs.reverse_explosion_animation = function(self,dtime) mobs.reverse_explosion_animation = function(self,dtime)
--if explosion animation was greater than 0 then reverse it --if explosion animation was greater than 0 then reverse it
if self.explosion_animation ~= nil and self.explosion_animation > 0 then if self.explosion_animation and self.explosion_animation > 0 then
self.explosion_animation = self.explosion_animation - dtime self.explosion_animation = self.explosion_animation - dtime
if self.explosion_animation < 0 then if self.explosion_animation < 0 then
self.explosion_animation = 0 self.explosion_animation = 0

View File

@ -36,9 +36,8 @@ mobs.shoot_projectile_handling = function(arrow_item, pos, dir, yaw, shooter, po
le._collectable = collectable le._collectable = collectable
--play custom shoot sound --play custom shoot sound
if shooter ~= nil and shooter.shoot_sound then if shooter and shooter.shoot_sound then
minetest.sound_play(shooter.shoot_sound, {pos=pos, max_hear_distance=16}, true) minetest.sound_play(shooter.shoot_sound, {pos=pos, max_hear_distance=16}, true)
end end
return obj return obj
end end

View File

@ -5,6 +5,7 @@ local get_node_light = minetest.get_node_light
local find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air local find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air
local get_biome_name = minetest.get_biome_name local get_biome_name = minetest.get_biome_name
local get_objects_inside_radius = minetest.get_objects_inside_radius local get_objects_inside_radius = minetest.get_objects_inside_radius
local get_connected_players = minetest.get_connected_players
local math_random = math.random local math_random = math.random
@ -18,6 +19,7 @@ local vector_floor = vector.floor
local table_copy = table.copy local table_copy = table.copy
local table_remove = table.remove local table_remove = table.remove
local pairs = pairs
-- range for mob count -- range for mob count
local aoc_range = 48 local aoc_range = 48
@ -279,7 +281,7 @@ function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_ligh
end end
-- if toggle set to nil then ignore day/night check -- if toggle set to nil then ignore day/night check
if day_toggle ~= nil then if day_toggle then
local tod = (minetest.get_timeofday() or 0) * 24000 local tod = (minetest.get_timeofday() or 0) * 24000
@ -369,7 +371,7 @@ function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_ligh
if minetest.registered_nodes[node_ok(pos2).name].walkable == true then if minetest.registered_nodes[node_ok(pos2).name].walkable == true then
-- inside block -- inside block
minetest.log("info", "Mob spawn of "..name.." at "..minetest.pos_to_string(pos).." failed, too little space!") minetest.log("info", "Mob spawn of "..name.." at "..minetest.pos_to_string(pos).." failed, too little space!")
if ent.spawn_small_alternative ~= nil and (not minetest.registered_nodes[node_ok(pos).name].walkable) then if ent.spawn_small_alternative and (not minetest.registered_nodes[node_ok(pos).name].walkable) then
minetest.log("info", "Trying to spawn smaller alternative mob: "..ent.spawn_small_alternative) minetest.log("info", "Trying to spawn smaller alternative mob: "..ent.spawn_small_alternative)
spawn_action(orig_pos, node, active_object_count, active_object_count_wider, ent.spawn_small_alternative) spawn_action(orig_pos, node, active_object_count, active_object_count_wider, ent.spawn_small_alternative)
end end
@ -540,7 +542,7 @@ if mobs_spawn then
timer = timer + dtime timer = timer + dtime
if timer >= 10 then if timer >= 10 then
timer = 0 timer = 0
for _,player in pairs(minetest.get_connected_players()) do for _,player in pairs(get_connected_players()) do
-- after this line each "break" means "continue" -- after this line each "break" means "continue"
local do_mob_spawning = true local do_mob_spawning = true
repeat repeat
@ -548,15 +550,15 @@ if mobs_spawn then
--they happen in a single server step --they happen in a single server step
local player_pos = player:get_pos() local player_pos = player:get_pos()
local _,dimension = mcl_worlds.y_to_layer(player_pos.y) local dimension = mcl_worlds.pos_to_dimension(player_pos)
if dimension == "void" or dimension == "default" then if dimension == "void" or dimension == "default" then
break -- ignore void and unloaded area break -- ignore void and unloaded area
end end
local min,max = decypher_limits(player_pos.y) local min, max = decypher_limits(player_pos.y)
for i = 1,math_random(1,4) do for i = 1, math_random(1,4) do
-- after this line each "break" means "continue" -- after this line each "break" means "continue"
local do_mob_algorithm = true local do_mob_algorithm = true
repeat repeat

View File

@ -1,5 +1,5 @@
local S = minetest.get_translator("mcl_mobs") local S = minetest.get_translator(minetest.get_current_modname())
-- name tag -- name tag
minetest.register_craftitem("mcl_mobs:nametag", { minetest.register_craftitem("mcl_mobs:nametag", {

View File

@ -1,8 +1,9 @@
mcl_paintings = {} mcl_paintings = {}
dofile(minetest.get_modpath(minetest.get_current_modname()).."/paintings.lua") local modname = minetest.get_current_modname()
dofile(minetest.get_modpath(modname).."/paintings.lua")
local S = minetest.get_translator("mcl_paintings") local S = minetest.get_translator(modname)
local math = math local math = math

View File

@ -8,7 +8,7 @@
-- NOTE: Most strings intentionally not marked for translation, other mods already have these items. -- NOTE: Most strings intentionally not marked for translation, other mods already have these items.
-- TODO: Remove this file eventually, most items are already outsourced in other mods. -- TODO: Remove this file eventually, most items are already outsourced in other mods.
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
local c = mobs_mc.is_item_variable_overridden local c = mobs_mc.is_item_variable_overridden
@ -234,8 +234,8 @@ end
if c("ender_eye") and c("blaze_powder") and c("blaze_rod") then if c("ender_eye") and c("blaze_powder") and c("blaze_rod") then
minetest.register_craft({ minetest.register_craft({
type = "shapeless", type = "shapeless",
output = 'mobs_mc:ender_eye', output = "mobs_mc:ender_eye",
recipe = { 'mobs_mc:blaze_powder', 'mobs_mc:blaze_rod'}, recipe = { "mobs_mc:blaze_powder", "mobs_mc:blaze_rod"},
}) })
end end

View File

@ -6,7 +6,7 @@
-- NOTE: Strings intentionally not marked for translation, other mods already have these items. -- 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: Remove this file eventually, all items here are already outsourced in other mods.
--local S = minetest.get_translator("mobs_mc") --local S = minetest.get_translator(minetest.get_current_modname())
--maikerumines throwing code --maikerumines throwing code
--arrow (weapon) --arrow (weapon)
@ -83,7 +83,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if self.timer>0.2 then if self.timer>0.2 then
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1.5) local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1.5)
for k, obj in pairs(objs) do for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then if obj:get_luaentity() then
if obj:get_luaentity().name ~= "mobs_mc:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then if obj:get_luaentity().name ~= "mobs_mc:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then
local damage = 3 local damage = 3
minetest.sound_play("damage", {pos = pos}, true) minetest.sound_play("damage", {pos = pos}, true)
@ -108,7 +108,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if self.lastpos.x~=nil then if self.lastpos.x~=nil then
if node.name ~= "air" then if node.name ~= "air" then
minetest.sound_play("bowhit1", {pos = pos}, true) minetest.sound_play("bowhit1", {pos = pos}, true)
minetest.add_item(self.lastpos, 'mobs_mc:arrow') minetest.add_item(self.lastpos, "mobs_mc:arrow")
self.object:remove() self.object:remove()
end end
end end
@ -155,7 +155,7 @@ end
if c("arrow") and c("flint") and c("feather") and c("stick") then if c("arrow") and c("flint") and c("feather") and c("stick") then
minetest.register_craft({ minetest.register_craft({
output = 'mobs_mc:arrow 4', output = "mobs_mc:arrow 4",
recipe = { recipe = {
{mobs_mc.items.flint}, {mobs_mc.items.flint},
{mobs_mc.items.stick}, {mobs_mc.items.stick},
@ -181,11 +181,11 @@ if c("bow") then
}) })
minetest.register_craft({ minetest.register_craft({
output = 'mobs_mc:bow_wood', output = "mobs_mc:bow_wood",
recipe = { recipe = {
{mobs_mc.items.string, mobs_mc.items.stick, ''}, {mobs_mc.items.string, mobs_mc.items.stick, ""},
{mobs_mc.items.string, '', mobs_mc.items.stick}, {mobs_mc.items.string, "", mobs_mc.items.stick},
{mobs_mc.items.string, mobs_mc.items.stick, ''}, {mobs_mc.items.string, mobs_mc.items.stick, ""},
} }
}) })
end end
@ -259,7 +259,7 @@ if c("egg") then
}) })
-- shoot egg -- shoot egg
local mobs_shoot_egg = function (item, player, pointed_thing) local function mobs_shoot_egg(item, player, pointed_thing)
local playerpos = player:get_pos() local playerpos = player:get_pos()
@ -349,7 +349,7 @@ mobs:register_arrow("mobs_mc:snowball_entity", {
if c("snowball") then if c("snowball") then
-- shoot snowball -- shoot snowball
local mobs_shoot_snowball = function (item, player, pointed_thing) local function mobs_shoot_snowball(item, player, pointed_thing)
local playerpos = player:get_pos() local playerpos = player:get_pos()

View File

@ -5,7 +5,7 @@
-- TODO: Remove this file eventually, all items here are already outsourced in other mods. -- TODO: Remove this file eventually, all items here are already outsourced in other mods.
-- TODO: Add translation. -- TODO: Add translation.
--local S = minetest.get_translator("mobs_mc") --local S = local S = minetest.get_translator(minetest.get_current_modname())
-- Heads system -- Heads system

View File

@ -2,7 +2,7 @@
--################### AGENT - seemingly unused --################### AGENT - seemingly unused
--################### --###################
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
mobs:register_mob("mobs_mc:agent", { mobs:register_mob("mobs_mc:agent", {
type = "npc", type = "npc",

View File

@ -1,6 +1,6 @@
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
mobs:register_mob("mobs_mc:bat", { mobs:register_mob("mobs_mc:bat", {
description = S("Bat"), description = S("Bat"),

View File

@ -3,7 +3,7 @@
-- Model and mobs_blaze.png see https://github.com/22i/minecraft-voxel-blender-models -hi 22i ~jordan4ibanez -- Model and mobs_blaze.png see https://github.com/22i/minecraft-voxel-blender-models -hi 22i ~jordan4ibanez
-- blaze.lua partial copy of mobs_mc/ghast.lua -- blaze.lua partial copy of mobs_mc/ghast.lua
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### BLAZE --################### BLAZE

View File

@ -1,6 +1,6 @@
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### CHICKEN --################### CHICKEN

View File

@ -1,6 +1,6 @@
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
local cow_def = { local cow_def = {
description = S("Cow"), description = S("Cow"),

View File

@ -1,6 +1,6 @@
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### CREEPER --################### CREEPER
@ -72,7 +72,7 @@ mobs:register_mob("mobs_mc:creeper", {
-- TODO: Make creeper flash after doing this as well. -- TODO: Make creeper flash after doing this as well.
-- TODO: Test and debug this code. -- TODO: Test and debug this code.
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
if self._forced_explosion_countdown_timer ~= nil then if self._forced_explosion_countdown_timer then
return return
end end
local item = clicker:get_wielded_item() local item = clicker:get_wielded_item()
@ -92,7 +92,7 @@ mobs:register_mob("mobs_mc:creeper", {
end end
end, end,
do_custom = function(self, dtime) do_custom = function(self, dtime)
if self._forced_explosion_countdown_timer ~= nil then if self._forced_explosion_countdown_timer then
self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime
if self._forced_explosion_countdown_timer <= 0 then if self._forced_explosion_countdown_timer <= 0 then
mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength) mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength)
@ -196,7 +196,7 @@ mobs:register_mob("mobs_mc:creeper_charged", {
-- TODO: Make creeper flash after doing this as well. -- TODO: Make creeper flash after doing this as well.
-- TODO: Test and debug this code. -- TODO: Test and debug this code.
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
if self._forced_explosion_countdown_timer ~= nil then if self._forced_explosion_countdown_timer then
return return
end end
local item = clicker:get_wielded_item() local item = clicker:get_wielded_item()
@ -216,7 +216,7 @@ mobs:register_mob("mobs_mc:creeper_charged", {
end end
end, end,
do_custom = function(self, dtime) do_custom = function(self, dtime)
if self._forced_explosion_countdown_timer ~= nil then if self._forced_explosion_countdown_timer then
self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime
if self._forced_explosion_countdown_timer <= 0 then if self._forced_explosion_countdown_timer <= 0 then
mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength) mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength)

View File

@ -2,7 +2,7 @@
--################### ENDERDRAGON --################### ENDERDRAGON
--################### --###################
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
mobs:register_mob("mobs_mc:enderdragon", { mobs:register_mob("mobs_mc:enderdragon", {
description = S("Ender Dragon"), description = S("Ender Dragon"),

View File

@ -24,9 +24,11 @@
-- added rain damage. -- added rain damage.
-- fixed the grass_with_dirt issue. -- fixed the grass_with_dirt issue.
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
local telesound = function(pos, is_source) local vector = vector
local function telesound(pos, is_source)
local snd local snd
if is_source then if is_source then
snd = "mobs_mc_enderman_teleport_src" snd = "mobs_mc_enderman_teleport_src"
@ -302,7 +304,7 @@ mobs:register_mob("mobs_mc:enderman", {
if self.attacking then if self.attacking then
local target = self.attacking local target = self.attacking
local pos = target:get_pos() local pos = target:get_pos()
if pos ~= nil then if pos then
if vector.distance(self.object:get_pos(), target:get_pos()) > 10 then if vector.distance(self.object:get_pos(), target:get_pos()) > 10 then
self:teleport(target) self:teleport(target)
end end
@ -341,8 +343,8 @@ mobs:register_mob("mobs_mc:enderman", {
-- self:teleport(nil) -- self:teleport(nil)
-- self.state = "" -- self.state = ""
--else --else
if self.attack ~= nil and not minetest.settings:get_bool("creative_mode") then if self.attack and not minetest.settings:get_bool("creative_mode") then
self.state = 'attack' self.state = "attack"
end end
--end --end
end end
@ -459,7 +461,7 @@ mobs:register_mob("mobs_mc:enderman", {
end end
end end
end end
elseif self._taken_node ~= nil and self._taken_node ~= "" and self._take_place_timer >= self._next_take_place_time then elseif self._taken_node and self._taken_node ~= "" and self._take_place_timer >= self._next_take_place_time then
-- Place taken node -- Place taken node
self._take_place_timer = 0 self._take_place_timer = 0
self._next_take_place_time = math.random(take_frequency_min, take_frequency_max) self._next_take_place_time = math.random(take_frequency_min, take_frequency_max)
@ -485,12 +487,12 @@ mobs:register_mob("mobs_mc:enderman", {
end end
end, end,
do_teleport = function(self, target) do_teleport = function(self, target)
if target ~= nil then if target then
local target_pos = target:get_pos() local target_pos = target:get_pos()
-- Find all solid nodes below air in a 10×10×10 cuboid centered on the target -- Find all solid nodes below air in a 10×10×10 cuboid centered on the target
local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(target_pos, 5), vector.add(target_pos, 5), {"group:solid", "group:cracky", "group:crumbly"}) local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(target_pos, 5), vector.add(target_pos, 5), {"group:solid", "group:cracky", "group:crumbly"})
local telepos local telepos
if nodes ~= nil then if nodes then
if #nodes > 0 then if #nodes > 0 then
-- Up to 64 attempts to teleport -- Up to 64 attempts to teleport
for n=1, math.min(64, #nodes) do for n=1, math.min(64, #nodes) do
@ -525,7 +527,7 @@ mobs:register_mob("mobs_mc:enderman", {
-- We need to add (or subtract) different random numbers to each vector component, so it couldn't be done with a nice single vector.add() or .subtract(): -- We need to add (or subtract) different random numbers to each vector component, so it couldn't be done with a nice single vector.add() or .subtract():
local randomCube = vector.new( pos.x + 8*(pr:next(0,16)-8), pos.y + 8*(pr:next(0,16)-8), pos.z + 8*(pr:next(0,16)-8) ) local randomCube = vector.new( pos.x + 8*(pr:next(0,16)-8), pos.y + 8*(pr:next(0,16)-8), pos.z + 8*(pr:next(0,16)-8) )
local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(randomCube, 4), vector.add(randomCube, 4), {"group:solid", "group:cracky", "group:crumbly"}) local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(randomCube, 4), vector.add(randomCube, 4), {"group:solid", "group:cracky", "group:crumbly"})
if nodes ~= nil then if nodes then
if #nodes > 0 then if #nodes > 0 then
-- Up to 8 low-level (in total up to 8*8 = 64) attempts to teleport -- Up to 8 low-level (in total up to 8*8 = 64) attempts to teleport
for n=1, math.min(8, #nodes) do for n=1, math.min(8, #nodes) do
@ -557,13 +559,13 @@ mobs:register_mob("mobs_mc:enderman", {
end, end,
on_die = function(self, pos) on_die = function(self, pos)
-- Drop carried node on death -- Drop carried node on death
if self._taken_node ~= nil and self._taken_node ~= "" then if self._taken_node and self._taken_node ~= "" then
minetest.add_item(pos, self._taken_node) minetest.add_item(pos, self._taken_node)
end end
end, end,
do_punch = function(self, hitter, tflp, tool_caps, dir) do_punch = function(self, hitter, tflp, tool_caps, dir)
-- damage from rain caused by itself so we don't want it to attack itself. -- damage from rain caused by itself so we don't want it to attack itself.
if hitter ~= self.object and hitter ~= nil then if hitter ~= self.object and hitter then
--if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then --if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then
-- self:teleport(nil) -- self:teleport(nil)
--else --else

View File

@ -2,7 +2,7 @@
--################### ENDERMITE --################### ENDERMITE
--################### --###################
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
mobs:register_mob("mobs_mc:endermite", { mobs:register_mob("mobs_mc:endermite", {
description = S("Endermite"), description = S("Endermite"),

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### GHAST --################### GHAST

View File

@ -2,7 +2,7 @@
--################### GUARDIAN --################### GUARDIAN
--################### --###################
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
mobs:register_mob("mobs_mc:guardian", { mobs:register_mob("mobs_mc:guardian", {
description = S("Guardian"), description = S("Guardian"),

View File

@ -4,7 +4,7 @@
--################### GUARDIAN --################### GUARDIAN
--################### --###################
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
mobs:register_mob("mobs_mc:guardian_elder", { mobs:register_mob("mobs_mc:guardian_elder", {
description = S("Elder Guardian"), description = S("Elder Guardian"),

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### HORSE --################### HORSE

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local path = minetest.get_modpath("mobs_mc") local path = minetest.get_modpath(minetest.get_current_modname())
if not minetest.get_modpath("mobs_mc_gameconfig") then if not minetest.get_modpath("mobs_mc_gameconfig") then
mobs_mc = {} mobs_mc = {}

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### IRON GOLEM --################### IRON GOLEM

View File

@ -1,4 +1,4 @@
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### LLAMA --################### LLAMA

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### OCELOT AND CAT --################### OCELOT AND CAT

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### PARROT --################### PARROT

View File

@ -1,6 +1,6 @@
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
mobs:register_mob("mobs_mc:pig", { mobs:register_mob("mobs_mc:pig", {
description = S("Pig"), description = S("Pig"),

View File

@ -1,6 +1,6 @@
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### POLARBEAR --################### POLARBEAR

View File

@ -1,6 +1,6 @@
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
local rabbit = { local rabbit = {
description = S("Rabbit"), description = S("Rabbit"),

View File

@ -1,6 +1,6 @@
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### SHEEP --################### SHEEP
@ -38,7 +38,7 @@ local rainbow_colors = {
"unicolor_red_violet" "unicolor_red_violet"
} }
if minetest.get_modpath("mcl_wool") ~= nil then if minetest.get_modpath("mcl_wool") then
colors["unicolor_light_blue"] = { mobs_mc.items.wool_light_blue, "#5050FFD0" } colors["unicolor_light_blue"] = { mobs_mc.items.wool_light_blue, "#5050FFD0" }
end end

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### SHULKER --################### SHULKER

View File

@ -2,7 +2,7 @@
--################### SILVERFISH --################### SILVERFISH
--################### --###################
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
mobs:register_mob("mobs_mc:silverfish", { mobs:register_mob("mobs_mc:silverfish", {
description = S("Silverfish"), description = S("Silverfish"),
@ -61,7 +61,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then
description = "Stone Monster Egg", description = "Stone Monster Egg",
tiles = {"default_stone.png"}, tiles = {"default_stone.png"},
groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1},
drop = '', drop = "",
is_ground_content = true, is_ground_content = true,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
after_dig_node = spawn_silverfish, after_dig_node = spawn_silverfish,
@ -72,7 +72,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then
tiles = {"default_cobble.png"}, tiles = {"default_cobble.png"},
is_ground_content = false, is_ground_content = false,
groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1},
drop = '', drop = "",
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
after_dig_node = spawn_silverfish, after_dig_node = spawn_silverfish,
}) })
@ -82,7 +82,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then
tiles = {"default_mossycobble.png"}, tiles = {"default_mossycobble.png"},
is_ground_content = false, is_ground_content = false,
groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1},
drop = '', drop = "",
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
after_dig_node = spawn_silverfish, after_dig_node = spawn_silverfish,
}) })
@ -94,7 +94,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then
tiles = {"default_stone_brick.png"}, tiles = {"default_stone_brick.png"},
is_ground_content = false, is_ground_content = false,
groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1},
drop = '', drop = "",
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
after_dig_node = spawn_silverfish, after_dig_node = spawn_silverfish,
}) })
@ -104,7 +104,7 @@ if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then
tiles = {"default_stone_block.png"}, tiles = {"default_stone_block.png"},
is_ground_content = false, is_ground_content = false,
groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1}, groups = {oddly_breakable_by_hand = 2, spawns_silverfish = 1},
drop = '', drop = "",
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
after_dig_node = spawn_silverfish, after_dig_node = spawn_silverfish,
}) })

View File

@ -3,8 +3,8 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
local mod_bows = minetest.get_modpath("mcl_bows") ~= nil local mod_bows = minetest.get_modpath("mcl_bows")
--################### --###################
--################### SKELETON --################### SKELETON

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### WITHER SKELETON --################### WITHER SKELETON

View File

@ -1,6 +1,6 @@
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
-- Returns a function that spawns children in a circle around pos. -- Returns a function that spawns children in a circle around pos.
-- To be used as on_die callback. -- To be used as on_die callback.
@ -41,10 +41,10 @@ local spawn_children_on_die = function(child_mob, children_count, spawn_distance
-- If mother was murdered, children attack the killer after 1 second -- If mother was murdered, children attack the killer after 1 second
if self.state == "attack" then if self.state == "attack" then
minetest.after(1.0, function(children, enemy) minetest.after(1.0, function(children, enemy)
for c=1, #children do for c = 1, #children do
local child = children[c] local child = children[c]
local le = child:get_luaentity() local le = child:get_luaentity()
if le ~= nil then if le then
le.state = "attack" le.state = "attack"
le.attack = enemy le.attack = enemy
end end

View File

@ -3,12 +3,12 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
local snow_trail_frequency = 0.5 -- Time in seconds for checking to add a new snow trail local snow_trail_frequency = 0.5 -- Time in seconds for checking to add a new snow trail
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
local mod_throwing = minetest.get_modpath("mcl_throwing") ~= nil local mod_throwing = minetest.get_modpath("mcl_throwing")
local gotten_texture = { local gotten_texture = {
"mobs_mc_snowman.png", "mobs_mc_snowman.png",

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### SPIDER --################### SPIDER

View File

@ -4,7 +4,7 @@
--################### SQUID --################### SQUID
--################### --###################
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
mobs:register_mob("mobs_mc:squid", { mobs:register_mob("mobs_mc:squid", {
description = S("Squid"), description = S("Squid"),

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### VEX --################### VEX

View File

@ -19,7 +19,7 @@
-- TODO: Internal inventory, pick up items, trade with other villagers -- TODO: Internal inventory, pick up items, trade with other villagers
-- TODO: Farm stuff -- TODO: Farm stuff
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
local N = function(s) return s end local N = function(s) return s end
local F = minetest.formspec_escape local F = minetest.formspec_escape

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### EVOKER --################### EVOKER

View File

@ -3,8 +3,8 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
local mod_bows = minetest.get_modpath("mcl_bows") ~= nil local mod_bows = minetest.get_modpath("mcl_bows")
mobs:register_mob("mobs_mc:illusioner", { mobs:register_mob("mobs_mc:illusioner", {
description = S("Illusioner"), description = S("Illusioner"),

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### VINDICATOR --################### VINDICATOR

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### ZOMBIE VILLAGER --################### ZOMBIE VILLAGER

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### WITCH --################### WITCH

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### WITHER --################### WITHER

View File

@ -1,6 +1,6 @@
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
local default_walk_chance = 50 local default_walk_chance = 50

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### ZOMBIE --################### ZOMBIE

View File

@ -3,7 +3,7 @@
--made for MC like Survival game --made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes --License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator(minetest.get_current_modname())
--################### --###################
--################### ZOMBIE PIGMAN --################### ZOMBIE PIGMAN

View File

@ -1,4 +1,4 @@
local S = minetest.get_translator("mcl_void_damage") local S = minetest.get_translator(minetest.get_current_modname())
--local enable_damage = minetest.settings:get_bool("enable_damage") --local enable_damage = minetest.settings:get_bool("enable_damage")
local pos_to_dim = mcl_worlds.pos_to_dimension local pos_to_dim = mcl_worlds.pos_to_dimension

View File

@ -1,4 +1,4 @@
local modpath = minetest.get_modpath("mcl_weather") local modpath = minetest.get_modpath(minetest.get_current_modname())
mcl_weather = {} mcl_weather = {}
@ -12,6 +12,6 @@ dofile(modpath.."/snow.lua")
dofile(modpath.."/rain.lua") dofile(modpath.."/rain.lua")
dofile(modpath.."/nether_dust.lua") dofile(modpath.."/nether_dust.lua")
if minetest.get_modpath("lightning") ~= nil then if minetest.get_modpath("lightning") then
dofile(modpath.."/thunder.lua") dofile(modpath.."/thunder.lua")
end end

View File

@ -96,7 +96,7 @@ end
-- be sure to remove sound before removing player otherwise soundhandler reference will be lost. -- be sure to remove sound before removing player otherwise soundhandler reference will be lost.
function mcl_weather.rain.remove_player(player) function mcl_weather.rain.remove_player(player)
local player_meta = mcl_weather.players[player:get_player_name()] local player_meta = mcl_weather.players[player:get_player_name()]
if player_meta ~= nil and player_meta.origin_sky ~= nil then if player_meta and player_meta.origin_sky then
player:set_clouds({color="#FFF0F0E5"}) player:set_clouds({color="#FFF0F0E5"})
mcl_weather.players[player:get_player_name()] = nil mcl_weather.players[player:get_player_name()] = nil
end end
@ -120,12 +120,12 @@ end)
-- when player stay on 'edge' where sound should play and stop depending from random raindrop appearance. -- when player stay on 'edge' where sound should play and stop depending from random raindrop appearance.
function mcl_weather.rain.update_sound(player) function mcl_weather.rain.update_sound(player)
local player_meta = mcl_weather.players[player:get_player_name()] local player_meta = mcl_weather.players[player:get_player_name()]
if player_meta ~= nil then if player_meta then
if player_meta.sound_updated ~= nil and player_meta.sound_updated + 5 > minetest.get_gametime() then if player_meta.sound_updated and player_meta.sound_updated + 5 > minetest.get_gametime() then
return false return false
end end
if player_meta.sound_handler ~= nil then if player_meta.sound_handler then
if mcl_weather.rain.last_rp_count == 0 then if mcl_weather.rain.last_rp_count == 0 then
minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0) minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0)
player_meta.sound_handler = nil player_meta.sound_handler = nil
@ -141,7 +141,7 @@ end
-- rain sound removed from player. -- rain sound removed from player.
function mcl_weather.rain.remove_sound(player) function mcl_weather.rain.remove_sound(player)
local player_meta = mcl_weather.players[player:get_player_name()] local player_meta = mcl_weather.players[player:get_player_name()]
if player_meta ~= nil and player_meta.sound_handler ~= nil then if player_meta and player_meta.sound_handler then
minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0) minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0)
player_meta.sound_handler = nil player_meta.sound_handler = nil
player_meta.sound_updated = nil player_meta.sound_updated = nil

View File

@ -1,4 +1,4 @@
local S = minetest.get_translator("mcl_weather") local S = minetest.get_translator(minetest.get_current_modname())
local math = math local math = math
@ -49,7 +49,7 @@ minetest.register_on_shutdown(save_weather)
function mcl_weather.get_rand_end_time(min_duration, max_duration) function mcl_weather.get_rand_end_time(min_duration, max_duration)
local r local r
if min_duration ~= nil and max_duration ~= nil then if min_duration and max_duration then
r = math.random(min_duration, max_duration) r = math.random(min_duration, max_duration)
else else
r = math.random(mcl_weather.min_duration, mcl_weather.max_duration) r = math.random(mcl_weather.min_duration, mcl_weather.max_duration)
@ -170,8 +170,8 @@ end
function mcl_weather.change_weather(new_weather, explicit_end_time, changer_name) function mcl_weather.change_weather(new_weather, explicit_end_time, changer_name)
local changer_name = changer_name or debug.getinfo(2).name.."()" local changer_name = changer_name or debug.getinfo(2).name.."()"
if (mcl_weather.reg_weathers ~= nil and mcl_weather.reg_weathers[new_weather] ~= nil) then if (mcl_weather.reg_weathers and mcl_weather.reg_weathers[new_weather]) then
if (mcl_weather.state ~= nil and mcl_weather.reg_weathers[mcl_weather.state] ~= nil) then if (mcl_weather.state and mcl_weather.reg_weathers[mcl_weather.state]) then
mcl_weather.reg_weathers[mcl_weather.state].clear() mcl_weather.reg_weathers[mcl_weather.state].clear()
end end
@ -269,7 +269,7 @@ minetest.register_chatcommand("toggledownfall", {
-- Configuration setting which allows user to disable ABM for weathers (if they use it). -- Configuration setting which allows user to disable ABM for weathers (if they use it).
-- Weather mods expected to be use this flag before registering ABM. -- Weather mods expected to be use this flag before registering ABM.
local weather_allow_abm = minetest.settings:get_bool("weather_allow_abm") local weather_allow_abm = minetest.settings:get_bool("weather_allow_abm")
if weather_allow_abm ~= nil and weather_allow_abm == false then if weather_allow_abm == false then
mcl_weather.allow_abm = false mcl_weather.allow_abm = false
end end

View File

@ -1,6 +1,10 @@
local S = minetest.get_translator("doc") local S = minetest.get_translator(minetest.get_current_modname())
local F = function(f) return minetest.formspec_escape(S(f)) end local F = function(f) return minetest.formspec_escape(S(f)) end
local mod_central_messages = minetest.get_modpath("central_message")
local mod_inventory_plus = minetest.get_modpath("inventory_plus")
local math = math
local colorize = minetest.colorize local colorize = minetest.colorize
doc = {} doc = {}
@ -63,7 +67,7 @@ local set_category_order_was_called = false
local function get_entry(category_id, entry_id) local function get_entry(category_id, entry_id)
local category = doc.data.categories[category_id] local category = doc.data.categories[category_id]
local entry local entry
if category ~= nil then if category then
entry = category.entries[entry_id] entry = category.entries[entry_id]
end end
if category == nil or entry == nil then if category == nil or entry == nil then
@ -93,7 +97,7 @@ end
-- Add a new category -- Add a new category
function doc.add_category(id, def) function doc.add_category(id, def)
if doc.data.categories[id] == nil and id ~= nil then if doc.data.categories[id] == nil and id then
doc.data.categories[id] = {} doc.data.categories[id] = {}
doc.data.categories[id].entries = {} doc.data.categories[id].entries = {}
doc.data.categories[id].entry_count = 0 doc.data.categories[id].entry_count = 0
@ -123,7 +127,7 @@ end
-- Add a new entry -- Add a new entry
function doc.add_entry(category_id, entry_id, def) function doc.add_entry(category_id, entry_id, def)
local cat = doc.data.categories[category_id] local cat = doc.data.categories[category_id]
if cat ~= nil then if cat then
local hidden = def.hidden or (def.hidden == nil and cat.def.hide_entries_by_default) local hidden = def.hidden or (def.hidden == nil and cat.def.hide_entries_by_default)
if hidden then if hidden then
cat.hidden_count = cat.hidden_count + 1 cat.hidden_count = cat.hidden_count + 1
@ -177,7 +181,7 @@ function doc.mark_entry_as_revealed(playername, category_id, entry_id)
doc.data.players[playername].entry_textlist_needs_updating = true doc.data.players[playername].entry_textlist_needs_updating = true
-- Notify player of entry revelation -- Notify player of entry revelation
if doc.data.players[playername].stored_data.notify_on_reveal == true then if doc.data.players[playername].stored_data.notify_on_reveal == true then
if minetest.get_modpath("central_message") ~= nil then if mod_central_messages then
local cat = doc.data.categories[category_id] local cat = doc.data.categories[category_id]
cmsg.push_message_player(minetest.get_player_by_name(playername), S("New help entry unlocked: @1 > @2", cat.def.name, entry.name)) cmsg.push_message_player(minetest.get_player_by_name(playername), S("New help entry unlocked: @1 > @2", cat.def.name, entry.name))
end end
@ -224,7 +228,7 @@ function doc.mark_all_entries_as_revealed(playername)
msg = S("All help entries are already revealed.") msg = S("All help entries are already revealed.")
end end
-- Notify -- Notify
if minetest.get_modpath("central_message") ~= nil then if mod_central_messages then
cmsg.push_message_player(minetest.get_player_by_name(playername), msg) cmsg.push_message_player(minetest.get_player_by_name(playername), msg)
else else
minetest.chat_send_player(playername, msg) minetest.chat_send_player(playername, msg)
@ -427,7 +431,7 @@ end
-- Returns the currently viewed entry and/or category of the player -- Returns the currently viewed entry and/or category of the player
function doc.get_selection(playername) function doc.get_selection(playername)
local playerdata = doc.data.players[playername] local playerdata = doc.data.players[playername]
if playerdata ~= nil then if playerdata then
local cat = playerdata.category local cat = playerdata.category
if cat then if cat then
local entry = playerdata.entry local entry = playerdata.entry
@ -459,7 +463,7 @@ function doc.entry_builders.text_and_gallery(data, playername)
local stolen_height = 0 local stolen_height = 0
local formstring = "" local formstring = ""
-- Only add the gallery if images are in the data, otherwise, the text widget gets all of the space -- Only add the gallery if images are in the data, otherwise, the text widget gets all of the space
if data.images ~= nil then if data.images then
local gallery local gallery
gallery, stolen_height = doc.widgets.gallery(data.images, playername, nil, doc.FORMSPEC.ENTRY_END_Y + 0.2, nil, nil, nil, nil, false) gallery, stolen_height = doc.widgets.gallery(data.images, playername, nil, doc.FORMSPEC.ENTRY_END_Y + 0.2, nil, nil, nil, nil, false)
formstring = formstring .. gallery formstring = formstring .. gallery
@ -605,7 +609,7 @@ do
minetest.log("action", "[doc] doc.mt opened.") minetest.log("action", "[doc] doc.mt opened.")
local string = file:read() local string = file:read()
io.close(file) io.close(file)
if(string ~= nil) then if string then
local savetable = minetest.deserialize(string) local savetable = minetest.deserialize(string)
for name, players_stored_data in pairs(savetable.players_stored_data) do for name, players_stored_data in pairs(savetable.players_stored_data) do
doc.data.players[name] = {} doc.data.players[name] = {}
@ -672,12 +676,12 @@ function doc.formspec_main(playername)
local data = doc.data.categories[id] local data = doc.data.categories[id]
local bw = doc.FORMSPEC.WIDTH / math.floor(((doc.data.category_count-1) / CATEGORYFIELDSIZE.HEIGHT)+1) local bw = doc.FORMSPEC.WIDTH / math.floor(((doc.data.category_count-1) / CATEGORYFIELDSIZE.HEIGHT)+1)
-- Skip categories which do not exist -- Skip categories which do not exist
if data ~= nil then if data then
-- Category buton -- Category buton
local button = "button["..((x-1)*bw)..","..y..";"..bw..",1;doc_button_category_"..id..";"..minetest.formspec_escape(data.def.name).."]" local button = "button["..((x-1)*bw)..","..y..";"..bw..",1;doc_button_category_"..id..";"..minetest.formspec_escape(data.def.name).."]"
local tooltip = "" local tooltip = ""
-- Optional description -- Optional description
if data.def.description ~= nil then if data.def.description then
tooltip = "tooltip[doc_button_category_"..id..";"..minetest.formspec_escape(data.def.description).."]" tooltip = "tooltip[doc_button_category_"..id..";"..minetest.formspec_escape(data.def.description).."]"
end end
formstring = formstring .. button .. tooltip formstring = formstring .. button .. tooltip
@ -701,7 +705,7 @@ function doc.formspec_main(playername)
end end
end end
local sel = doc.data.categories[doc.data.players[playername].category] local sel = doc.data.categories[doc.data.players[playername].category]
if sel ~= nil then if sel then
formstring = formstring .. ";" formstring = formstring .. ";"
formstring = formstring .. doc.data.categories[doc.data.players[playername].category].order_position formstring = formstring .. doc.data.categories[doc.data.players[playername].category].order_position
end end
@ -711,7 +715,7 @@ function doc.formspec_main(playername)
notify_checkbox_y = doc.FORMSPEC.HEIGHT-1 notify_checkbox_y = doc.FORMSPEC.HEIGHT-1
end end
local text local text
if minetest.get_modpath("central_message") then if mod_central_messages then
text = F("Notify me when new help is available") text = F("Notify me when new help is available")
else else
text = F("Play notification sound when new help is available") text = F("Play notification sound when new help is available")
@ -944,7 +948,7 @@ function doc.process_form(player,formname,fields)
local playername = player:get_player_name() local playername = player:get_player_name()
--[[ process clicks on the tab header ]] --[[ process clicks on the tab header ]]
if(formname == "doc:main" or formname == "doc:category" or formname == "doc:entry") then if(formname == "doc:main" or formname == "doc:category" or formname == "doc:entry") then
if fields.doc_header ~= nil then if fields.doc_header then
local tab = tonumber(fields.doc_header) local tab = tonumber(fields.doc_header)
local formspec, subformname, contents local formspec, subformname, contents
local cid, eid local cid, eid
@ -959,7 +963,7 @@ function doc.process_form(player,formname,fields)
elseif(tab==3) then elseif(tab==3) then
doc.data.players[playername].galidx = 1 doc.data.players[playername].galidx = 1
contents = doc.formspec_entry(cid, eid, playername) contents = doc.formspec_entry(cid, eid, playername)
if cid ~= nil and eid ~= nil then if cid and eid then
doc.mark_entry_as_viewed(playername, cid, eid) doc.mark_entry_as_viewed(playername, cid, eid)
end end
subformname = "entry" subformname = "entry"
@ -984,7 +988,7 @@ function doc.process_form(player,formname,fields)
if fields["doc_mainlist"] then if fields["doc_mainlist"] then
local event = minetest.explode_textlist_event(fields["doc_mainlist"]) local event = minetest.explode_textlist_event(fields["doc_mainlist"])
local cid = doc.data.category_order[event.index] local cid = doc.data.category_order[event.index]
if cid ~= nil then if cid then
if event.type == "CHG" then if event.type == "CHG" then
doc.data.players[playername].catsel = nil doc.data.players[playername].catsel = nil
doc.data.players[playername].category = cid doc.data.players[playername].category = cid
@ -1014,10 +1018,10 @@ function doc.process_form(player,formname,fields)
elseif(formname == "doc:category") then elseif(formname == "doc:category") then
if fields["doc_button_goto_entry"] then if fields["doc_button_goto_entry"] then
local cid = doc.data.players[playername].category local cid = doc.data.players[playername].category
if cid ~= nil then if cid then
local eid = nil local eid = nil
local eids, catsel = doc.data.players[playername].entry_ids, doc.data.players[playername].catsel local eids, catsel = doc.data.players[playername].entry_ids, doc.data.players[playername].catsel
if eids ~= nil and catsel ~= nil then if eids and catsel then
eid = eids[catsel] eid = eids[catsel]
end end
doc.data.players[playername].galidx = 1 doc.data.players[playername].galidx = 1
@ -1040,7 +1044,7 @@ function doc.process_form(player,formname,fields)
local cid = doc.data.players[playername].category local cid = doc.data.players[playername].category
local eid = nil local eid = nil
local eids, catsel = doc.data.players[playername].entry_ids, event.index local eids, catsel = doc.data.players[playername].entry_ids, event.index
if eids ~= nil and catsel ~= nil then if eids and catsel then
eid = eids[catsel] eid = eids[catsel]
end end
doc.mark_entry_as_viewed(playername, cid, eid) doc.mark_entry_as_viewed(playername, cid, eid)
@ -1101,7 +1105,7 @@ function doc.process_form(player,formname,fields)
minetest.show_formspec(playername, "doc:entry", formspec) minetest.show_formspec(playername, "doc:entry", formspec)
end end
else else
if fields["doc_inventory_plus"] and minetest.get_modpath("inventory_plus") then if fields["doc_inventory_plus"] and mod_inventory_plus then
doc.show_doc(playername) doc.show_doc(playername)
return return
end end
@ -1169,7 +1173,7 @@ minetest.register_on_joinplayer(function(player)
end end
-- Add button for Inventory++ -- Add button for Inventory++
if minetest.get_modpath("inventory_plus") ~= nil then if mod_inventory_plus then
inventory_plus.register_button(player, "doc_inventory_plus", S("Help")) inventory_plus.register_button(player, "doc_inventory_plus", S("Help"))
end end
end) end)
@ -1180,7 +1184,7 @@ local function button_action(player)
end end
-- Unified Inventory -- Unified Inventory
if minetest.get_modpath("unified_inventory") ~= nil then if minetest.get_modpath("unified_inventory") then
unified_inventory.register_button("doc", { unified_inventory.register_button("doc", {
type = "image", type = "image",
image = "doc_button_icon_hires.png", image = "doc_button_icon_hires.png",
@ -1190,7 +1194,7 @@ if minetest.get_modpath("unified_inventory") ~= nil then
end end
-- sfinv_buttons -- sfinv_buttons
if minetest.get_modpath("sfinv_buttons") ~= nil then if minetest.get_modpath("sfinv_buttons") then
sfinv_buttons.register_button("doc", { sfinv_buttons.register_button("doc", {
image = "doc_button_icon_lores.png", image = "doc_button_icon_lores.png",
tooltip = S("Collection of help texts"), tooltip = S("Collection of help texts"),

View File

@ -1,5 +1,7 @@
local S = minetest.get_translator(minetest.get_current_modname()) local S = minetest.get_translator(minetest.get_current_modname())
local mod_doc_basics = minetest.get_modpath("doc_basics")
local doc_identifier = {} local doc_identifier = {}
doc_identifier.registered_objects = {} doc_identifier.registered_objects = {}
@ -25,9 +27,9 @@ function doc_identifier.identify(itemstack, user, pointed_thing)
elseif itype == "error_unknown" then elseif itype == "error_unknown" then
vsize = vsize + 2 vsize = vsize + 2
local mod local mod
if param ~= nil then if param then
local colon = string.find(param, ":") local colon = string.find(param, ":")
if colon ~= nil and colon > 1 then if colon and colon > 1 then
mod = string.sub(param,1,colon-1) mod = string.sub(param,1,colon-1)
end end
end end
@ -37,8 +39,8 @@ function doc_identifier.identify(itemstack, user, pointed_thing)
S("• The author of the game or a mod has made a mistake") S("• The author of the game or a mod has made a mistake")
message = message .. "\n\n" message = message .. "\n\n"
if mod ~= nil then if mod then
if minetest.get_modpath(mod) ~= nil then if minetest.get_modpath(mod) then
message = message .. S("It appears to originate from the mod “@1”, which is enabled.", mod) message = message .. S("It appears to originate from the mod “@1”, which is enabled.", mod)
message = message .. "\n" message = message .. "\n"
else else
@ -46,7 +48,7 @@ function doc_identifier.identify(itemstack, user, pointed_thing)
message = message .. "\n" message = message .. "\n"
end end
end end
if param ~= nil then if param then
message = message .. S("Its identifier is “@1”.", param) message = message .. S("Its identifier is “@1”.", param)
end end
elseif itype == "error_ignore" then elseif itype == "error_ignore" then
@ -67,7 +69,7 @@ function doc_identifier.identify(itemstack, user, pointed_thing)
if pointed_thing.type == "node" then if pointed_thing.type == "node" then
local pos = pointed_thing.under local pos = pointed_thing.under
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
if minetest.registered_nodes[node.name] ~= nil then if minetest.registered_nodes[node.name] then
--local nodedef = minetest.registered_nodes[node.name] --local nodedef = minetest.registered_nodes[node.name]
if(node.name == "ignore") then if(node.name == "ignore") then
show_message(username, "error_ignore") show_message(username, "error_ignore")
@ -83,14 +85,14 @@ function doc_identifier.identify(itemstack, user, pointed_thing)
local object = pointed_thing.ref local object = pointed_thing.ref
local le = object:get_luaentity() local le = object:get_luaentity()
if object:is_player() then if object:is_player() then
if minetest.get_modpath("doc_basics") ~= nil and doc.entry_exists("basics", "players") then if mod_doc_basics and doc.entry_exists("basics", "players") then
doc.show_entry(username, "basics", "players", true) doc.show_entry(username, "basics", "players", true)
else else
-- Fallback message -- Fallback message
show_message(username, "player") show_message(username, "player")
end end
-- luaentity exists -- luaentity exists
elseif le ~= nil then elseif le then
local ro = doc_identifier.registered_objects[le.name] local ro = doc_identifier.registered_objects[le.name]
-- Dropped items -- Dropped items
if le.name == "__builtin:item" then if le.name == "__builtin:item" then
@ -113,7 +115,7 @@ function doc_identifier.identify(itemstack, user, pointed_thing)
doc.show_entry(username, "nodes", itemstring, true) doc.show_entry(username, "nodes", itemstring, true)
end end
-- A known registered object -- A known registered object
elseif ro ~= nil then elseif ro then
doc.show_entry(username, ro.category, ro.entry, true) doc.show_entry(username, ro.category, ro.entry, true)
-- Undefined object (error) -- Undefined object (error)
elseif minetest.registered_entities[le.name] == nil then elseif minetest.registered_entities[le.name] == nil then
@ -196,7 +198,7 @@ minetest.register_craft({
{"group:stick", ""} } {"group:stick", ""} }
}) })
if minetest.get_modpath("mcl_core") ~= nil then if minetest.get_modpath("mcl_core") then
minetest.register_craft({ minetest.register_craft({
output = "doc_identifier:identifier_solid", output = "doc_identifier:identifier_solid",
recipe = { { "mcl_core:glass" }, recipe = { { "mcl_core:glass" },

View File

@ -60,7 +60,7 @@ local function groups_to_string(grouptable, filter)
-- List seperator -- List seperator
gstring = gstring .. S(", ") gstring = gstring .. S(", ")
end end
if groupdefs[id] ~= nil and doc.sub.items.settings.friendly_group_names == true then if groupdefs[id] and doc.sub.items.settings.friendly_group_names == true then
gstring = gstring .. groupdefs[id] gstring = gstring .. groupdefs[id]
else else
gstring = gstring .. id gstring = gstring .. id
@ -123,9 +123,9 @@ end
local function get_entry_name(itemstring) local function get_entry_name(itemstring)
local def = minetest.registered_items[itemstring] local def = minetest.registered_items[itemstring]
if def._doc_items_entry_name ~= nil then if def._doc_items_entry_name then
return def._doc_items_entry_name return def._doc_items_entry_name
elseif item_name_overrides[itemstring] ~= nil then elseif item_name_overrides[itemstring] then
return item_name_overrides[itemstring] return item_name_overrides[itemstring]
else else
return def.description return def.description
@ -133,7 +133,7 @@ local function get_entry_name(itemstring)
end end
function doc.sub.items.get_group_name(groupname) function doc.sub.items.get_group_name(groupname)
if groupdefs[groupname] ~= nil and doc.sub.items.settings.friendly_group_names == true then if groupdefs[groupname] and doc.sub.items.settings.friendly_group_names == true then
return groupdefs[groupname] return groupdefs[groupname]
else else
return groupname return groupname
@ -163,9 +163,9 @@ local function factoid_toolcaps(tool_capabilities, check_uses)
local formstring = "" local formstring = ""
if check_uses == nil then check_uses = false end if check_uses == nil then check_uses = false end
if tool_capabilities ~= nil and tool_capabilities ~= {} then if tool_capabilities and tool_capabilities ~= {} then
local groupcaps = tool_capabilities.groupcaps local groupcaps = tool_capabilities.groupcaps
if groupcaps ~= nil then if groupcaps then
local miningcapstr = "" local miningcapstr = ""
local miningtimesstr = "" local miningtimesstr = ""
local miningusesstr = "" local miningusesstr = ""
@ -198,7 +198,7 @@ local function factoid_toolcaps(tool_capabilities, check_uses)
caplines = caplines + 1 caplines = caplines + 1
for rating=3, 1, -1 do for rating=3, 1, -1 do
if v.times ~= nil and v.times[rating] ~= nil then if v.times and v.times[rating] then
local maxtime = v.times[rating] local maxtime = v.times[rating]
local mintime local mintime
local mintimestr, maxtimestr local mintimestr, maxtimestr
@ -265,7 +265,7 @@ local function factoid_toolcaps(tool_capabilities, check_uses)
-- Weapon data -- Weapon data
local damage_groups = tool_capabilities.damage_groups local damage_groups = tool_capabilities.damage_groups
if damage_groups ~= nil then if damage_groups then
formstring = formstring .. S("This is a melee weapon which deals damage by punching.") .. "\n" formstring = formstring .. S("This is a melee weapon which deals damage by punching.") .. "\n"
-- Damage groups -- Damage groups
formstring = formstring .. S("Maximum damage per hit:") .. "\n" formstring = formstring .. S("Maximum damage per hit:") .. "\n"
@ -276,7 +276,7 @@ local function factoid_toolcaps(tool_capabilities, check_uses)
-- Full punch interval -- Full punch interval
local punch = 1.0 local punch = 1.0
if tool_capabilities.full_punch_interval ~= nil then if tool_capabilities.full_punch_interval then
punch = tool_capabilities.full_punch_interval punch = tool_capabilities.full_punch_interval
end end
formstring = formstring .. S("Full punch interval: @1 s", string.format("%.1f", punch)) formstring = formstring .. S("Full punch interval: @1 s", string.format("%.1f", punch))
@ -302,7 +302,7 @@ local function factoid_mining_node(data)
-- Check if there are no mining groups at all -- Check if there are no mining groups at all
local nogroups = true local nogroups = true
for groupname,_ in pairs(mininggroups) do for groupname,_ in pairs(mininggroups) do
if data.def.groups[groupname] ~= nil or groupname == "dig_immediate" then if data.def.groups[groupname] or groupname == "dig_immediate" then
nogroups = false nogroups = false
break break
end end
@ -334,7 +334,7 @@ local function factoid_mining_node(data)
local minegroupcount = 0 local minegroupcount = 0
for group,_ in pairs(mininggroups) do for group,_ in pairs(mininggroups) do
local rating = data.def.groups[group] local rating = data.def.groups[group]
if rating ~= nil then if rating then
mstring = mstring .. S("• @1: @2", doc.sub.items.get_group_name(group), rating).."\n" mstring = mstring .. S("• @1: @2", doc.sub.items.get_group_name(group), rating).."\n"
minegroupcount = minegroupcount + 1 minegroupcount = minegroupcount + 1
end end
@ -358,14 +358,14 @@ local function range_factoid(itemstring, def)
local handrange = minetest.registered_items[""].range local handrange = minetest.registered_items[""].range
local itemrange = def.range local itemrange = def.range
if itemstring == "" then if itemstring == "" then
if handrange ~= nil then if handrange then
return S("Range: @1", itemrange) return S("Range: @1", itemrange)
else else
return S("Range: 4") return S("Range: 4")
end end
else else
if handrange == nil then handrange = 4 end if handrange == nil then handrange = 4 end
if itemrange ~= nil then if itemrange then
return S("Range: @1", itemrange) return S("Range: @1", itemrange)
else else
return S("Range: @1 (@2)", get_entry_name(""), handrange) return S("Range: @1 (@2)", get_entry_name(""), handrange)
@ -381,7 +381,7 @@ local function factoid_fuel(itemstring, ctype)
local formstring = "" local formstring = ""
local result, decremented = minetest.get_craft_result({method = "fuel", items = {itemstring}}) local result, decremented = minetest.get_craft_result({method = "fuel", items = {itemstring}})
if result ~= nil and result.time > 0 then if result and result.time > 0 then
local base local base
local burntext = burntime_to_text(result.time) local burntext = burntime_to_text(result.time)
if ctype == "tools" then if ctype == "tools" then
@ -424,7 +424,7 @@ local function entry_image(data)
formstring = formstring .. "image["..(doc.FORMSPEC.ENTRY_END_X-1)..","..doc.FORMSPEC.ENTRY_START_Y..";1,1;".. formstring = formstring .. "image["..(doc.FORMSPEC.ENTRY_END_X-1)..","..doc.FORMSPEC.ENTRY_START_Y..";1,1;"..
minetest.registered_items[""].wield_image.."]" minetest.registered_items[""].wield_image.."]"
-- Other items -- Other items
elseif data.image ~= nil then elseif data.image then
formstring = formstring .. "image["..(doc.FORMSPEC.ENTRY_END_X-1)..","..doc.FORMSPEC.ENTRY_START_Y..";1,1;"..data.image.."]" formstring = formstring .. "image["..(doc.FORMSPEC.ENTRY_END_X-1)..","..doc.FORMSPEC.ENTRY_START_Y..";1,1;"..data.image.."]"
else else
formstring = formstring .. "item_image["..(doc.FORMSPEC.ENTRY_END_X-1)..","..doc.FORMSPEC.ENTRY_START_Y..";1,1;"..data.itemstring.."]" formstring = formstring .. "item_image["..(doc.FORMSPEC.ENTRY_END_X-1)..","..doc.FORMSPEC.ENTRY_START_Y..";1,1;"..data.itemstring.."]"
@ -466,11 +466,11 @@ local function factoids_header(data, ctype)
local longdesc = data.longdesc local longdesc = data.longdesc
local usagehelp = data.usagehelp local usagehelp = data.usagehelp
if longdesc ~= nil then if longdesc then
datastring = datastring .. S("Description: @1", longdesc) datastring = datastring .. S("Description: @1", longdesc)
datastring = newline2(datastring) datastring = newline2(datastring)
end end
if usagehelp ~= nil then if usagehelp then
datastring = datastring .. S("Usage help: @1", usagehelp) datastring = datastring .. S("Usage help: @1", usagehelp)
datastring = newline2(datastring) datastring = newline2(datastring)
end end
@ -494,7 +494,7 @@ local function factoids_header(data, ctype)
datastring = datastring .. S("This item points to liquids.").."\n" datastring = datastring .. S("This item points to liquids.").."\n"
end end
end end
if data.def.on_use ~= nil then if data.def.on_use then
if ctype == "nodes" then if ctype == "nodes" then
datastring = datastring .. S("Punches with this block don't work as usual; melee combat and mining are either not possible or work differently.").."\n" datastring = datastring .. S("Punches with this block don't work as usual; melee combat and mining are either not possible or work differently.").."\n"
elseif ctype == "tools" then elseif ctype == "tools" then
@ -528,7 +528,7 @@ local function factoids_footer(data, playername, ctype)
-- Show other “exposable” groups -- Show other “exposable” groups
if not forbidden_core_factoids.groups then if not forbidden_core_factoids.groups then
local gstring, gcount = groups_to_string(data.def.groups, miscgroups) local gstring, gcount = groups_to_string(data.def.groups, miscgroups)
if gstring ~= nil then if gstring then
if gcount == 1 then if gcount == 1 then
if ctype == "nodes" then if ctype == "nodes" then
datastring = datastring .. S("This block belongs to the @1 group.", gstring) .. "\n" datastring = datastring .. S("This block belongs to the @1 group.", gstring) .. "\n"
@ -607,7 +607,7 @@ doc.add_category("nodes", {
datastring = datastring .. S("This block is a liquid with these properties:") .. "\n" datastring = datastring .. S("This block is a liquid with these properties:") .. "\n"
local range, renew, viscos local range, renew, viscos
if data.def.liquid_range then range = data.def.liquid_range else range = 8 end if data.def.liquid_range then range = data.def.liquid_range else range = 8 end
if data.def.liquid_renewable ~= nil then renew = data.def.liquid_renewable else renew = true end if data.def.liquid_renewable then renew = data.def.liquid_renewable else renew = true end
if data.def.liquid_viscosity then viscos = data.def.liquid_viscosity else viscos = 0 end if data.def.liquid_viscosity then viscos = data.def.liquid_viscosity else viscos = 0 end
if renew then if renew then
datastring = datastring .. S("• Renewable") .. "\n" datastring = datastring .. S("• Renewable") .. "\n"
@ -627,7 +627,7 @@ doc.add_category("nodes", {
--- Direct interaction with the player --- Direct interaction with the player
---- Damage (very important) ---- Damage (very important)
if not forbidden_core_factoids.node_damage then if not forbidden_core_factoids.node_damage then
if data.def.damage_per_second ~= nil and data.def.damage_per_second > 1 then if data.def.damage_per_second and data.def.damage_per_second > 1 then
datastring = datastring .. S("This block causes a damage of @1 hit points per second.", data.def.damage_per_second) .. "\n" datastring = datastring .. S("This block causes a damage of @1 hit points per second.", data.def.damage_per_second) .. "\n"
elseif data.def.damage_per_second == 1 then elseif data.def.damage_per_second == 1 then
datastring = datastring .. S("This block causes a damage of @1 hit point per second.", data.def.damage_per_second) .. "\n" datastring = datastring .. S("This block causes a damage of @1 hit point per second.", data.def.damage_per_second) .. "\n"
@ -640,7 +640,7 @@ doc.add_category("nodes", {
end end
end end
local fdap = data.def.groups.fall_damage_add_percent local fdap = data.def.groups.fall_damage_add_percent
if fdap ~= nil and fdap ~= 0 then if fdap and fdap ~= 0 then
if fdap > 0 then if fdap > 0 then
datastring = datastring .. S("The fall damage on this block is increased by @1%.", fdap) .. "\n" datastring = datastring .. S("The fall damage on this block is increased by @1%.", fdap) .. "\n"
elseif fdap <= -100 then elseif fdap <= -100 then
@ -662,11 +662,11 @@ doc.add_category("nodes", {
datastring = datastring .. S("This block can be climbed.").."\n" datastring = datastring .. S("This block can be climbed.").."\n"
end end
local bouncy = data.def.groups.bouncy local bouncy = data.def.groups.bouncy
if bouncy ~= nil and bouncy ~= 0 then if bouncy and bouncy ~= 0 then
datastring = datastring .. S("This block will make you bounce off with an elasticity of @1%.", bouncy).."\n" datastring = datastring .. S("This block will make you bounce off with an elasticity of @1%.", bouncy).."\n"
end end
local slippery = data.def.groups.slippery local slippery = data.def.groups.slippery
if slippery ~= nil and slippery ~= 0 then if slippery and slippery ~= 0 then
datastring = datastring .. S("This block is slippery.") .. "\n" datastring = datastring .. S("This block is slippery.") .. "\n"
end end
datastring = datastring .. factoid_custom("nodes", "movement", data) datastring = datastring .. factoid_custom("nodes", "movement", data)
@ -766,7 +766,7 @@ doc.add_category("nodes", {
datastring = newline2(datastring) datastring = newline2(datastring)
--- List nodes/groups to which this node connects to --- List nodes/groups to which this node connects to
if not forbidden_core_factoids.connects_to and data.def.connects_to ~= nil then if not forbidden_core_factoids.connects_to and data.def.connects_to then
local nodes = {} local nodes = {}
local groups = {} local groups = {}
for c=1,#data.def.connects_to do for c=1,#data.def.connects_to do
@ -781,7 +781,7 @@ doc.add_category("nodes", {
local nstring = "" local nstring = ""
for n=1,#nodes do for n=1,#nodes do
local name local name
if item_name_overrides[nodes[n]] ~= nil then if item_name_overrides[nodes[n]] then
name = item_name_overrides[nodes[n]] name = item_name_overrides[nodes[n]]
else else
name = description_for_formspec(nodes[n]) name = description_for_formspec(nodes[n])
@ -789,7 +789,7 @@ doc.add_category("nodes", {
if n > 1 then if n > 1 then
nstring = nstring .. S(", ") nstring = nstring .. S(", ")
end end
if name ~= nil then if name then
nstring = nstring .. name nstring = nstring .. name
else else
nstring = nstring .. S("Unknown Node") nstring = nstring .. S("Unknown Node")
@ -820,7 +820,7 @@ doc.add_category("nodes", {
datastring = newline2(datastring) datastring = newline2(datastring)
-- Non-default drops -- Non-default drops
if not forbidden_core_factoids.drops and data.def.drop ~= nil and data.def.drop ~= data.itemstring and data.itemstring ~= "air" then if not forbidden_core_factoids.drops and data.def.drop and data.def.drop ~= data.itemstring and data.itemstring ~= "air" then
-- TODO: Calculate drop probabilities of max > 1 like for max == 1 -- TODO: Calculate drop probabilities of max > 1 like for max == 1
local function get_desc(stack) local function get_desc(stack)
return description_for_formspec(stack:get_name()) return description_for_formspec(stack:get_name())
@ -838,7 +838,7 @@ doc.add_category("nodes", {
datastring = datastring .. S("This block will drop the following when mined: @1.", desc).."\n" datastring = datastring .. S("This block will drop the following when mined: @1.", desc).."\n"
end end
end end
elseif type(data.def.drop) == "table" and data.def.drop.items ~= nil then elseif type(data.def.drop) == "table" and data.def.drop.items then
local max = data.def.drop.max_items local max = data.def.drop.max_items
local dropstring = "" local dropstring = ""
local dropstring_base local dropstring_base
@ -892,7 +892,7 @@ doc.add_category("nodes", {
if chance > 0 then if chance > 0 then
probtable = {} probtable = {}
probtable.items = {} probtable.items = {}
for j=1,#data.def.drop.items[i].items do for j = 1, #data.def.drop.items[i].items do
local dropstack = ItemStack(data.def.drop.items[i].items[j]) local dropstack = ItemStack(data.def.drop.items[i].items[j])
local itemstring = dropstack:get_name() local itemstring = dropstack:get_name()
local desc = get_desc(dropstack) local desc = get_desc(dropstack)
@ -963,7 +963,7 @@ doc.add_category("nodes", {
dropstring = dropstring .. dropstring_this dropstring = dropstring .. dropstring_this
pcount = pcount + 1 pcount = pcount + 1
end end
if max ~= nil and max > 1 then if max and max > 1 then
datastring = datastring .. S(dropstring_base, max, dropstring) datastring = datastring .. S(dropstring_base, max, dropstring)
else else
datastring = datastring .. S(dropstring_base, dropstring) datastring = datastring .. S(dropstring_base, dropstring)
@ -998,15 +998,15 @@ doc.add_category("tools", {
if entries[2].eid == "" then return false end if entries[2].eid == "" then return false end
local comp = {} local comp = {}
for e=1, 2 do for e = 1, 2 do
comp[e] = {} comp[e] = {}
end end
-- No tool capabilities: Instant loser -- No tool capabilities: Instant loser
if entries[1].data.def.tool_capabilities == nil and entries[2].data.def.tool_capabilities ~= nil then return false end if entries[1].data.def.tool_capabilities == nil and entries[2].data.def.tool_capabilities then return false end
if entries[2].data.def.tool_capabilities == nil and entries[1].data.def.tool_capabilities ~= nil then return true end if entries[2].data.def.tool_capabilities == nil and entries[1].data.def.tool_capabilities then return true end
-- No tool capabilities for both: Compare by uses -- No tool capabilities for both: Compare by uses
if entries[1].data.def.tool_capabilities == nil and entries[2].data.def.tool_capabilities == nil then if entries[1].data.def.tool_capabilities == nil and entries[2].data.def.tool_capabilities == nil then
for e=1, 2 do for e = 1, 2 do
if type(entries[e].data.def._doc_items_durability) == "number" then if type(entries[e].data.def._doc_items_durability) == "number" then
comp[e].uses = entries[e].data.def._doc_items_durability comp[e].uses = entries[e].data.def._doc_items_durability
else else
@ -1061,7 +1061,7 @@ doc.add_category("tools", {
comp[e].count = groupcount comp[e].count = groupcount
comp[e].group = group comp[e].group = group
comp[e].mintime = mintime comp[e].mintime = mintime
if realuses ~= nil then if realuses then
comp[e].uses = realuses comp[e].uses = realuses
elseif type(entries[e].data.def._doc_items_durability) == "number" then elseif type(entries[e].data.def._doc_items_durability) == "number" then
comp[e].uses = entries[e].data.def._doc_items_durability comp[e].uses = entries[e].data.def._doc_items_durability
@ -1166,9 +1166,9 @@ local function gather_descs()
-- 1st pass: Gather groups of interest -- 1st pass: Gather groups of interest
for id, def in pairs(minetest.registered_items) do for id, def in pairs(minetest.registered_items) do
-- Gather all groups used for mining -- Gather all groups used for mining
if def.tool_capabilities ~= nil then if def.tool_capabilities then
local groupcaps = def.tool_capabilities.groupcaps local groupcaps = def.tool_capabilities.groupcaps
if groupcaps ~= nil then if groupcaps then
for k,v in pairs(groupcaps) do for k,v in pairs(groupcaps) do
if mininggroups[k] ~= true then if mininggroups[k] ~= true then
mininggroups[k] = true mininggroups[k] = true
@ -1179,7 +1179,7 @@ local function gather_descs()
-- ... and gather all groups which appear in crafting recipes -- ... and gather all groups which appear in crafting recipes
local crafts = minetest.get_all_craft_recipes(id) local crafts = minetest.get_all_craft_recipes(id)
if crafts ~= nil then if crafts then
for c=1,#crafts do for c=1,#crafts do
for k,v in pairs(crafts[c].items) do for k,v in pairs(crafts[c].items) do
if string.sub(v,1,6) == "group:" then if string.sub(v,1,6) == "group:" then
@ -1194,7 +1194,7 @@ local function gather_descs()
end end
-- ... and gather all groups used in connects_to -- ... and gather all groups used in connects_to
if def.connects_to ~= nil then if def.connects_to then
for c=1, #def.connects_to do for c=1, #def.connects_to do
if string.sub(def.connects_to[c],1,6) == "group:" then if string.sub(def.connects_to[c],1,6) == "group:" then
local group = string.sub(def.connects_to[c],7,-1) local group = string.sub(def.connects_to[c],7,-1)
@ -1213,7 +1213,7 @@ local function gather_descs()
else else
help.longdesc["air"] = S("A transparent block, basically empty space. It is usually left behind after digging something.") help.longdesc["air"] = S("A transparent block, basically empty space. It is usually left behind after digging something.")
end end
if minetest.registered_items["ignore"]._doc_items_create_entry ~= nil then if minetest.registered_items["ignore"]._doc_items_create_entry then
suppressed["ignore"] = minetest.registered_items["ignore"]._doc_items_create_entry == true suppressed["ignore"] = minetest.registered_items["ignore"]._doc_items_create_entry == true
end end
@ -1246,19 +1246,19 @@ local function gather_descs()
for id, def in pairs(deftable) do for id, def in pairs(deftable) do
local name, ld, uh, im local name, ld, uh, im
local forced = false local forced = false
if def._doc_items_create_entry == true and def ~= nil then forced = true end if def._doc_items_create_entry == true and def then forced = true end
name = get_entry_name(id) name = get_entry_name(id)
if not (((def.description == nil or def.description == "") and def._doc_items_entry_name == nil) or (def._doc_items_create_entry == false) or (suppressed[id] == true)) or forced then if not (((def.description == nil or def.description == "") and def._doc_items_entry_name == nil) or (def._doc_items_create_entry == false) or (suppressed[id] == true)) or forced then
if def._doc_items_longdesc then if def._doc_items_longdesc then
ld = def._doc_items_longdesc ld = def._doc_items_longdesc
end end
if help.longdesc[id] ~= nil then if help.longdesc[id] then
ld = help.longdesc[id] ld = help.longdesc[id]
end end
if def._doc_items_usagehelp then if def._doc_items_usagehelp then
uh = def._doc_items_usagehelp uh = def._doc_items_usagehelp
end end
if help.usagehelp[id] ~= nil then if help.usagehelp[id] then
uh = help.usagehelp[id] uh = help.usagehelp[id]
end end
if def._doc_items_image then if def._doc_items_image then
@ -1307,13 +1307,13 @@ local function reveal_item(playername, itemstring)
if itemstring == nil or itemstring == "" or playername == nil or playername == "" then if itemstring == nil or itemstring == "" or playername == nil or playername == "" then
return false return false
end end
if minetest.registered_nodes[itemstring] ~= nil then if minetest.registered_nodes[itemstring] then
category_id = "nodes" category_id = "nodes"
elseif minetest.registered_tools[itemstring] ~= nil then elseif minetest.registered_tools[itemstring] then
category_id = "tools" category_id = "tools"
elseif minetest.registered_craftitems[itemstring] ~= nil then elseif minetest.registered_craftitems[itemstring] then
category_id = "craftitems" category_id = "craftitems"
elseif minetest.registered_items[itemstring] ~= nil then elseif minetest.registered_items[itemstring] then
category_id = "craftitems" category_id = "craftitems"
else else
return false return false
@ -1333,7 +1333,7 @@ end
minetest.register_on_dignode(function(pos, oldnode, digger) minetest.register_on_dignode(function(pos, oldnode, digger)
if digger == nil then return end if digger == nil then return end
local playername = digger:get_player_name() local playername = digger:get_player_name()
if playername ~= nil and playername ~= "" and oldnode ~= nil then if playername and playername ~= "" and oldnode then
reveal_item(playername, oldnode.name) reveal_item(playername, oldnode.name)
reveal_items_in_inventory(digger) reveal_items_in_inventory(digger)
end end
@ -1342,7 +1342,7 @@ end)
minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing) minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
if puncher == nil then return end if puncher == nil then return end
local playername = puncher:get_player_name() local playername = puncher:get_player_name()
if playername ~= nil and playername ~= "" and node ~= nil then if playername and playername ~= "" and node then
reveal_item(playername, node.name) reveal_item(playername, node.name)
end end
end) end)
@ -1350,7 +1350,7 @@ end)
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing) minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing)
if placer == nil then return end if placer == nil then return end
local playername = placer:get_player_name() local playername = placer:get_player_name()
if playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then if playername and playername ~= "" and itemstack and not itemstack:is_empty() then
reveal_item(playername, itemstack:get_name()) reveal_item(playername, itemstack:get_name())
end end
end) end)
@ -1358,7 +1358,7 @@ end)
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
if player == nil then return end if player == nil then return end
local playername = player:get_player_name() local playername = player:get_player_name()
if playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then if playername and playername ~= "" and itemstack and not itemstack:is_empty() then
reveal_item(playername, itemstack:get_name()) reveal_item(playername, itemstack:get_name())
end end
end) end)
@ -1370,7 +1370,7 @@ minetest.register_on_player_inventory_action(function(player, action, inventory,
if action == "take" or action == "put" then if action == "take" or action == "put" then
itemstack = inventory_info.stack itemstack = inventory_info.stack
end end
if itemstack ~= nil and playername ~= nil and playername ~= "" and (not itemstack:is_empty()) then if itemstack and playername and playername ~= "" and (not itemstack:is_empty()) then
reveal_item(playername, itemstack:get_name()) reveal_item(playername, itemstack:get_name())
end end
end) end)
@ -1378,9 +1378,9 @@ end)
minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing) minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing)
if user == nil then return end if user == nil then return end
local playername = user:get_player_name() local playername = user:get_player_name()
if playername ~= nil and playername ~= "" and itemstack ~= nil and not itemstack:is_empty() then if playername and playername ~= "" and itemstack and not itemstack:is_empty() then
reveal_item(playername, itemstack:get_name()) reveal_item(playername, itemstack:get_name())
if replace_with_item ~= nil then if replace_with_item then
reveal_item(playername, replace_with_item) reveal_item(playername, replace_with_item)
end end
end end
@ -1390,10 +1390,12 @@ minetest.register_on_joinplayer(function(player)
reveal_items_in_inventory(player) reveal_items_in_inventory(player)
end) end)
--[[ Periodically check all items in player inventory and reveal them all. --[[
Periodically check all items in player inventory and reveal them all.
TODO: Check whether there's a serious performance impact on servers with many players. TODO: Check whether there's a serious performance impact on servers with many players.
TODO: If possible, try to replace this functionality by updating the revealed items as TODO: If possible, try to replace this functionality by updating the revealed items as soon the player obtained a new item (probably needs new Minetest callbacks).
soon the player obtained a new item (probably needs new Minetest callbacks). ]] ]]
local checktime = 8 local checktime = 8
local timer = 0 local timer = 0
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)

View File

@ -1,4 +1,4 @@
local S = minetest.get_translator("mcl_doc") local S = minetest.get_translator(minetest.get_current_modname())
-- Disable built-in factoids; it is planned to add custom ones as replacements -- Disable built-in factoids; it is planned to add custom ones as replacements
doc.sub.items.disable_core_factoid("node_mining") doc.sub.items.disable_core_factoid("node_mining")
@ -50,8 +50,8 @@ end)
doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def) doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def)
local formstring = "" local formstring = ""
if def.groups.leafdecay ~= nil then if def.groups.leafdecay then
if def.drop ~= "" and def.drop ~= nil and def.drop ~= itemstring then if def.drop ~= "" and def.drop and def.drop ~= itemstring then
formstring = S("This block quickly decays when there is no wood block of any species within a distance of @1. When decaying, it disappears and may drop one of its regular drops. The block does not decay when the block has been placed by a player.", def.groups.leafdecay) formstring = S("This block quickly decays when there is no wood block of any species within a distance of @1. When decaying, it disappears and may drop one of its regular drops. The block does not decay when the block has been placed by a player.", def.groups.leafdecay)
else else
formstring = S("This block quickly decays and disappears when there is no wood block of any species within a distance of @1. The block does not decay when the block has been placed by a player.", def.groups.leafdecay) formstring = S("This block quickly decays and disappears when there is no wood block of any species within a distance of @1. The block does not decay when the block has been placed by a player.", def.groups.leafdecay)
@ -399,7 +399,7 @@ doc.sub.items.register_factoid("tools", "misc", function(itemstring, def)
local formstring = "" local formstring = ""
-- Weapon data -- Weapon data
local damage_groups = tool_capabilities.damage_groups local damage_groups = tool_capabilities.damage_groups
if damage_groups ~= nil and damage_groups.fleshy ~= nil then if damage_groups and damage_groups.fleshy then
formstring = formstring .. S("This is a melee weapon which deals damage by punching.") .. "\n" formstring = formstring .. S("This is a melee weapon which deals damage by punching.") .. "\n"
-- Damage groups -- Damage groups
@ -408,7 +408,7 @@ doc.sub.items.register_factoid("tools", "misc", function(itemstring, def)
-- Full punch interval -- Full punch interval
local punch = 1.0 local punch = 1.0
if tool_capabilities.full_punch_interval ~= nil then if tool_capabilities.full_punch_interval then
punch = tool_capabilities.full_punch_interval punch = tool_capabilities.full_punch_interval
end end
formstring = formstring .. S("Full punch interval: @1 s", string.format("%.1f", punch)) formstring = formstring .. S("Full punch interval: @1 s", string.format("%.1f", punch))

View File

@ -2,7 +2,7 @@
Basic help for MCL2. Fork of doc_basics Basic help for MCL2. Fork of doc_basics
]] ]]
local S = minetest.get_translator("mcl_doc_basics") local S = minetest.get_translator(minetest.get_current_modname())
doc.add_category("basics", doc.add_category("basics",
{ {

View File

@ -1,4 +1,4 @@
local S = minetest.get_translator("mcl_doc_basics") local S = minetest.get_translator(minetest.get_current_modname())
doc.add_entry("advanced", "creative", { doc.add_entry("advanced", "creative", {
name = S("Creative Mode"), name = S("Creative Mode"),

View File

@ -1,2 +1,4 @@
dofile(minetest.get_modpath("mcl_tt").."/snippets_base.lua") local modpath = minetest.get_modpath(minetest.get_current_modname())
dofile(minetest.get_modpath("mcl_tt").."/snippets_mcl.lua")
dofile(modpath.."/snippets_base.lua")
dofile(modpath.."/snippets_mcl.lua")

View File

@ -1,4 +1,4 @@
local S = minetest.get_translator("mcl_tt") local S = minetest.get_translator(minetest.get_current_modname())
--[[local function get_min_digtime(caps) --[[local function get_min_digtime(caps)
local mintime local mintime

View File

@ -1,4 +1,4 @@
local S = minetest.get_translator("mcl_tt") local S = minetest.get_translator(minetest.get_current_modname())
-- Armor -- Armor
tt.register_snippet(function(itemstring) tt.register_snippet(function(itemstring)

View File

@ -43,7 +43,7 @@ local function apply_snippets(desc, itemstring, toolcaps, itemstack)
end end
local function should_change(itemstring, def) local function should_change(itemstring, def)
return itemstring ~= "" and itemstring ~= "air" and itemstring ~= "ignore" and itemstring ~= "unknown" and def ~= nil and def.description ~= nil and def.description ~= "" and def._tt_ignore ~= true return itemstring ~= "" and itemstring ~= "air" and itemstring ~= "ignore" and itemstring ~= "unknown" and def and def.description and def.description ~= "" and def._tt_ignore ~= true
end end
local function append_snippets() local function append_snippets()

View File

@ -14,11 +14,16 @@
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-- --
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local S = minetest.get_translator(modname)
-- The global award namespace -- The global award namespace
awards = { awards = {
show_mode = "hud" show_mode = "hud",
} }
dofile(minetest.get_modpath("awards").."/api_helpers.lua")
dofile(modpath.."/api_helpers.lua")
-- Table Save Load Functions -- Table Save Load Functions
function awards.save() function awards.save()
@ -29,8 +34,6 @@ function awards.save()
end end
end end
local S = minetest.get_translator("awards")
function awards.init() function awards.init()
awards.players = awards.load() awards.players = awards.load()
awards.def = {} awards.def = {}
@ -53,7 +56,7 @@ end
function awards.register_trigger(name, func) function awards.register_trigger(name, func)
awards.trigger_types[name] = func awards.trigger_types[name] = func
awards.on[name] = {} awards.on[name] = {}
awards['register_on_'..name] = function(func) awards["register_on_"..name] = function(func)
table.insert(awards.on[name], func) table.insert(awards.on[name], func)
end end
end end

View File

@ -14,7 +14,7 @@
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-- --
local S = minetest.get_translator("awards") local S = minetest.get_translator(minetest.get_current_modname())
minetest.register_chatcommand("awards", { minetest.register_chatcommand("awards", {
params = S("[c|clear|disable|enable]"), params = S("[c|clear|disable|enable]"),

View File

@ -14,9 +14,11 @@
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-- --
dofile(minetest.get_modpath("awards").."/api.lua") local modpath = minetest.get_modpath(minetest.get_current_modname())
dofile(minetest.get_modpath("awards").."/chat_commands.lua")
dofile(minetest.get_modpath("awards").."/sfinv.lua") dofile(modpath.."/api.lua")
dofile(minetest.get_modpath("awards").."/unified_inventory.lua") dofile(modpath.."/chat_commands.lua")
dofile(minetest.get_modpath("awards").."/triggers.lua") dofile(modpath.."/sfinv.lua")
dofile(modpath.."/unified_inventory.lua")
dofile(modpath.."/triggers.lua")

View File

@ -1,5 +1,5 @@
if minetest.get_modpath("sfinv") then if minetest.get_modpath("sfinv") then
local S = minetest.get_translator("awards") local S = minetest.get_translator(minetest.get_current_modname())
sfinv.register_page("awards:awards", { sfinv.register_page("awards:awards", {
title = S("Awards"), title = S("Awards"),

View File

@ -14,7 +14,7 @@
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-- --
local S = minetest.get_translator("awards") local S = minetest.get_translator(minetest.get_current_modname())
awards.register_trigger("dig", function(def) awards.register_trigger("dig", function(def)
local tmp = { local tmp = {
@ -382,7 +382,7 @@ end)
minetest.register_on_chat_message(function(name, message) minetest.register_on_chat_message(function(name, message)
-- Run checks -- Run checks
local idx = string.find(message,"/") local idx = string.find(message,"/")
if not name or (idx ~= nil and idx <= 1) then if not name or (idx and idx <= 1) then
return return
end end

View File

@ -37,7 +37,7 @@ hb.settings.alignment_pattern = hb.load_setting("hudbars_alignment_pattern", "st
hb.settings.autohide_breath = hb.load_setting("hudbars_autohide_breath", "bool", true) hb.settings.autohide_breath = hb.load_setting("hudbars_autohide_breath", "bool", true)
local sorting = minetest.settings:get("hudbars_sorting") local sorting = minetest.settings:get("hudbars_sorting")
if sorting ~= nil then if sorting then
hb.settings.sorting = {} hb.settings.sorting = {}
hb.settings.sorting_reverse = {} hb.settings.sorting_reverse = {}
for k,v in string.gmatch(sorting, "(%w+)=(%w+)") do for k,v in string.gmatch(sorting, "(%w+)=(%w+)") do

View File

@ -27,10 +27,10 @@ function hb.load_setting(sname, stype, defaultval, valid_values)
elseif stype == "number" then elseif stype == "number" then
sval = tonumber(minetest.settings:get(sname)) sval = tonumber(minetest.settings:get(sname))
end end
if sval ~= nil then if sval then
if valid_values ~= nil then if valid_values then
local valid = false local valid = false
for i=1,#valid_values do for i = 1, #valid_values do
if sval == valid_values[i] then if sval == valid_values[i] then
valid = true valid = true
end end
@ -114,7 +114,7 @@ function hb.get_hudtable(identifier)
end end
function hb.get_hudbar_position_index(identifier) function hb.get_hudbar_position_index(identifier)
if hb.settings.sorting[identifier] ~= nil then if hb.settings.sorting[identifier] then
return hb.settings.sorting[identifier] return hb.settings.sorting[identifier]
else else
local i = 0 local i = 0
@ -215,7 +215,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, direction,
offset = { x = offset.x - 1, y = offset.y - 1 }, offset = { x = offset.x - 1, y = offset.y - 1 },
z_index = 0, z_index = 0,
}) })
if textures.icon ~= nil then if textures.icon then
ids.icon = player:hud_add({ ids.icon = player:hud_add({
hud_elem_type = "image", hud_elem_type = "image",
position = pos, position = pos,
@ -335,7 +335,7 @@ function hb.change_hudbar(player, identifier, new_value, new_max_value, new_icon
end end
local value_changed, max_changed = false, false local value_changed, max_changed = false, false
if new_value ~= nil then if new_value then
if new_value ~= hudtable.hudstate[name].value then if new_value ~= hudtable.hudstate[name].value then
hudtable.hudstate[name].value = new_value hudtable.hudstate[name].value = new_value
value_changed = true value_changed = true
@ -343,7 +343,7 @@ function hb.change_hudbar(player, identifier, new_value, new_max_value, new_icon
else else
new_value = hudtable.hudstate[name].value new_value = hudtable.hudstate[name].value
end end
if new_max_value ~= nil then if new_max_value then
if new_max_value ~= hudtable.hudstate[name].max then if new_max_value ~= hudtable.hudstate[name].max then
hudtable.hudstate[name].max = new_max_value hudtable.hudstate[name].max = new_max_value
max_changed = true max_changed = true
@ -353,29 +353,29 @@ function hb.change_hudbar(player, identifier, new_value, new_max_value, new_icon
end end
if hb.settings.bar_type == "progress_bar" then if hb.settings.bar_type == "progress_bar" then
if new_icon ~= nil and hudtable.hudids[name].icon ~= nil then if new_icon and hudtable.hudids[name].icon then
player:hud_change(hudtable.hudids[name].icon, "text", new_icon) player:hud_change(hudtable.hudids[name].icon, "text", new_icon)
end end
if new_bgicon ~= nil and hudtable.hudids[name].bgicon ~= nil then if new_bgicon and hudtable.hudids[name].bgicon then
player:hud_change(hudtable.hudids[name].bgicon, "text", new_bgicon) player:hud_change(hudtable.hudids[name].bgicon, "text", new_bgicon)
end end
if new_bar ~= nil then if new_bar then
player:hud_change(hudtable.hudids[name].bar , "text", new_bar) player:hud_change(hudtable.hudids[name].bar , "text", new_bar)
end end
if new_label ~= nil then if new_label then
hudtable.label = new_label hudtable.label = new_label
local new_text = make_label(hudtable.format_string, hudtable.format_string_config, new_label, hudtable.hudstate[name].value, hudtable.hudstate[name].max) local new_text = make_label(hudtable.format_string, hudtable.format_string_config, new_label, hudtable.hudstate[name].value, hudtable.hudstate[name].max)
player:hud_change(hudtable.hudids[name].text, "text", new_text) player:hud_change(hudtable.hudids[name].text, "text", new_text)
end end
if new_text_color ~= nil then if new_text_color then
player:hud_change(hudtable.hudids[name].text, "number", new_text_color) player:hud_change(hudtable.hudids[name].text, "number", new_text_color)
end end
else else
if new_icon ~= nil and hudtable.hudids[name].bar ~= nil then if new_icon and hudtable.hudids[name].bar then
player:hud_change(hudtable.hudids[name].bar, "text", new_icon) player:hud_change(hudtable.hudids[name].bar, "text", new_icon)
end end
if new_bgicon ~= nil and hudtable.hudids[name].bg ~= nil then if new_bgicon and hudtable.hudids[name].bg then
player:hud_change(hudtable.hudids[name].bg, "text", new_bgicon) player:hud_change(hudtable.hudids[name].bg, "text", new_bgicon)
end end
end end
@ -426,7 +426,7 @@ function hb.hide_hudbar(player, identifier)
local hudtable = hb.get_hudtable(identifier) local hudtable = hb.get_hudtable(identifier)
if hudtable == nil then return false end if hudtable == nil then return false end
if hb.settings.bar_type == "progress_bar" then if hb.settings.bar_type == "progress_bar" then
if hudtable.hudids[name].icon ~= nil then if hudtable.hudids[name].icon then
player:hud_change(hudtable.hudids[name].icon, "scale", {x=0,y=0}) player:hud_change(hudtable.hudids[name].icon, "scale", {x=0,y=0})
end end
player:hud_change(hudtable.hudids[name].bg, "scale", {x=0,y=0}) player:hud_change(hudtable.hudids[name].bg, "scale", {x=0,y=0})
@ -446,7 +446,7 @@ function hb.unhide_hudbar(player, identifier)
local value = hudtable.hudstate[name].value local value = hudtable.hudstate[name].value
local max = hudtable.hudstate[name].max local max = hudtable.hudstate[name].max
if hb.settings.bar_type == "progress_bar" then if hb.settings.bar_type == "progress_bar" then
if hudtable.hudids[name].icon ~= nil then if hudtable.hudids[name].icon then
player:hud_change(hudtable.hudids[name].icon, "scale", {x=1,y=1}) player:hud_change(hudtable.hudids[name].icon, "scale", {x=1,y=1})
end end
if hudtable.hudstate[name].max ~= 0 then if hudtable.hudstate[name].max ~= 0 then
@ -548,7 +548,7 @@ local function update_hud(player, has_damage)
end end
minetest.register_on_player_hpchange(function(player) minetest.register_on_player_hpchange(function(player)
if hb.players[player:get_player_name()] ~= nil then if hb.players[player:get_player_name()] then
update_health(player) update_health(player)
end end
end) end)

View File

@ -3,7 +3,7 @@
-- If true, activates achievements from other Minecraft editions (XBox, PS, etc.) -- If true, activates achievements from other Minecraft editions (XBox, PS, etc.)
local non_pc_achievements = false local non_pc_achievements = false
local S = minetest.get_translator("mcl_achievements") local S = minetest.get_translator(minetest.get_current_modname())
-- Achievements from PC Edition -- Achievements from PC Edition

View File

@ -1,4 +1,4 @@
local S = minetest.get_translator("mcl_death_messages") local S = minetest.get_translator(minetest.get_current_modname())
mcl_death_messages = { mcl_death_messages = {
assist = {}, assist = {},

View File

@ -1,4 +1,4 @@
local S = minetest.get_translator("mcl_experience") local S = minetest.get_translator(minetest.get_current_modname())
mcl_experience = {} mcl_experience = {}

View File

@ -19,7 +19,7 @@ local mcl_hbarmor = {
local tick_config = minetest.settings:get("mcl_hbarmor_tick") local tick_config = minetest.settings:get("mcl_hbarmor_tick")
if tonumber(tick_config) ~= nil then if tonumber(tick_config) then
mcl_hbarmor.tick = tonumber(tick_config) mcl_hbarmor.tick = tonumber(tick_config)
end end

View File

@ -1,4 +1,4 @@
local S = minetest.get_translator("mcl_inventory") local S = minetest.get_translator(minetest.get_current_modname())
local F = minetest.formspec_escape local F = minetest.formspec_escape
-- Prepare player info table -- Prepare player info table
@ -7,7 +7,7 @@ local players = {}
-- Containing all the items for each Creative Mode tab -- Containing all the items for each Creative Mode tab
local inventory_lists = {} local inventory_lists = {}
--local mod_player = minetest.get_modpath("mcl_player") ~= nil --local mod_player = minetest.get_modpath("mcl_player")
-- Create tables -- Create tables
local builtin_filter_ids = {"blocks","deco","redstone","rail","food","tools","combat","mobs","brew","matr","misc","all"} local builtin_filter_ids = {"blocks","deco","redstone","rail","food","tools","combat","mobs","brew","matr","misc","all"}
@ -37,7 +37,7 @@ do
return def.mesecons or def.groups.mesecon or def.groups.mesecon_conductor_craftable or def.groups.mesecon_effecor_off return def.mesecons or def.groups.mesecon or def.groups.mesecon_conductor_craftable or def.groups.mesecon_effecor_off
end end
local function is_tool(def) local function is_tool(def)
return def.groups.tool or (def.tool_capabilities ~= nil and def.tool_capabilities.damage_groups == nil) return def.groups.tool or (def.tool_capabilities and def.tool_capabilities.damage_groups == nil)
end end
local function is_weapon_or_armor(def) local function is_weapon_or_armor(def)
return def.groups.weapon or def.groups.weapon_ranged or def.groups.ammo or def.groups.combat_item or ((def.groups.armor_head or def.groups.armor_torso or def.groups.armor_legs or def.groups.armor_feet or def.groups.horse_armor) and def.groups.non_combat_armor ~= 1) return def.groups.weapon or def.groups.weapon_ranged or def.groups.ammo or def.groups.combat_item or ((def.groups.armor_head or def.groups.armor_torso or def.groups.armor_legs or def.groups.armor_feet or def.groups.horse_armor) and def.groups.non_combat_armor ~= 1)
@ -301,7 +301,7 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size,
if page == "nix" then if page == "nix" then
local inv = minetest.get_inventory({type="detached", name="creative_"..playername}) local inv = minetest.get_inventory({type="detached", name="creative_"..playername})
inv_size = inv:get_size("main") inv_size = inv:get_size("main")
elseif page ~= nil and page ~= "inv" then elseif page and page ~= "inv" then
inv_size = #(inventory_lists[page]) inv_size = #(inventory_lists[page])
else else
inv_size = 0 inv_size = 0
@ -314,7 +314,7 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size,
"listring[current_player;main]".. "listring[current_player;main]"..
"listring[detached:trash;main]" "listring[detached:trash;main]"
if page ~= nil then if page then
name = page name = page
if players[playername] then if players[playername] then
players[playername].page = page players[playername].page = page
@ -473,9 +473,7 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size,
formspec = formspec .. "field[5.3,1.34;4,0.75;search;;"..minetest.formspec_escape(filter).."]" formspec = formspec .. "field[5.3,1.34;4,0.75;search;;"..minetest.formspec_escape(filter).."]"
formspec = formspec .. "field_close_on_enter[search;false]" formspec = formspec .. "field_close_on_enter[search;false]"
end end
if pagenum ~= nil then formspec = formspec .. "p"..tostring(pagenum) end if pagenum then formspec = formspec .. "p"..tostring(pagenum) end
player:set_inventory_formspec(formspec) player:set_inventory_formspec(formspec)
end end
@ -545,7 +543,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
elseif fields.search == "" and not fields.creative_next and not fields.creative_prev then elseif fields.search == "" and not fields.creative_next and not fields.creative_prev then
set_inv_page("all", player) set_inv_page("all", player)
page = "nix" page = "nix"
elseif fields.search ~= nil and not fields.creative_next and not fields.creative_prev then elseif fields.search and not fields.creative_next and not fields.creative_prev then
set_inv_search(string.lower(fields.search),player) set_inv_search(string.lower(fields.search),player)
page = "nix" page = "nix"
end end
@ -578,7 +576,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if page == "nix" then if page == "nix" then
local inv = minetest.get_inventory({type="detached", name="creative_"..name}) local inv = minetest.get_inventory({type="detached", name="creative_"..name})
inv_size = inv:get_size("main") inv_size = inv:get_size("main")
elseif page ~= nil and page ~= "inv" then elseif page and page ~= "inv" then
inv_size = #(inventory_lists[page]) inv_size = #(inventory_lists[page])
else else
inv_size = 0 inv_size = 0
@ -593,7 +591,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
players[name].start_i = start_i players[name].start_i = start_i
local filter = "" local filter = ""
if not fields.nix and fields.search ~= nil and fields.search ~= "" then if not fields.nix and fields.search and fields.search ~= "" then
filter = fields.search filter = fields.search
players[name].filter = filter players[name].filter = filter
end end
@ -644,7 +642,7 @@ if minetest.is_creative_enabled("") then
if page == "nix" then if page == "nix" then
local inv = minetest.get_inventory({type="detached", name="creative_"..name}) local inv = minetest.get_inventory({type="detached", name="creative_"..name})
inv_size = inv:get_size("main") inv_size = inv:get_size("main")
elseif page ~= nil and page ~= "inv" then elseif page and page ~= "inv" then
inv_size = #(inventory_lists[page]) inv_size = #(inventory_lists[page])
else else
inv_size = 0 inv_size = 0

View File

@ -1,10 +1,10 @@
local S = minetest.get_translator("mcl_inventory") local S = minetest.get_translator(minetest.get_current_modname())
local F = minetest.formspec_escape local F = minetest.formspec_escape
mcl_inventory = {} mcl_inventory = {}
--local mod_player = minetest.get_modpath("mcl_player") ~= nil --local mod_player = minetest.get_modpath("mcl_player")
--local mod_craftguide = minetest.get_modpath("mcl_craftguide") ~= nil --local mod_craftguide = minetest.get_modpath("mcl_craftguide")
-- Returns a single itemstack in the given inventory to the main inventory, or drop it when there's no space left -- 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) function return_item(itemstack, dropper, pos, inv)

View File

@ -6,6 +6,10 @@ local huds = {}
local dtimes = {} local dtimes = {}
local dlimit = 3 -- HUD element will be hidden after this many seconds local dlimit = 3 -- HUD element will be hidden after this many seconds
local math = math
local string = string
local tonumber = tonumber
local hudbars_mod = minetest.get_modpath("hudbars") local hudbars_mod = minetest.get_modpath("hudbars")
local xp_mod = minetest.get_modpath("mcl_experience") local xp_mod = minetest.get_modpath("mcl_experience")
@ -74,7 +78,7 @@ minetest.register_globalstep(function(dtime)
if dtimes[player_name] and dtimes[player_name] < dlimit then if dtimes[player_name] and dtimes[player_name] < dlimit then
dtimes[player_name] = dtimes[player_name] + dtime dtimes[player_name] = dtimes[player_name] + dtime
if dtimes[player_name] > dlimit and huds[player_name] then if dtimes[player_name] > dlimit and huds[player_name] then
player:hud_change(huds[player_name], 'text', "") player:hud_change(huds[player_name], "text", "")
end end
end end
@ -105,7 +109,7 @@ minetest.register_globalstep(function(dtime)
if firstnewline then if firstnewline then
desc = string.sub(desc, 1, firstnewline-1) desc = string.sub(desc, 1, firstnewline-1)
end end
player:hud_change(huds[player_name], 'text', desc) player:hud_change(huds[player_name], "text", desc)
end end
end end
end end

View File

@ -1,8 +1,8 @@
local S = minetest.get_translator("mcl_comparators") local S = minetest.get_translator(minetest.get_current_modname())
-- Functions that get the input/output rules of the comparator -- Functions that get the input/output rules of the comparator
local comparator_get_output_rules = function(node) local function comparator_get_output_rules(node)
local rules = {{x = -1, y = 0, z = 0, spread=true}} local rules = {{x = -1, y = 0, z = 0, spread=true}}
for i = 0, node.param2 do for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules) rules = mesecon.rotate_rules_left(rules)
@ -11,7 +11,7 @@ local comparator_get_output_rules = function(node)
end end
local comparator_get_input_rules = function(node) local function comparator_get_input_rules(node)
local rules = { local rules = {
-- we rely on this order in update_self below -- we rely on this order in update_self below
{x = 1, y = 0, z = 0}, -- back {x = 1, y = 0, z = 0}, -- back
@ -27,13 +27,13 @@ end
-- Functions that are called after the delay time -- Functions that are called after the delay time
local comparator_turnon = function(params) local function comparator_turnon(params)
local rules = comparator_get_output_rules(params.node) local rules = comparator_get_output_rules(params.node)
mesecon.receptor_on(params.pos, rules) mesecon.receptor_on(params.pos, rules)
end end
local comparator_turnoff = function(params) local function comparator_turnoff(params)
local rules = comparator_get_output_rules(params.node) local rules = comparator_get_output_rules(params.node)
mesecon.receptor_off(params.pos, rules) mesecon.receptor_off(params.pos, rules)
end end
@ -41,14 +41,14 @@ end
-- Functions that set the correct node type an schedule a turnon/off -- Functions that set the correct node type an schedule a turnon/off
local comparator_activate = function(pos, node) local function comparator_activate(pos, node)
local def = minetest.registered_nodes[node.name] local def = minetest.registered_nodes[node.name]
minetest.swap_node(pos, { name = def.comparator_onstate, param2 = node.param2 }) minetest.swap_node(pos, { name = def.comparator_onstate, param2 = node.param2 })
minetest.after(0.1, comparator_turnon , {pos = pos, node = node}) minetest.after(0.1, comparator_turnon , {pos = pos, node = node})
end end
local comparator_deactivate = function(pos, node) local function comparator_deactivate(pos, node)
local def = minetest.registered_nodes[node.name] local def = minetest.registered_nodes[node.name]
minetest.swap_node(pos, { name = def.comparator_offstate, param2 = node.param2 }) minetest.swap_node(pos, { name = def.comparator_offstate, param2 = node.param2 })
minetest.after(0.1, comparator_turnoff, {pos = pos, node = node}) minetest.after(0.1, comparator_turnoff, {pos = pos, node = node})
@ -56,7 +56,7 @@ end
-- weather pos has an inventory that contains at least one item -- weather pos has an inventory that contains at least one item
local container_inventory_nonempty = function(pos) local function container_inventory_nonempty(pos)
local invnode = minetest.get_node(pos) local invnode = minetest.get_node(pos)
local invnodedef = minetest.registered_nodes[invnode.name] local invnodedef = minetest.registered_nodes[invnode.name]
-- Ignore stale nodes -- Ignore stale nodes
@ -78,14 +78,14 @@ local container_inventory_nonempty = function(pos)
end end
-- weather pos has an constant signal output for the comparator -- weather pos has an constant signal output for the comparator
local static_signal_output = function(pos) local function static_signal_output(pos)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local g = minetest.get_item_group(node.name, "comparator_signal") local g = minetest.get_item_group(node.name, "comparator_signal")
return g > 0 return g > 0
end end
-- whether the comparator should be on according to its inputs -- whether the comparator should be on according to its inputs
local comparator_desired_on = function(pos, node) local function comparator_desired_on(pos, node)
local my_input_rules = comparator_get_input_rules(node); local my_input_rules = comparator_get_input_rules(node);
local back_rule = my_input_rules[1] local back_rule = my_input_rules[1]
local state local state
@ -116,7 +116,7 @@ end
-- update comparator state, if needed -- update comparator state, if needed
local update_self = function(pos, node) local function update_self(pos, node)
node = node or minetest.get_node(pos) node = node or minetest.get_node(pos)
local old_state = mesecon.is_receptor_on(node.name) local old_state = mesecon.is_receptor_on(node.name)
local new_state = comparator_desired_on(pos, node) local new_state = comparator_desired_on(pos, node)
@ -131,7 +131,7 @@ end
-- compute tile depending on state and mode -- compute tile depending on state and mode
local get_tiles = function(state, mode) local function get_tiles(state, mode)
local top = "mcl_comparators_"..state..".png^".. local top = "mcl_comparators_"..state..".png^"..
"mcl_comparators_"..mode..".png" "mcl_comparators_"..mode..".png"
local sides = "mcl_comparators_sides_"..state..".png^".. local sides = "mcl_comparators_sides_"..state..".png^"..
@ -146,13 +146,13 @@ local get_tiles = function(state, mode)
end end
-- Given one mode, get the other mode -- Given one mode, get the other mode
local flipmode = function(mode) local function flipmode(mode)
if mode == "comp" then return "sub" if mode == "comp" then return "sub"
elseif mode == "sub" then return "comp" elseif mode == "sub" then return "comp"
end end
end end
local make_rightclick_handler = function(state, mode) local function make_rightclick_handler(state, mode)
local newnodename = local newnodename =
"mcl_comparators:comparator_"..state.."_"..flipmode(mode) "mcl_comparators:comparator_"..state.."_"..flipmode(mode)
return function (pos, node, clicker) return function (pos, node, clicker)
@ -260,7 +260,7 @@ for _, mode in pairs{"comp", "sub"} do
paramtype2 = "facedir", paramtype2 = "facedir",
sunlight_propagates = false, sunlight_propagates = false,
is_ground_content = false, is_ground_content = false,
drop = 'mcl_comparators:comparator_off_comp', drop = "mcl_comparators:comparator_off_comp",
on_construct = update_self, on_construct = update_self,
on_rightclick = on_rightclick =
make_rightclick_handler(state_str, mode), make_rightclick_handler(state_str, mode),

View File

@ -7,10 +7,10 @@
All node definitions share a lot of code, so this is the reason why there All node definitions share a lot of code, so this is the reason why there
are so many weird tables below. are so many weird tables below.
]] ]]
local S = minetest.get_translator("mcl_dispensers") local S = minetest.get_translator(minetest.get_current_modname())
-- For after_place_node -- For after_place_node
local setup_dispenser = function(pos) local function setup_dispenser(pos)
-- Set formspec and inventory -- Set formspec and inventory
local form = "size[9,8.75]".. local form = "size[9,8.75]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
@ -29,7 +29,7 @@ local setup_dispenser = function(pos)
inv:set_size("main", 9) inv:set_size("main", 9)
end end
local orientate_dispenser = function(pos, placer) local function orientate_dispenser(pos, placer)
-- Not placed by player -- Not placed by player
if not placer then return end if not placer then return end
@ -99,7 +99,7 @@ local dispenserdef = {
mesecons = { mesecons = {
effector = { effector = {
-- Dispense random item when triggered -- Dispense random item when triggered
action_on = function (pos, node) action_on = function(pos, node)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local droppos, dropdir local droppos, dropdir
@ -246,10 +246,11 @@ S("• Flint and steel: Is used to ignite a fire in air and to ignite TNT").."\n
S("• Spawn eggs: Will summon the mob they contain").."\n".. S("• Spawn eggs: Will summon the mob they contain").."\n"..
S("• Other items: Are simply dropped") S("• Other items: Are simply dropped")
horizontal_def.after_place_node = function(pos, placer, itemstack, pointed_thing) function horizontal_def.after_place_node(pos, placer, itemstack, pointed_thing)
setup_dispenser(pos) setup_dispenser(pos)
orientate_dispenser(pos, placer) orientate_dispenser(pos, placer)
end end
horizontal_def.tiles = { horizontal_def.tiles = {
"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_top.png", "default_furnace_bottom.png",
"default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png",
@ -287,7 +288,7 @@ minetest.register_node("mcl_dispensers:dispenser_up", up_def)
minetest.register_craft({ minetest.register_craft({
output = 'mcl_dispensers:dispenser', output = "mcl_dispensers:dispenser",
recipe = { recipe = {
{"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",}, {"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",},
{"mcl_core:cobble", "mcl_bows:bow", "mcl_core:cobble",}, {"mcl_core:cobble", "mcl_bows:bow", "mcl_core:cobble",},

View File

@ -8,10 +8,10 @@ All node definitions share a lot of code, so this is the reason why there
are so many weird tables below. are so many weird tables below.
]] ]]
local S = minetest.get_translator("mcl_droppers") local S = minetest.get_translator(minetest.get_current_modname())
-- For after_place_node -- For after_place_node
local setup_dropper = function(pos) local function setup_dropper(pos)
-- Set formspec and inventory -- Set formspec and inventory
local form = "size[9,8.75]".. local form = "size[9,8.75]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
@ -30,7 +30,7 @@ local setup_dropper = function(pos)
inv:set_size("main", 9) inv:set_size("main", 9)
end end
local orientate_dropper = function(pos, placer) local function orientate_dropper(pos, placer)
-- Not placed by player -- Not placed by player
if not placer then return end if not placer then return end
@ -98,7 +98,7 @@ local dropperdef = {
_mcl_hardness = 3.5, _mcl_hardness = 3.5,
mesecons = {effector = { mesecons = {effector = {
-- Drop random item when triggered -- Drop random item when triggered
action_on = function (pos, node) action_on = function(pos, node)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local droppos local droppos
@ -152,7 +152,7 @@ horizontal_def.description = S("Dropper")
horizontal_def._tt_help = S("9 inventory slots").."\n"..S("Drops item when powered by redstone power") horizontal_def._tt_help = S("9 inventory slots").."\n"..S("Drops item when powered by redstone power")
horizontal_def._doc_items_longdesc = S("A dropper is a redstone component and a container with 9 inventory slots which, when supplied with redstone power, drops an item or puts it into a container in front of it.") horizontal_def._doc_items_longdesc = S("A dropper is a redstone component and a container with 9 inventory slots which, when supplied with redstone power, drops an item or puts it into a container in front of it.")
horizontal_def._doc_items_usagehelp = S("Droppers can be placed in 6 possible directions, items will be dropped out of the hole. Use the dropper to access its inventory. Supply it with redstone energy once to make the dropper drop or transfer a random item.") horizontal_def._doc_items_usagehelp = S("Droppers can be placed in 6 possible directions, items will be dropped out of the hole. Use the dropper to access its inventory. Supply it with redstone energy once to make the dropper drop or transfer a random item.")
horizontal_def.after_place_node = function(pos, placer, itemstack, pointed_thing) function horizontal_def.after_place_node(pos, placer, itemstack, pointed_thing)
setup_dropper(pos) setup_dropper(pos)
orientate_dropper(pos, placer) orientate_dropper(pos, placer)
end end
@ -195,7 +195,7 @@ minetest.register_node("mcl_droppers:dropper_up", up_def)
-- Ladies and gentlemen, I present to you: the crafting recipe! -- Ladies and gentlemen, I present to you: the crafting recipe!
minetest.register_craft({ minetest.register_craft({
output = 'mcl_droppers:dropper', output = "mcl_droppers:dropper",
recipe = { recipe = {
{"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",}, {"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",},
{"mcl_core:cobble", "", "mcl_core:cobble",}, {"mcl_core:cobble", "", "mcl_core:cobble",},

View File

@ -8,10 +8,10 @@ All node definitions share a lot of code, so this is the reason why there
are so many weird tables below. are so many weird tables below.
]] ]]
local S = minetest.get_translator("mcl_droppers") local S = minetest.get_translator(minetest.get_current_modname())
-- For after_place_node -- For after_place_node
local setup_dropper = function(pos) local function setup_dropper(pos)
-- Set formspec and inventory -- Set formspec and inventory
local form = "size[9,8.75]".. local form = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]".. "background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]"..
@ -28,7 +28,7 @@ local setup_dropper = function(pos)
inv:set_size("main", 9) inv:set_size("main", 9)
end end
local orientate_dropper = function(pos, placer) local function orientate_dropper(pos, placer)
-- Not placed by player -- Not placed by player
if not placer then return end if not placer then return end
@ -96,7 +96,7 @@ local dropperdef = {
_mcl_hardness = 3.5, _mcl_hardness = 3.5,
mesecons = {effector = { mesecons = {effector = {
-- Drop random item when triggered -- Drop random item when triggered
action_on = function (pos, node) action_on = function(pos, node)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local droppos local droppos
@ -149,14 +149,16 @@ local horizontal_def = table.copy(dropperdef)
horizontal_def.description = S("Dropper") horizontal_def.description = S("Dropper")
horizontal_def._doc_items_longdesc = S("A dropper is a redstone component and a container with 9 inventory slots which, when supplied with redstone power, drops an item or puts it into a container in front of it.") horizontal_def._doc_items_longdesc = S("A dropper is a redstone component and a container with 9 inventory slots which, when supplied with redstone power, drops an item or puts it into a container in front of it.")
horizontal_def._doc_items_usagehelp = S("Droppers can be placed in 6 possible directions, items will be dropped out of the hole. Use the dropper to access its inventory. Supply it with redstone energy once to make the dropper drop or transfer a random item.") horizontal_def._doc_items_usagehelp = S("Droppers can be placed in 6 possible directions, items will be dropped out of the hole. Use the dropper to access its inventory. Supply it with redstone energy once to make the dropper drop or transfer a random item.")
horizontal_def.after_place_node = function(pos, placer, itemstack, pointed_thing)
function horizontal_def.after_place_node(pos, placer, itemstack, pointed_thing)
setup_dropper(pos) setup_dropper(pos)
orientate_dropper(pos, placer) orientate_dropper(pos, placer)
end end
horizontal_def.tiles = { horizontal_def.tiles = {
"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_top.png", "default_furnace_bottom.png",
"default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png",
"default_furnace_side.png", "mcl_droppers_dropper_front_horizontal.png" "default_furnace_side.png", "mcl_droppers_dropper_front_horizontal.png",
} }
horizontal_def.paramtype2 = "facedir" horizontal_def.paramtype2 = "facedir"
horizontal_def.groups = {pickaxey=1, container=2, material_stone=1} horizontal_def.groups = {pickaxey=1, container=2, material_stone=1}
@ -170,7 +172,7 @@ down_def.after_place_node = setup_dropper
down_def.tiles = { down_def.tiles = {
"default_furnace_top.png", "mcl_droppers_dropper_front_vertical.png", "default_furnace_top.png", "mcl_droppers_dropper_front_vertical.png",
"default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png",
"default_furnace_side.png", "default_furnace_side.png" "default_furnace_side.png", "default_furnace_side.png",
} }
down_def.groups = {pickaxey=1, container=2,not_in_creative_inventory=1, material_stone=1} down_def.groups = {pickaxey=1, container=2,not_in_creative_inventory=1, material_stone=1}
down_def._doc_items_create_entry = false down_def._doc_items_create_entry = false
@ -184,7 +186,7 @@ up_def.description = S("Upwards-Facing Dropper")
up_def.tiles = { up_def.tiles = {
"mcl_droppers_dropper_front_vertical.png", "default_furnace_bottom.png", "mcl_droppers_dropper_front_vertical.png", "default_furnace_bottom.png",
"default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png",
"default_furnace_side.png", "default_furnace_side.png" "default_furnace_side.png", "default_furnace_side.png",
} }
minetest.register_node("mcl_droppers:dropper_up", up_def) minetest.register_node("mcl_droppers:dropper_up", up_def)
@ -192,7 +194,7 @@ minetest.register_node("mcl_droppers:dropper_up", up_def)
-- Ladies and gentlemen, I present to you: the crafting recipe! -- Ladies and gentlemen, I present to you: the crafting recipe!
minetest.register_craft({ minetest.register_craft({
output = 'mcl_droppers:dropper', output = "mcl_droppers:dropper",
recipe = { recipe = {
{"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",}, {"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",},
{"mcl_core:cobble", "", "mcl_core:cobble",}, {"mcl_core:cobble", "", "mcl_core:cobble",},

View File

@ -1,4 +1,4 @@
local S = minetest.get_translator("mcl_observers") local S = minetest.get_translator(minetest.get_current_modname())
mcl_observers = {} mcl_observers = {}

View File

@ -1,3 +1,5 @@
local table = table
mesecon.queue.actions={} -- contains all ActionQueue actions mesecon.queue.actions={} -- contains all ActionQueue actions
function mesecon.queue:add_function(name, func) function mesecon.queue:add_function(name, func)
@ -31,7 +33,7 @@ function mesecon.queue:add_action(pos, func, params, time, overwritecheck, prior
end end
end end
if (toremove ~= nil) then if toremove then
table.remove(mesecon.queue.actions, toremove) table.remove(mesecon.queue.actions, toremove)
end end
@ -43,7 +45,7 @@ end
-- this makes sure that resuming mesecons circuits when restarting minetest works fine -- this makes sure that resuming mesecons circuits when restarting minetest works fine
-- However, even that does not work in some cases, that's why we delay the time the globalsteps -- However, even that does not work in some cases, that's why we delay the time the globalsteps
-- start to be execute by 5 seconds -- start to be execute by 5 seconds
local get_highest_priority = function (actions) local function get_highest_priority(actions)
local highestp = -1 local highestp = -1
local highesti local highesti
for i, ac in ipairs(actions) do for i, ac in ipairs(actions) do

View File

@ -138,7 +138,7 @@ local function receptor_get_rules(node)
local receptor = mesecon.get_receptor(node.name) local receptor = mesecon.get_receptor(node.name)
if receptor then if receptor then
local rules = receptor.rules local rules = receptor.rules
if type(rules) == 'function' then if type(rules) == "function" then
return rules(node) return rules(node)
elseif rules then elseif rules then
return rules return rules
@ -179,7 +179,7 @@ function mesecon.effector_get_rules(node)
local effector = mesecon.get_effector(node.name) local effector = mesecon.get_effector(node.name)
if effector then if effector then
local rules = effector.rules local rules = effector.rules
if type(rules) == 'function' then if type(rules) == "function" then
return rules(node) return rules(node)
elseif rules then elseif rules then
return rules return rules
@ -352,7 +352,7 @@ function mesecon.conductor_get_rules(node)
local conductor = mesecon.get_conductor(node.name) local conductor = mesecon.get_conductor(node.name)
if conductor then if conductor then
local rules = conductor.rules local rules = conductor.rules
if type(rules) == 'function' then if type(rules) == "function" then
return rules(node) return rules(node)
elseif rules then elseif rules then
return rules return rules

View File

@ -1,7 +1,7 @@
-- WALL BUTTON -- WALL BUTTON
-- A button that when pressed emits power for a short moment and then turns off again -- A button that when pressed emits power for a short moment and then turns off again
local S = minetest.get_translator("mesecons_button") local S = minetest.get_translator(minetest.get_current_modname())
local button_sounds = {} -- remember button push sounds local button_sounds = {} -- remember button push sounds
@ -37,7 +37,7 @@ function mesecon.push_button(pos, node)
timer:start(def._mcl_button_timer) timer:start(def._mcl_button_timer)
end end
local on_button_place = function(itemstack, placer, pointed_thing) local function on_button_place(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then if pointed_thing.type ~= "node" then
-- no interaction possible with entities -- no interaction possible with entities
return itemstack return itemstack
@ -86,7 +86,7 @@ end
local buttonuse = S("Use the button to push it.") local buttonuse = S("Use the button to push it.")
mesecon.register_button = function(basename, description, texture, recipeitem, sounds, plusgroups, button_timer, push_by_arrow, longdesc, button_sound) function mesecon.register_button(basename, description, texture, recipeitem, sounds, plusgroups, button_timer, push_by_arrow, longdesc, button_sound)
local groups_off = table.copy(plusgroups) local groups_off = table.copy(plusgroups)
groups_off.attached_node=1 groups_off.attached_node=1
groups_off.dig_by_water=1 groups_off.dig_by_water=1
@ -132,7 +132,7 @@ mesecon.register_button = function(basename, description, texture, recipeitem, s
_doc_items_usagehelp = buttonuse, _doc_items_usagehelp = buttonuse,
on_place = on_button_place, on_place = on_button_place,
node_placement_prediction = "", node_placement_prediction = "",
on_rightclick = function (pos, node) on_rightclick = function(pos, node)
mesecon.push_button(pos, node) mesecon.push_button(pos, node)
end, end,
sounds = sounds, sounds = sounds,
@ -159,7 +159,7 @@ mesecon.register_button = function(basename, description, texture, recipeitem, s
sunlight_propagates = true, sunlight_propagates = true,
node_box = boxes_on, node_box = boxes_on,
groups = groups_on, groups = groups_on,
drop = 'mesecons_button:button_'..basename..'_off', drop = "mesecons_button:button_"..basename.."_off",
_doc_items_create_entry = false, _doc_items_create_entry = false,
node_placement_prediction = "", node_placement_prediction = "",
sounds = sounds, sounds = sounds,

View File

@ -1,6 +1,8 @@
local S = minetest.get_translator("mesecons_commandblock") local S = minetest.get_translator(minetest.get_current_modname())
local F = minetest.formspec_escape local F = minetest.formspec_escape
local tonumber = tonumber
local color_red = mcl_colors.RED local color_red = mcl_colors.RED
local command_blocks_activated = minetest.settings:get_bool("mcl_enable_commandblocks", true) local command_blocks_activated = minetest.settings:get_bool("mcl_enable_commandblocks", true)
@ -27,7 +29,7 @@ local function resolve_commands(commands, pos)
local commander = meta:get_string("commander") local commander = meta:get_string("commander")
-- A non-printable character used while replacing “@@”. -- A non-printable character used while replacing “@@”.
local SUBSTITUTE_CHARACTER = '\26' -- ASCII SUB local SUBSTITUTE_CHARACTER = "\26" -- ASCII SUB
-- No players online: remove all commands containing -- No players online: remove all commands containing
-- problematic placeholders. -- problematic placeholders.
@ -137,7 +139,7 @@ local function commandblock_action_off(pos, node)
end end
end end
local on_rightclick = function(pos, node, player, itemstack, pointed_thing) local function on_rightclick(pos, node, player, itemstack, pointed_thing)
if not command_blocks_activated then if not command_blocks_activated then
minetest.chat_send_player(player:get_player_name(), msg_not_activated) minetest.chat_send_player(player:get_player_name(), msg_not_activated)
return return
@ -192,19 +194,19 @@ local on_rightclick = function(pos, node, player, itemstack, pointed_thing)
minetest.show_formspec(pname, "commandblock_"..pos.x.."_"..pos.y.."_"..pos.z, formspec) minetest.show_formspec(pname, "commandblock_"..pos.x.."_"..pos.y.."_"..pos.z, formspec)
end end
local on_place = function(itemstack, placer, pointed_thing) local function on_place(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then if pointed_thing.type ~= "node" then
return itemstack return itemstack
end end
-- Use pointed node's on_rightclick function first, if present -- Use pointed node's on_rightclick function first, if present
local node = minetest.get_node(pointed_thing.under) local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing)
if placer and not placer:get_player_control().sneak then if new_stack then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then return new_stack
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
end
end end
--local node = minetest.get_node(pointed_thing.under)
local privs = minetest.get_player_privs(placer:get_player_name()) local privs = minetest.get_player_privs(placer:get_player_name())
if not privs.maphack then if not privs.maphack then
minetest.chat_send_player(placer:get_player_name(), S("Placement denied. You need the “maphack” privilege to place command blocks.")) minetest.chat_send_player(placer:get_player_name(), S("Placement denied. You need the “maphack” privilege to place command blocks."))
@ -295,8 +297,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end end
local index, _, x, y, z = string.find(formname, "commandblock_(-?%d+)_(-?%d+)_(-?%d+)") local index, _, x, y, z = string.find(formname, "commandblock_(-?%d+)_(-?%d+)_(-?%d+)")
if index ~= nil and x ~= nil and y ~= nil and z ~= nil then if index and x and y and z then
local pos = {x=tonumber(x), y=tonumber(y), z=tonumber(z)} local pos = {x = tonumber(x), y = tonumber(y), z = tonumber(z)}
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
if not minetest.is_creative_enabled(player:get_player_name()) then if not minetest.is_creative_enabled(player:get_player_name()) then
minetest.chat_send_player(player:get_player_name(), S("Editing the command block has failed! You can only change the command block in Creative Mode!")) minetest.chat_send_player(player:get_player_name(), S("Editing the command block has failed! You can only change the command block in Creative Mode!"))

View File

@ -1,3 +1,3 @@
name = mesecons_commandblock name = mesecons_commandblock
depends = mesecons, mcl_colors depends = mesecons, mcl_colors, mcl_util
optional_depends = doc, doc_items optional_depends = doc, doc_items

View File

@ -1,4 +1,4 @@
local S = minetest.get_translator("mesecons_delayer") local S = minetest.get_translator(minetest.get_current_modname())
local DELAYS = { 0.1, 0.2, 0.3, 0.4 } local DELAYS = { 0.1, 0.2, 0.3, 0.4 }
local DEFAULT_DELAY = DELAYS[1] local DEFAULT_DELAY = DELAYS[1]
@ -264,8 +264,8 @@ for i = 1, 4 do
paramtype2 = "facedir", paramtype2 = "facedir",
sunlight_propagates = false, sunlight_propagates = false,
is_ground_content = false, is_ground_content = false,
drop = 'mesecons_delayer:delayer_off_1', drop = "mesecons_delayer:delayer_off_1",
on_rightclick = function (pos, node, clicker) on_rightclick = function(pos, node, clicker)
local protname = clicker:get_player_name() local protname = clicker:get_player_name()
if minetest.is_protected(pos, protname) then if minetest.is_protected(pos, protname) then
minetest.record_protection_violation(pos, protname) minetest.record_protection_violation(pos, protname)
@ -330,8 +330,8 @@ for i = 1, 4 do
paramtype2 = "facedir", paramtype2 = "facedir",
sunlight_propagates = false, sunlight_propagates = false,
is_ground_content = false, is_ground_content = false,
drop = 'mesecons_delayer:delayer_off_1', drop = "mesecons_delayer:delayer_off_1",
on_rightclick = function (pos, node, clicker) on_rightclick = function(pos, node, clicker)
local protname = clicker:get_player_name() local protname = clicker:get_player_name()
if minetest.is_protected(pos, protname) then if minetest.is_protected(pos, protname) then
minetest.record_protection_violation(pos, protname) minetest.record_protection_violation(pos, protname)
@ -410,7 +410,7 @@ minetest.register_node("mesecons_delayer:delayer_off_locked", {
paramtype2 = "facedir", paramtype2 = "facedir",
sunlight_propagates = false, sunlight_propagates = false,
is_ground_content = false, is_ground_content = false,
drop = 'mesecons_delayer:delayer_off_1', drop = "mesecons_delayer:delayer_off_1",
delayer_time = DEFAULT_DELAY, delayer_time = DEFAULT_DELAY,
sounds = mcl_sounds.node_sound_stone_defaults(), sounds = mcl_sounds.node_sound_stone_defaults(),
mesecons = { mesecons = {
@ -465,7 +465,7 @@ minetest.register_node("mesecons_delayer:delayer_on_locked", {
paramtype2 = "facedir", paramtype2 = "facedir",
sunlight_propagates = false, sunlight_propagates = false,
is_ground_content = false, is_ground_content = false,
drop = 'mesecons_delayer:delayer_off_1', drop = "mesecons_delayer:delayer_off_1",
delayer_time = DEFAULT_DELAY, delayer_time = DEFAULT_DELAY,
sounds = mcl_sounds.node_sound_stone_defaults(), sounds = mcl_sounds.node_sound_stone_defaults(),
mesecons = { mesecons = {

Some files were not shown because too many files have changed in this diff Show More