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 g, _ in pairs(mcl_autogroup.registered_diggroups) do
if ndef.groups[g] ~= nil then
if ndef.groups[g] then
maps[g][ndef._mcl_hardness or 0] = true
end
end

View File

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

View File

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

View File

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

View File

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

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 paddling_speed = 22
@ -470,6 +470,6 @@ minetest.register_craft({
burntime = 20,
})
if minetest.get_modpath("doc_identifier") ~= nil then
if minetest.get_modpath("doc_identifier") then
doc.sub.identifier.register_object("mcl_boats:boat", "craftitems", "mcl_boats:boat")
end

View File

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

View File

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

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

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
local function register_rail(itemstring, tiles, def_extras, creative)
@ -206,11 +206,11 @@ register_rail("mcl_minecarts:detector_rail_on",
-- Crafting
minetest.register_craft({
output = 'mcl_minecarts:rail 16',
output = "mcl_minecarts:rail 16",
recipe = {
{'mcl_core:iron_ingot', '', 'mcl_core:iron_ingot'},
{'mcl_core:iron_ingot', 'mcl_core:stick', 'mcl_core:iron_ingot'},
{'mcl_core:iron_ingot', '', 'mcl_core:iron_ingot'},
{"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"},
{"mcl_core:iron_ingot", "mcl_core:stick", "mcl_core:iron_ingot"},
{"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"},
}
})

View File

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

View File

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

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

View File

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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 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 = {}
@ -12,6 +12,6 @@ dofile(modpath.."/snow.lua")
dofile(modpath.."/rain.lua")
dofile(modpath.."/nether_dust.lua")
if minetest.get_modpath("lightning") ~= nil then
if minetest.get_modpath("lightning") then
dofile(modpath.."/thunder.lua")
end

View File

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

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

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

View File

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

View File

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

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

View File

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

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", {
name = S("Creative Mode"),

View File

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

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 mintime

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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)
local sorting = minetest.settings:get("hudbars_sorting")
if sorting ~= nil then
if sorting then
hb.settings.sorting = {}
hb.settings.sorting_reverse = {}
for k,v in string.gmatch(sorting, "(%w+)=(%w+)") do

View File

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

