1
0
mirror of https://github.com/minetest-mods/3d_armor.git synced 2024-11-11 04:50:27 +01:00

Remove undeclared variable warnings on start-up

This commit is contained in:
stujones11 2015-01-04 19:57:55 +00:00
parent ad6c464573
commit b5db0f1aa6

View File

@ -7,6 +7,9 @@ ARMOR_DESTROY = false
ARMOR_LEVEL_MULTIPLIER = 1 ARMOR_LEVEL_MULTIPLIER = 1
ARMOR_HEAL_MULTIPLIER = 1 ARMOR_HEAL_MULTIPLIER = 1
local skin_mod = nil
local inv_mod = nil
local modpath = minetest.get_modpath(ARMOR_MOD_NAME) local modpath = minetest.get_modpath(ARMOR_MOD_NAME)
local worldpath = minetest.get_worldpath() local worldpath = minetest.get_worldpath()
local input = io.open(modpath.."/armor.conf", "r") local input = io.open(modpath.."/armor.conf", "r")
@ -30,21 +33,23 @@ armor = {
physics = {"jump","speed","gravity"}, physics = {"jump","speed","gravity"},
formspec = "size[8,8.5]list[detached:player_name_armor;armor;0,1;2,3;]" formspec = "size[8,8.5]list[detached:player_name_armor;armor;0,1;2,3;]"
.."image[2,0.75;2,4;armor_preview]" .."image[2,0.75;2,4;armor_preview]"
.."list[current_player;main;0,4.5;8,4;]" .."list[current_player;main;0,4.5;8,4;]"
.."list[current_player;craft;4,1;3,3;]" .."list[current_player;craft;4,1;3,3;]"
.."list[current_player;craftpreview;7,2;1,1;]", .."list[current_player;craftpreview;7,2;1,1;]",
textures = {}, textures = {},
default_skin = "character", default_skin = "character",
} }
if inventory_plus then if minetest.get_modpath("inventory_plus") then
inv_mod = "inventory_plus"
armor.formspec = "size[8,8.5]button[0,0;2,0.5;main;Back]" armor.formspec = "size[8,8.5]button[0,0;2,0.5;main;Back]"
.."list[detached:player_name_armor;armor;0,1;2,3;]" .."list[detached:player_name_armor;armor;0,1;2,3;]"
.."image[2.5,0.75;2,4;armor_preview]" .."image[2.5,0.75;2,4;armor_preview]"
.."label[5,1;Level: armor_level]" .."label[5,1;Level: armor_level]"
.."label[5,1.5;Heal: armor_heal]" .."label[5,1.5;Heal: armor_heal]"
.."list[current_player;main;0,4.5;8,4;]" .."list[current_player;main;0,4.5;8,4;]"
elseif unified_inventory then elseif minetest.get_modpath("unified_inventory") then
inv_mod = "unified_inventory"
unified_inventory.register_button("armor", { unified_inventory.register_button("armor", {
type = "image", type = "image",
image = "inventory_plus_armor.png", image = "inventory_plus_armor.png",
@ -232,9 +237,9 @@ end
armor.get_player_skin = function(self, name) armor.get_player_skin = function(self, name)
local skin = nil local skin = nil
if skins then if skin_mod == "skins" then
skin = skins.skins[name] skin = skins.skins[name]
elseif u_skins then elseif skin_mod == "u_skins" then
skin = u_skins.u_skins[name] skin = u_skins.u_skins[name]
end end
return skin or armor.default_skin return skin or armor.default_skin
@ -249,13 +254,13 @@ end
armor.update_inventory = function(self, player) armor.update_inventory = function(self, player)
local name = player:get_player_name() local name = player:get_player_name()
if unified_inventory then if inv_mod == "unified_inventory" then
if unified_inventory.current_page[name] == "armor" then if unified_inventory.current_page[name] == "armor" then
unified_inventory.set_inventory_formspec(player, "armor") unified_inventory.set_inventory_formspec(player, "armor")
end end
else else
local formspec = armor:get_armor_formspec(name) local formspec = armor:get_armor_formspec(name)
if inventory_plus then if inv_mod == "inventory_plus" then
local page = player:get_inventory_formspec() local page = player:get_inventory_formspec()
if page:find("detached:"..name.."_armor") then if page:find("detached:"..name.."_armor") then
inventory_plus.set_inventory_formspec(player, formspec) inventory_plus.set_inventory_formspec(player, formspec)
@ -289,7 +294,7 @@ default.player_register_model("3d_armor_character.x", {
minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = player:get_player_name() local name = player:get_player_name()
if inventory_plus and fields.armor then if inv_mod == "inventory_plus" and fields.armor then
local formspec = armor:get_armor_formspec(name) local formspec = armor:get_armor_formspec(name)
inventory_plus.set_inventory_formspec(player, formspec) inventory_plus.set_inventory_formspec(player, formspec)
return return
@ -338,7 +343,7 @@ minetest.register_on_joinplayer(function(player)
return count return count
end, end,
}) })
if inventory_plus then if inv_mod == "inventory_plus" then
inventory_plus.register_button(player,"armor", "Armor") inventory_plus.register_button(player,"armor", "Armor")
end end
armor_inv:set_size("armor", 6) armor_inv:set_size("armor", 6)
@ -372,16 +377,19 @@ minetest.register_on_joinplayer(function(player)
preview = armor.default_skin.."_preview.png", preview = armor.default_skin.."_preview.png",
} }
if minetest.get_modpath("skins") then if minetest.get_modpath("skins") then
skin_mod = "skins"
local skin = skins.skins[name] local skin = skins.skins[name]
if skin and skins.get_type(skin) == skins.type.MODEL then if skin and skins.get_type(skin) == skins.type.MODEL then
armor.textures[name].skin = skin..".png" armor.textures[name].skin = skin..".png"
end end
elseif minetest.get_modpath("simple_skins") then elseif minetest.get_modpath("simple_skins") then
skin_mod = "skins"
local skin = skins.skins[name] local skin = skins.skins[name]
if skin then if skin then
armor.textures[name].skin = skin..".png" armor.textures[name].skin = skin..".png"
end end
elseif minetest.get_modpath("u_skins") then elseif minetest.get_modpath("u_skins") then
skin_mod = "u_skins"
local skin = u_skins.u_skins[name] local skin = u_skins.u_skins[name]
if skin and u_skins.get_type(skin) == u_skins.type.MODEL then if skin and u_skins.get_type(skin) == u_skins.type.MODEL then
armor.textures[name].skin = skin..".png" armor.textures[name].skin = skin..".png"
@ -398,7 +406,7 @@ minetest.register_on_joinplayer(function(player)
for i=1, ARMOR_INIT_TIMES do for i=1, ARMOR_INIT_TIMES do
minetest.after(ARMOR_INIT_DELAY * i, function(player) minetest.after(ARMOR_INIT_DELAY * i, function(player)
armor:set_player_armor(player) armor:set_player_armor(player)
if inventory_plus == nil and unified_inventory == nil then if not inv_mod then
armor:update_inventory(player) armor:update_inventory(player)
end end
end, player) end, player)
@ -422,9 +430,9 @@ if ARMOR_DROP == true or ARMOR_DESTROY == true then
end end
end end
armor:set_player_armor(player) armor:set_player_armor(player)
if unified_inventory then if inv_mod == "unified_inventory" then
unified_inventory.set_inventory_formspec(player, "craft") unified_inventory.set_inventory_formspec(player, "craft")
elseif inventory_plus then elseif inv_mod == "inventory_plus" then
local formspec = inventory_plus.get_formspec(player,"main") local formspec = inventory_plus.get_formspec(player,"main")
inventory_plus.set_inventory_formspec(player, formspec) inventory_plus.set_inventory_formspec(player, formspec)
else else