Localize most variables

This commit is contained in:
ShadowNinja
2013-12-17 13:56:37 -05:00
parent 0ea1bd1fa2
commit 5cf765b2f1
12 changed files with 296 additions and 308 deletions

View File

@ -17,6 +17,7 @@ dofile(path.."/generator.lua")
-- The power radiator supplies appliances with inductive coupled power:
-- Lighting and associated textures is taken directly from VanessaE's homedecor and made electric.
dofile(path.."/power_radiator.lua")
dofile(path.."/lighting.lua")
-- This is currently useless, slow, and mostly copied
--dofile(path.."/power_radiator.lua")
--dofile(path.."/lighting.lua")

View File

@ -21,7 +21,7 @@ minetest.register_craft({
})
mk1_on = function(pos, node)
local function mk1_on(pos, node)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local pos1={}
@ -41,7 +41,7 @@ mk1_on = function(pos, node)
end
end
mk1_off = function(pos, node)
local function mk1_off(pos, node)
if node.name == "technic:constructor_mk1_on" then
technic.swap_node(pos,"technic:constructor_mk1_off")
nodeupdate(pos)
@ -97,7 +97,7 @@ minetest.register_node("technic:constructor_mk1_on", {
--Constructor Mk2
mk2_on = function(pos, node)
local function mk2_on(pos, node)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local pos1={}
@ -123,7 +123,7 @@ mk2_on = function(pos, node)
end
end
mk2_off = function(pos, node)
local function mk2_off(pos, node)
if node.name == "technic:constructor_mk2_on" then
technic.swap_node(pos,"technic:constructor_mk2_off")
nodeupdate(pos)
@ -181,7 +181,7 @@ minetest.register_node("technic:constructor_mk2_on", {
-- Constructor Mk3
mk3_on = function(pos, node)
local function mk3_on(pos, node)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
@ -225,7 +225,7 @@ mk3_on = function(pos, node)
end
end
mk3_off = function(pos, node)
local function mk3_off(pos, node)
if node.name == "technic:constructor_mk3_on" then
technic.swap_node(pos,"technic:constructor_mk3_off")
nodeupdate(pos)
@ -289,7 +289,7 @@ minetest.register_node("technic:constructor_mk3_on", {
})
deploy_node =function (inv, slot_name, pos1, node1, node)
local function deploy_node(inv, slot_name, pos1, node1, node)
if node1.name == "air" then
if not inv:is_empty(slot_name) then
stack1=inv:get_list(slot_name)

View File

@ -43,7 +43,7 @@ local function get_face(pos,ppos,pvect)
end
end
function lines(str)
local function lines(str)
local t = {}
local function helper(line) table.insert(t, line) return "" end
helper((str:gsub("(.-)\r?\n", helper)))

View File

@ -74,7 +74,7 @@ minetest.register_abm({
end,
})
function inject_items (pos)
local function inject_items (pos)
local meta=minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local mode=meta:get_string("mode")

View File

@ -6,11 +6,11 @@ technic.alloy_recipes = {}
-- Register recipe in a table
technic.register_alloy_recipe = function(metal1, count1, metal2, count2, result, count3)
in1 = {
local in1 = {
name = metal1,
count = count1,
}
in2 = {
local in2 = {
name = metal2,
count = count2,
}

View File

@ -161,14 +161,14 @@ function technic.charge_tools(meta, batt_charge, charge_step)
return batt_charge
end
local srcstack = inv:get_stack("src", 1)
local src_meta = get_item_meta(srcstack:get_metadata())
local src_meta = minetest.deserialize(srcstack:get_metadata())
local toolname = srcstack:get_name()
if not technic.power_tools[toolname] then
return batt_charge
end
-- Set meta data for the tool if it didn't do it itself
src_meta = get_item_meta(srcstack:get_metadata())
src_meta = minetest.deserialize(srcstack:get_metadata())
src_meta = src_meta or {}
if not src_meta.charge then
src_meta.charge = 0
@ -185,7 +185,7 @@ function technic.charge_tools(meta, batt_charge, charge_step)
batt_charge = batt_charge - charge_step
technic.set_RE_wear(srcstack, tool_charge, item_max_charge)
src_meta.charge = tool_charge
srcstack:set_metadata(set_item_meta(src_meta))
srcstack:set_metadata(minetest.serialize(src_meta))
inv:set_stack("src", 1, srcstack)
return batt_charge
end
@ -202,7 +202,7 @@ function technic.discharge_tools(meta, batt_charge, charge_step, max_charge)
return batt_charge
end
-- Set meta data for the tool if it didn't do it itself :-(
local src_meta = get_item_meta(srcstack:get_metadata())
local src_meta = minetest.deserialize(srcstack:get_metadata())
src_meta = src_meta or {}
if not src_meta.charge then
src_meta.charge = 0
@ -220,7 +220,7 @@ function technic.discharge_tools(meta, batt_charge, charge_step, max_charge)
batt_charge = batt_charge + charge_step
technic.set_RE_wear(srcstack, tool_charge, item_max_charge)
src_meta.charge = tool_charge
srcstack:set_metadata(set_item_meta(src_meta))
srcstack:set_metadata(minetest.serialize(src_meta))
inv:set_stack("dst", 1, srcstack)
return batt_charge
end