1
0
Fork 0

Localize various unneeded global variables

This commit is contained in:
Wuzzy 2018-01-26 22:20:15 +01:00
parent a40dec6da9
commit 16bb9b8901
10 changed files with 30 additions and 28 deletions

View File

@ -62,7 +62,7 @@ local function check_commands(commands, player_name)
local cmddef = minetest.chatcommands[cmd]
if not cmddef then
-- Invalid chat command
msg = "Error: The command “"..cmd.."” does not exist; your command block has not been changed. Use the “help” chat command for a list of available commands."
local msg = "Error: The command “"..cmd.."” does not exist; your command block has not been changed. Use the “help” chat command for a list of available commands."
if string.sub(cmd, 1, 1) == "/" then
msg = msg .. " Hint: Try to remove the trailing slash."
end

View File

@ -241,7 +241,7 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
if first_dropper and id >= first_dropper then
break
end
np = vector.add(n.pos, movedir)
local np = vector.add(n.pos, movedir)
minetest.add_node(np, n.node)
minetest.get_meta(np):from_table(n.meta)
end

View File

@ -1,7 +1,7 @@
local PISTON_MAXIMUM_PUSH = 12
-- Get mesecon rules of pistons
piston_rules =
local piston_rules =
{{x=0, y=0, z=1}, --everything apart from z- (pusher side)
{x=1, y=0, z=0},
{x=-1, y=0, z=0},
@ -30,7 +30,7 @@ local piston_get_rules = function (node)
return rules
end
piston_facedir_direction = function (node)
local piston_facedir_direction = function (node)
local rules = {{x = 0, y = 0, z = -1}}
for i = 1, node.param2 do
rules = mesecon.rotate_rules_left(rules)
@ -38,7 +38,7 @@ piston_facedir_direction = function (node)
return rules[1]
end
piston_get_direction = function (dir, node)
local piston_get_direction = function (dir, node)
if type(dir) == "function" then
return dir(node)
else
@ -830,7 +830,7 @@ local piston_up_down_get_stopper = function (node, dir, stack, stackid)
end
local piston_get_stopper = function (node, dir, stack, stackid)
pistonspec = minetest.registered_nodes[node.name].mesecons_piston
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
dir = piston_get_direction(pistonspec.dir, node)
local pusherpos = vector.add(stack[stackid].pos, dir)
local pushernode = minetest.get_node(pusherpos)

View File

@ -339,7 +339,7 @@ local banner_pattern_craft = function(itemstack, player, old_craft_grid, craft_i
-- For copying to be allowed, one banner has to have no layers while the other one has at least 1 layer.
-- The banner with layers will be used as a source.
local src_banner, src_layers, src_desc, src_index
local src_banner, src_layers_raw, src_desc, src_index
if #b1layers == 0 and #b2layers > 0 then
src_banner = banner2
src_layers_raw = b2layers_raw

View File

@ -270,7 +270,7 @@ end
function mcl_core.generate_v6_oak_tree(pos)
local trunk = "mcl_core:tree"
local leaves = "mcl_core:leaves"
node = {name = ""}
local node = {name = ""}
for dy=1,4 do
pos.y = pos.y+dy
if minetest.get_node(pos).name ~= "air" then

View File

@ -345,7 +345,7 @@ if not fire_enabled then
chance = 2,
catch_up = false,
action = function(pos)
function try_ignite(airs)
local function try_ignite(airs)
while #airs > 0 do
local r = math.random(1, #airs)
if minetest.find_node_near(airs[r], 1, {"group:flammable", "group:flammable_lava"}) then

View File

@ -140,6 +140,7 @@ local function check_end_portal_frame(pos)
end
end
-- All checks survived! We have a valid portal!
local k
if dir.x > 0 then
k = 1
else
@ -158,6 +159,7 @@ local function check_end_portal_frame(pos)
return false
end
end
local k
if dir.z > 0 then
k = 1
else

View File

@ -16,7 +16,7 @@
-- TODO: Add legacy support for Minetest Game groups like crumbly, snappy, cracky, etc. for all tools
-- The hand
local groupcaps, range
local groupcaps, hand_range
if minetest.settings:get_bool("creative_mode") then
-- Instant breaking in creative mode
groupcaps = {

View File

@ -1558,7 +1558,7 @@ local generate_underground_mushrooms = function(minp, maxp, seed)
end
local pr_nether = PseudoRandom(os.time()+667)
local nehter_wart_chance
local nether_wart_chance
if mg_name == "v6" then
nether_wart_chance = 85
else

View File

@ -39,6 +39,23 @@ minetest.register_on_leaveplayer(function(player)
local playerName = player:get_player_name()
players[playerName] = nil
end)
local function setSprinting(playerName, sprinting) --Sets the state of a player (0=stopped/moving, 1=sprinting)
local player = minetest.get_player_by_name(playerName)
if players[playerName] then
players[playerName]["sprinting"] = sprinting
-- Don't overwrite physics when standing on soul sand or sleeping
if mcl_playerinfo[playerName].node_stand ~= "mcl_nether:soul_sand" and player:get_attribute("mcl_beds:sleeping") ~= "true" then
if sprinting == true then
player:set_physics_override({speed=mcl_sprint.SPEED})
elseif sprinting == false then
player:set_physics_override({speed=1.0})
end
return true
end
end
return false
end
minetest.register_globalstep(function(dtime)
--Get the gametime
local gameTime = minetest.get_gametime()
@ -106,20 +123,3 @@ minetest.register_globalstep(function(dtime)
end
end
end)
function setSprinting(playerName, sprinting) --Sets the state of a player (0=stopped/moving, 1=sprinting)
local player = minetest.get_player_by_name(playerName)
if players[playerName] then
players[playerName]["sprinting"] = sprinting
-- Don't overwrite physics when standing on soul sand or sleeping
if mcl_playerinfo[playerName].node_stand ~= "mcl_nether:soul_sand" and player:get_attribute("mcl_beds:sleeping") ~= "true" then
if sprinting == true then
player:set_physics_override({speed=mcl_sprint.SPEED})
elseif sprinting == false then
player:set_physics_override({speed=1.0})
end
return true
end
end
return false
end