Make 3d_armor optional on player page. Initial skins-only support
This commit is contained in:
parent
8759ef888e
commit
cfc627c49c
@ -2,3 +2,4 @@ default
|
||||
creative?
|
||||
sfinv?
|
||||
3d_armor?
|
||||
skins?
|
||||
|
6
init.lua
6
init.lua
@ -1,6 +1,8 @@
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
smart_inventory = {}
|
||||
smart_inventory.skins_mod = minetest.get_modpath("skins")
|
||||
smart_inventory.armor_mod = minetest.get_modpath("3d_armor")
|
||||
smart_inventory.registered_pages = {}
|
||||
smart_inventory.smartfs = dofile(modpath.."/smartfs.lua")
|
||||
smart_inventory.smartfs_elements = dofile(modpath.."/smartfs-elements.lua")
|
||||
@ -107,7 +109,7 @@ smart_inventory.cache = dofile(modpath.."/cache.lua")
|
||||
-- register pages
|
||||
dofile(modpath.."/crafting.lua")
|
||||
|
||||
if minetest.get_modpath("3d_armor") then
|
||||
dofile(modpath.."/armor.lua")
|
||||
if smart_inventory.skins_mod or smart_inventory.armor_mod then
|
||||
dofile(modpath.."/player.lua")
|
||||
end
|
||||
|
||||
|
@ -66,17 +66,25 @@ end
|
||||
|
||||
local function update_page(state)
|
||||
local name = state.location.rootState.location.player
|
||||
update_grid(state, "main")
|
||||
update_grid(state, "armor")
|
||||
state:get("preview"):setImage(armor.textures[name].preview)
|
||||
state.location.parentState:get("player_button"):setImage(armor.textures[name].preview)
|
||||
|
||||
state:get("level"):setText("Level: "..armor.def[name].level)
|
||||
state:get("heal"):setText("Heal: "..armor.def[name].heal)
|
||||
state:get("fire"):setText("Fire: "..armor.def[name].fire)
|
||||
state:get("radiation"):setText("Radiation: "..armor.def[name].radiation)
|
||||
if smart_inventory.armor_mod then
|
||||
update_grid(state, "main")
|
||||
update_grid(state, "armor")
|
||||
state:get("preview"):setImage(armor.textures[name].preview)
|
||||
state.location.parentState:get("player_button"):setImage(armor.textures[name].preview)
|
||||
state:get("level"):setText("Level: "..armor.def[name].level)
|
||||
state:get("heal"):setText("Heal: "..armor.def[name].heal)
|
||||
state:get("fire"):setText("Fire: "..armor.def[name].fire)
|
||||
state:get("radiation"):setText("Radiation: "..armor.def[name].radiation)
|
||||
update_selected_item(state)
|
||||
elseif smart_inventory.skins_mod then
|
||||
state.location.parentState:get("player_button"):setImage(skins.skins[name].."_preview.png")
|
||||
state:get("preview"):setImage(skins.skins[name].."_preview.png")
|
||||
end
|
||||
|
||||
update_selected_item(state)
|
||||
if smart_inventory.skins_mod then
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
local function move_item_to_armor(state, item)
|
||||
@ -97,8 +105,6 @@ local function move_item_to_inv(state, item)
|
||||
armor:set_player_armor(minetest.get_player_by_name(name))
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function player_callback(state)
|
||||
local name = state.location.rootState.location.player
|
||||
state:image(3.5,1.5,2,4,"preview","")
|
||||
@ -115,25 +121,26 @@ local function player_callback(state)
|
||||
state:item_image(0,3.5,2,2,"item_image","")
|
||||
state:background(0, 1.3, 3, 4.6, "it_bg", "minimap_overlay_square.png")
|
||||
|
||||
if smart_inventory.armor_mod then
|
||||
local grid_armor = smart_inventory.smartfs_elements.buttons_grid(state, 0, 0, 8, 1, "armor_grid")
|
||||
grid_armor:setBackground("halo.png")
|
||||
grid_armor:onClick(function(self, state, index, player)
|
||||
update_selected_item(state, state.param.armor_armor_list[index])
|
||||
move_item_to_inv(state, state.param.armor_armor_list[index])
|
||||
update_page(state)
|
||||
end)
|
||||
|
||||
local grid_armor = smart_inventory.smartfs_elements.buttons_grid(state, 0, 0, 8, 1, "armor_grid")
|
||||
grid_armor:setBackground("halo.png")
|
||||
grid_armor:onClick(function(self, state, index, player)
|
||||
update_selected_item(state, state.param.armor_armor_list[index])
|
||||
move_item_to_inv(state, state.param.armor_armor_list[index])
|
||||
update_page(state)
|
||||
end)
|
||||
local grid_main = smart_inventory.smartfs_elements.buttons_grid(state, 0, 6, 8, 2, "main_grid")
|
||||
grid_main:setBackground("halo.png")
|
||||
grid_main:onClick(function(self, state, index, player)
|
||||
update_selected_item(state, state.param.armor_main_list[index])
|
||||
move_item_to_armor(state, state.param.armor_main_list[index])
|
||||
update_page(state)
|
||||
end)
|
||||
armor:set_player_armor(minetest.get_player_by_name(name))
|
||||
end
|
||||
|
||||
local grid_main = smart_inventory.smartfs_elements.buttons_grid(state, 0, 6, 8, 2, "main_grid")
|
||||
grid_main:setBackground("halo.png")
|
||||
grid_main:onClick(function(self, state, index, player)
|
||||
update_selected_item(state, state.param.armor_main_list[index])
|
||||
move_item_to_armor(state, state.param.armor_main_list[index])
|
||||
update_page(state)
|
||||
end)
|
||||
|
||||
-- set values
|
||||
armor:set_player_armor(minetest.get_player_by_name(name))
|
||||
update_page(state)
|
||||
end
|
||||
|
||||
@ -146,19 +153,21 @@ smart_inventory.register_page({
|
||||
})
|
||||
|
||||
|
||||
-- Armor filter
|
||||
smart_inventory.filter.register_filter({
|
||||
name = "armor",
|
||||
shortdesc = "Armor",
|
||||
filter_func = function(def, name)
|
||||
if not def or not name then
|
||||
if smart_inventory.armor_mod then
|
||||
-- Armor filter
|
||||
smart_inventory.filter.register_filter({
|
||||
name = "armor",
|
||||
shortdesc = "Armor",
|
||||
filter_func = function(def, name)
|
||||
if not def or not name then
|
||||
return false
|
||||
end
|
||||
for _, v in pairs(armor.elements) do
|
||||
if def.groups["armor_"..v] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
for _, v in pairs(armor.elements) do
|
||||
if def.groups["armor_"..v] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
})
|
||||
})
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user