View File

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

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 = {
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 = {}

View File

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

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
-- Prepare player info table
@ -7,7 +7,7 @@ local players = {}
-- Containing all the items for each Creative Mode tab
local inventory_lists = {}
--local mod_player = minetest.get_modpath("mcl_player") ~= nil
--local mod_player = minetest.get_modpath("mcl_player")
-- Create tables
local builtin_filter_ids = {"blocks","deco","redstone","rail","food","tools","combat","mobs","brew","matr","misc","all"}
@ -37,7 +37,7 @@ do
return def.mesecons or def.groups.mesecon or def.groups.mesecon_conductor_craftable or def.groups.mesecon_effecor_off
end
local function is_tool(def)
return def.groups.tool or (def.tool_capabilities ~= nil and def.tool_capabilities.damage_groups == nil)
return def.groups.tool or (def.tool_capabilities and def.tool_capabilities.damage_groups == nil)
end
local function is_weapon_or_armor(def)
return def.groups.weapon or def.groups.weapon_ranged or def.groups.ammo or def.groups.combat_item or ((def.groups.armor_head or def.groups.armor_torso or def.groups.armor_legs or def.groups.armor_feet or def.groups.horse_armor) and def.groups.non_combat_armor ~= 1)
@ -301,7 +301,7 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size,
if page == "nix" then
local inv = minetest.get_inventory({type="detached", name="creative_"..playername})
inv_size = inv:get_size("main")
elseif page ~= nil and page ~= "inv" then
elseif page and page ~= "inv" then
inv_size = #(inventory_lists[page])
else
inv_size = 0
@ -314,7 +314,7 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size,
"listring[current_player;main]"..
"listring[detached:trash;main]"
if page ~= nil then
if page then
name = page
if players[playername] then
players[playername].page = page
@ -322,160 +322,158 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size,
end
--bg[name] = "crafting_creative_bg.png"
local inv_bg = "crafting_inventory_creative.png"
if name == "inv" then
inv_bg = "crafting_inventory_creative_survival.png"
local inv_bg = "crafting_inventory_creative.png"
if name == "inv" then
inv_bg = "crafting_inventory_creative_survival.png"
-- Show armor and player image
local player_preview
if minetest.settings:get_bool("3d_player_preview", true) then
player_preview = mcl_player.get_player_formspec_model(player, 3.9, 1.4, 1.2333, 2.4666, "")
else
player_preview = "image[3.9,1.4;1.2333,2.4666;"..mcl_player.player_get_preview(player).."]"
end
-- Background images for armor slots (hide if occupied)
local armor_slot_imgs = ""
local inv = player:get_inventory()
if inv:get_stack("armor", 2):is_empty() then
armor_slot_imgs = armor_slot_imgs .. "image[2.5,1.3;1,1;mcl_inventory_empty_armor_slot_helmet.png]"
end
if inv:get_stack("armor", 3):is_empty() then
armor_slot_imgs = armor_slot_imgs .. "image[2.5,2.75;1,1;mcl_inventory_empty_armor_slot_chestplate.png]"
end
if inv:get_stack("armor", 4):is_empty() then
armor_slot_imgs = armor_slot_imgs .. "image[5.5,1.3;1,1;mcl_inventory_empty_armor_slot_leggings.png]"
end
if inv:get_stack("armor", 5):is_empty() then
armor_slot_imgs = armor_slot_imgs .. "image[5.5,2.75;1,1;mcl_inventory_empty_armor_slot_boots.png]"
end
-- Survival inventory slots
main_list = "list[current_player;main;0,3.75;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,3.75,9,3)..
-- armor
"list[current_player;armor;2.5,1.3;1,1;1]"..
"list[current_player;armor;2.5,2.75;1,1;2]"..
"list[current_player;armor;5.5,1.3;1,1;3]"..
"list[current_player;armor;5.5,2.75;1,1;4]"..
mcl_formspec.get_itemslot_bg(2.5,1.3,1,1)..
mcl_formspec.get_itemslot_bg(2.5,2.75,1,1)..
mcl_formspec.get_itemslot_bg(5.5,1.3,1,1)..
mcl_formspec.get_itemslot_bg(5.5,2.75,1,1)..
armor_slot_imgs..
-- player preview
player_preview..
-- crafting guide button
"image_button[9,1;1,1;craftguide_book.png;__mcl_craftguide;]"..
"tooltip[__mcl_craftguide;"..F(S("Recipe book")).."]"..
-- help button
"image_button[9,2;1,1;doc_button_icon_lores.png;__mcl_doc;]"..
"tooltip[__mcl_doc;"..F(S("Help")).."]"..
-- skins button
"image_button[9,3;1,1;mcl_skins_button.png;__mcl_skins;]"..
"tooltip[__mcl_skins;"..F(S("Select player skin")).."]"..
-- achievements button
"image_button[9,4;1,1;mcl_achievements_button.png;__mcl_achievements;]"..
--"style_type[image_button;border=;bgimg=;bgimg_pressed=]"..
"tooltip[__mcl_achievements;"..F(S("Achievements")).."]"
-- For shortcuts
listrings = listrings ..
"listring[detached:"..playername.."_armor;armor]"..
"listring[current_player;main]"
-- Show armor and player image
local player_preview
if minetest.settings:get_bool("3d_player_preview", true) then
player_preview = mcl_player.get_player_formspec_model(player, 3.9, 1.4, 1.2333, 2.4666, "")
else
-- Creative inventory slots
main_list = "list[detached:creative_"..playername..";main;0,1.75;9,5;"..tostring(start_i).."]"..
mcl_formspec.get_itemslot_bg(0,1.75,9,5)..
-- Page buttons
"label[9.0,5.5;"..F(S("@1/@2", pagenum, pagemax)).."]"..
"image_button[9.0,6.0;0.7,0.7;crafting_creative_prev.png;creative_prev;]"..
"image_button[9.5,6.0;0.7,0.7;crafting_creative_next.png;creative_next;]"
player_preview = "image[3.9,1.4;1.2333,2.4666;"..mcl_player.player_get_preview(player).."]"
end
local tab_icon = {
blocks = "mcl_core:brick_block",
deco = "mcl_flowers:peony",
redstone = "mesecons:redstone",
rail = "mcl_minecarts:golden_rail",
misc = "mcl_buckets:bucket_lava",
nix = "mcl_compass:compass",
food = "mcl_core:apple",
tools = "mcl_core:axe_iron",
combat = "mcl_core:sword_gold",
mobs = "mobs_mc:cow",
brew = "mcl_potions:dragon_breath",
matr = "mcl_core:stick",
inv = "mcl_chests:chest",
}
local function tab(current_tab, this_tab)
local bg_img
if current_tab == this_tab then
bg_img = "crafting_creative_active"..hoch[this_tab]..".png"
else
bg_img = "crafting_creative_inactive"..hoch[this_tab]..".png"
end
return
"style["..this_tab..";border=false;bgimg=;bgimg_pressed=]"..
"item_image_button[" .. boffset[this_tab] ..";1,1;"..tab_icon[this_tab]..";"..this_tab..";]"..
"image[" .. offset[this_tab] .. ";1.5,1.44;" .. bg_img .. "]" ..
"image[" .. boffset[this_tab] .. ";1,1;crafting_creative_marker.png]"
-- Background images for armor slots (hide if occupied)
local armor_slot_imgs = ""
local inv = player:get_inventory()
if inv:get_stack("armor", 2):is_empty() then
armor_slot_imgs = armor_slot_imgs .. "image[2.5,1.3;1,1;mcl_inventory_empty_armor_slot_helmet.png]"
end
local caption = ""
if name ~= "inv" and filtername[name] then
caption = "label[0,1.2;"..F(minetest.colorize("#313131", filtername[name])).."]"
if inv:get_stack("armor", 3):is_empty() then
armor_slot_imgs = armor_slot_imgs .. "image[2.5,2.75;1,1;mcl_inventory_empty_armor_slot_chestplate.png]"
end
if inv:get_stack("armor", 4):is_empty() then
armor_slot_imgs = armor_slot_imgs .. "image[5.5,1.3;1,1;mcl_inventory_empty_armor_slot_leggings.png]"
end
if inv:get_stack("armor", 5):is_empty() then
armor_slot_imgs = armor_slot_imgs .. "image[5.5,2.75;1,1;mcl_inventory_empty_armor_slot_boots.png]"
end
local formspec = "size[10,9.3]"..
"no_prepend[]"..
mcl_vars.gui_nonbg..mcl_vars.gui_bg_color..
"background[-0.19,-0.25;10.5,9.87;"..inv_bg.."]"..
"label[-5,-5;"..name.."]"..
tab(name, "blocks") ..
"tooltip[blocks;"..F(filtername["blocks"]).."]"..
tab(name, "deco") ..
"tooltip[deco;"..F(filtername["deco"]).."]"..
tab(name, "redstone") ..
"tooltip[redstone;"..F(filtername["redstone"]).."]"..
tab(name, "rail") ..
"tooltip[rail;"..F(filtername["rail"]).."]"..
tab(name, "misc") ..
"tooltip[misc;"..F(filtername["misc"]).."]"..
tab(name, "nix") ..
"tooltip[nix;"..F(filtername["nix"]).."]"..
caption..
"list[current_player;main;0,7;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7,9,1)..
main_list..
tab(name, "food") ..
"tooltip[food;"..F(filtername["food"]).."]"..
tab(name, "tools") ..
"tooltip[tools;"..F(filtername["tools"]).."]"..
tab(name, "combat") ..
"tooltip[combat;"..F(filtername["combat"]).."]"..
tab(name, "mobs") ..
"tooltip[mobs;"..F(filtername["mobs"]).."]"..
tab(name, "brew") ..
"tooltip[brew;"..F(filtername["brew"]).."]"..
tab(name, "matr") ..
"tooltip[matr;"..F(filtername["matr"]).."]"..
tab(name, "inv") ..
"tooltip[inv;"..F(filtername["inv"]).."]"..
"list[detached:trash;main;9,7;1,1;]"..
mcl_formspec.get_itemslot_bg(9,7,1,1)..
"image[9,7;1,1;crafting_creative_trash.png]"..
listrings
-- Survival inventory slots
main_list = "list[current_player;main;0,3.75;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,3.75,9,3)..
-- armor
"list[current_player;armor;2.5,1.3;1,1;1]"..
"list[current_player;armor;2.5,2.75;1,1;2]"..
"list[current_player;armor;5.5,1.3;1,1;3]"..
"list[current_player;armor;5.5,2.75;1,1;4]"..
mcl_formspec.get_itemslot_bg(2.5,1.3,1,1)..
mcl_formspec.get_itemslot_bg(2.5,2.75,1,1)..
mcl_formspec.get_itemslot_bg(5.5,1.3,1,1)..
mcl_formspec.get_itemslot_bg(5.5,2.75,1,1)..
armor_slot_imgs..
-- player preview
player_preview..
-- crafting guide button
"image_button[9,1;1,1;craftguide_book.png;__mcl_craftguide;]"..
"tooltip[__mcl_craftguide;"..F(S("Recipe book")).."]"..
-- help button
"image_button[9,2;1,1;doc_button_icon_lores.png;__mcl_doc;]"..
"tooltip[__mcl_doc;"..F(S("Help")).."]"..
-- skins button
"image_button[9,3;1,1;mcl_skins_button.png;__mcl_skins;]"..
"tooltip[__mcl_skins;"..F(S("Select player skin")).."]"..
-- achievements button
"image_button[9,4;1,1;mcl_achievements_button.png;__mcl_achievements;]"..
--"style_type[image_button;border=;bgimg=;bgimg_pressed=]"..
"tooltip[__mcl_achievements;"..F(S("Achievements")).."]"
if name == "nix" then
if filter == nil then
filter = ""
end
formspec = formspec .. "field[5.3,1.34;4,0.75;search;;"..minetest.formspec_escape(filter).."]"
formspec = formspec .. "field_close_on_enter[search;false]"
end
if pagenum ~= nil then formspec = formspec .. "p"..tostring(pagenum) end
-- For shortcuts
listrings = listrings ..
"listring[detached:"..playername.."_armor;armor]"..
"listring[current_player;main]"
else
-- Creative inventory slots
main_list = "list[detached:creative_"..playername..";main;0,1.75;9,5;"..tostring(start_i).."]"..
mcl_formspec.get_itemslot_bg(0,1.75,9,5)..
-- Page buttons
"label[9.0,5.5;"..F(S("@1/@2", pagenum, pagemax)).."]"..
"image_button[9.0,6.0;0.7,0.7;crafting_creative_prev.png;creative_prev;]"..
"image_button[9.5,6.0;0.7,0.7;crafting_creative_next.png;creative_next;]"
end
local tab_icon = {
blocks = "mcl_core:brick_block",
deco = "mcl_flowers:peony",
redstone = "mesecons:redstone",
rail = "mcl_minecarts:golden_rail",
misc = "mcl_buckets:bucket_lava",
nix = "mcl_compass:compass",
food = "mcl_core:apple",
tools = "mcl_core:axe_iron",
combat = "mcl_core:sword_gold",
mobs = "mobs_mc:cow",
brew = "mcl_potions:dragon_breath",
matr = "mcl_core:stick",
inv = "mcl_chests:chest",
}
local function tab(current_tab, this_tab)
local bg_img
if current_tab == this_tab then
bg_img = "crafting_creative_active"..hoch[this_tab]..".png"
else
bg_img = "crafting_creative_inactive"..hoch[this_tab]..".png"
end
return
"style["..this_tab..";border=false;bgimg=;bgimg_pressed=]"..
"item_image_button[" .. boffset[this_tab] ..";1,1;"..tab_icon[this_tab]..";"..this_tab..";]"..
"image[" .. offset[this_tab] .. ";1.5,1.44;" .. bg_img .. "]" ..
"image[" .. boffset[this_tab] .. ";1,1;crafting_creative_marker.png]"
end
local caption = ""
if name ~= "inv" and filtername[name] then
caption = "label[0,1.2;"..F(minetest.colorize("#313131", filtername[name])).."]"
end
local formspec = "size[10,9.3]"..
"no_prepend[]"..
mcl_vars.gui_nonbg..mcl_vars.gui_bg_color..
"background[-0.19,-0.25;10.5,9.87;"..inv_bg.."]"..
"label[-5,-5;"..name.."]"..
tab(name, "blocks") ..
"tooltip[blocks;"..F(filtername["blocks"]).."]"..
tab(name, "deco") ..
"tooltip[deco;"..F(filtername["deco"]).."]"..
tab(name, "redstone") ..
"tooltip[redstone;"..F(filtername["redstone"]).."]"..
tab(name, "rail") ..
"tooltip[rail;"..F(filtername["rail"]).."]"..
tab(name, "misc") ..
"tooltip[misc;"..F(filtername["misc"]).."]"..
tab(name, "nix") ..
"tooltip[nix;"..F(filtername["nix"]).."]"..
caption..
"list[current_player;main;0,7;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7,9,1)..
main_list..
tab(name, "food") ..
"tooltip[food;"..F(filtername["food"]).."]"..
tab(name, "tools") ..
"tooltip[tools;"..F(filtername["tools"]).."]"..
tab(name, "combat") ..
"tooltip[combat;"..F(filtername["combat"]).."]"..
tab(name, "mobs") ..
"tooltip[mobs;"..F(filtername["mobs"]).."]"..
tab(name, "brew") ..
"tooltip[brew;"..F(filtername["brew"]).."]"..
tab(name, "matr") ..
"tooltip[matr;"..F(filtername["matr"]).."]"..
tab(name, "inv") ..
"tooltip[inv;"..F(filtername["inv"]).."]"..
"list[detached:trash;main;9,7;1,1;]"..
mcl_formspec.get_itemslot_bg(9,7,1,1)..
"image[9,7;1,1;crafting_creative_trash.png]"..
listrings
if name == "nix" then
if filter == nil then
filter = ""
end
formspec = formspec .. "field[5.3,1.34;4,0.75;search;;"..minetest.formspec_escape(filter).."]"
formspec = formspec .. "field_close_on_enter[search;false]"
end
if pagenum then formspec = formspec .. "p"..tostring(pagenum) end
player:set_inventory_formspec(formspec)
end
@ -545,7 +543,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
elseif fields.search == "" and not fields.creative_next and not fields.creative_prev then
set_inv_page("all", player)
page = "nix"
elseif fields.search ~= nil and not fields.creative_next and not fields.creative_prev then
elseif fields.search and not fields.creative_next and not fields.creative_prev then
set_inv_search(string.lower(fields.search),player)
page = "nix"
end
@ -578,7 +576,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if page == "nix" then
local inv = minetest.get_inventory({type="detached", name="creative_"..name})
inv_size = inv:get_size("main")
elseif page ~= nil and page ~= "inv" then
elseif page and page ~= "inv" then
inv_size = #(inventory_lists[page])
else
inv_size = 0
@ -593,7 +591,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
players[name].start_i = start_i
local filter = ""
if not fields.nix and fields.search ~= nil and fields.search ~= "" then
if not fields.nix and fields.search and fields.search ~= "" then
filter = fields.search
players[name].filter = filter
end
@ -644,7 +642,7 @@ if minetest.is_creative_enabled("") then
if page == "nix" then
local inv = minetest.get_inventory({type="detached", name="creative_"..name})
inv_size = inv:get_size("main")
elseif page ~= nil and page ~= "inv" then
elseif page and page ~= "inv" then
inv_size = #(inventory_lists[page])
else
inv_size = 0

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

View File

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

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

View File

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

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

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

View File

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

View File

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

View File

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

View File

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

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

View File

@ -1,3 +1,3 @@
name = mesecons_commandblock
depends = mesecons, mcl_colors
depends = mesecons, mcl_colors, mcl_util
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 DEFAULT_DELAY = DELAYS[1]
@ -264,8 +264,8 @@ for i = 1, 4 do
paramtype2 = "facedir",
sunlight_propagates = false,
is_ground_content = false,
drop = 'mesecons_delayer:delayer_off_1',
on_rightclick = function (pos, node, clicker)
drop = "mesecons_delayer:delayer_off_1",
on_rightclick = function(pos, node, clicker)
local protname = clicker:get_player_name()
if minetest.is_protected(pos, protname) then
minetest.record_protection_violation(pos, protname)
@ -330,8 +330,8 @@ for i = 1, 4 do
paramtype2 = "facedir",
sunlight_propagates = false,
is_ground_content = false,
drop = 'mesecons_delayer:delayer_off_1',
on_rightclick = function (pos, node, clicker)
drop = "mesecons_delayer:delayer_off_1",
on_rightclick = function(pos, node, clicker)
local protname = clicker:get_player_name()
if minetest.is_protected(pos, protname) then
minetest.record_protection_violation(pos, protname)
@ -410,7 +410,7 @@ minetest.register_node("mesecons_delayer:delayer_off_locked", {
paramtype2 = "facedir",
sunlight_propagates = false,
is_ground_content = false,
drop = 'mesecons_delayer:delayer_off_1',
drop = "mesecons_delayer:delayer_off_1",
delayer_time = DEFAULT_DELAY,
sounds = mcl_sounds.node_sound_stone_defaults(),
mesecons = {
@ -465,7 +465,7 @@ minetest.register_node("mesecons_delayer:delayer_on_locked", {
paramtype2 = "facedir",
sunlight_propagates = false,
is_ground_content = false,
drop = 'mesecons_delayer:delayer_off_1',
drop = "mesecons_delayer:delayer_off_1",
delayer_time = DEFAULT_DELAY,
sounds = mcl_sounds.node_sound_stone_defaults(),
mesecons = {

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