mirror of
https://github.com/minetest-mods/3d_armor.git
synced 2024-11-22 20:43:43 +01:00
Minor formspec improvements
This commit is contained in:
parent
6661ec0b40
commit
616d9398f2
@ -77,6 +77,13 @@ armor = {
|
|||||||
version = "0.4.7",
|
version = "0.4.7",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local armor_formpage = "image[2.5,0;2,4;armor_preview]"..
|
||||||
|
"label[5,1;Level: armor_level]"..
|
||||||
|
"label[5,1.5;Heal: armor_heal]"..
|
||||||
|
"label[5,2;Fire: armor_fire]"..
|
||||||
|
"label[5,2.5;Radiation: armor_radiation]"..
|
||||||
|
"list[current_player;main;0,4.25;8,1;]"..
|
||||||
|
"list[current_player;main;0,5.5;8,3;8]"
|
||||||
if minetest.get_modpath("inventory_plus") then
|
if minetest.get_modpath("inventory_plus") then
|
||||||
inv_mod = "inventory_plus"
|
inv_mod = "inventory_plus"
|
||||||
armor.formspec = "size[8,8.5]button[6,0;2,0.5;main;Back]"..
|
armor.formspec = "size[8,8.5]button[6,0;2,0.5;main;Back]"..
|
||||||
@ -84,13 +91,7 @@ if minetest.get_modpath("inventory_plus") then
|
|||||||
default.gui_bg_img..
|
default.gui_bg_img..
|
||||||
default.gui_slots..
|
default.gui_slots..
|
||||||
default.get_hotbar_bg(0,4.25)..
|
default.get_hotbar_bg(0,4.25)..
|
||||||
"image[2.5,0;2,4;armor_preview]"..
|
armor_formpage
|
||||||
"label[5,1;Level: armor_level]"..
|
|
||||||
"label[5,1.5;Heal: armor_heal]"..
|
|
||||||
"label[5,2;Fire: armor_fire]"..
|
|
||||||
"label[5,2.5;Radiation: armor_radiation]"..
|
|
||||||
"list[current_player;main;0,4.25;8,1;]"..
|
|
||||||
"list[current_player;main;0,5.5;8,3;8]"
|
|
||||||
if minetest.get_modpath("crafting") then
|
if minetest.get_modpath("crafting") then
|
||||||
inventory_plus.get_formspec = function(player, page)
|
inventory_plus.get_formspec = function(player, page)
|
||||||
end
|
end
|
||||||
@ -105,16 +106,16 @@ elseif minetest.get_modpath("unified_inventory") and not unified_inventory.sfinv
|
|||||||
get_formspec = function(player, perplayer_formspec)
|
get_formspec = function(player, perplayer_formspec)
|
||||||
local fy = perplayer_formspec.formspec_y
|
local fy = perplayer_formspec.formspec_y
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local formspec = "background[0.06,"..fy..";7.92,7.52;3d_armor_ui_form.png]"
|
local formspec = "background[0.06,"..fy..";7.92,7.52;3d_armor_ui_form.png]"..
|
||||||
.."label[0,0;Armor]"
|
"label[0,0;Armor]"..
|
||||||
.."list[detached:"..name.."_armor;armor;0,"..fy..";2,3;]"
|
"list[detached:"..name.."_armor;armor;0,"..fy..";2,3;]"..
|
||||||
.."image[2.5,"..(fy - 0.25)..";2,4;"..armor.textures[name].preview.."]"
|
"image[2.5,"..(fy - 0.25)..";2,4;"..armor.textures[name].preview.."]"..
|
||||||
.."label[5.0,"..(fy + 0.0)..";Level: "..armor.def[name].level.."]"
|
"label[5.0,"..(fy + 0.0)..";Level: "..armor.def[name].level.."]"..
|
||||||
.."label[5.0,"..(fy + 0.5)..";Heal: "..armor.def[name].heal.."]"
|
"label[5.0,"..(fy + 0.5)..";Heal: "..armor.def[name].heal.."]"..
|
||||||
.."label[5.0,"..(fy + 1.0)..";Fire: "..armor.def[name].fire.."]"
|
"label[5.0,"..(fy + 1.0)..";Fire: "..armor.def[name].fire.."]"..
|
||||||
.."label[5.0,"..(fy + 1.5)..";Radiation: "..armor.def[name].radiation.."]"
|
"label[5.0,"..(fy + 1.5)..";Radiation: "..armor.def[name].radiation.."]"..
|
||||||
.."listring[current_player;main]"
|
"listring[current_player;main]"..
|
||||||
.."listring[detached:"..name.."_armor;armor]"
|
"listring[detached:"..name.."_armor;armor]"
|
||||||
return {formspec=formspec}
|
return {formspec=formspec}
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@ -124,13 +125,13 @@ elseif minetest.get_modpath("smart_inventory") then
|
|||||||
inv_mod = "smart_inventory"
|
inv_mod = "smart_inventory"
|
||||||
elseif minetest.get_modpath("sfinv") then
|
elseif minetest.get_modpath("sfinv") then
|
||||||
inv_mod = "sfinv"
|
inv_mod = "sfinv"
|
||||||
armor.formspec = "image[2,0.5;2,4;armor_preview]"
|
armor.formspec = armor_formpage
|
||||||
|
|
||||||
sfinv.register_page("3d_armor:armor", {
|
sfinv.register_page("3d_armor:armor", {
|
||||||
title = "Armor",
|
title = "Armor",
|
||||||
get = function(self, player, context)
|
get = function(self, player, context)
|
||||||
return sfinv.make_formspec(player, context,
|
local name = player:get_player_name()
|
||||||
armor:get_armor_formspec(player:get_player_name()), true)
|
local formspec = armor:get_armor_formspec(name, true)
|
||||||
|
return sfinv.make_formspec(player, context, formspec, false)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -297,7 +298,7 @@ armor.get_preview = function(self, name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
armor.get_armor_formspec = function(self, name)
|
armor.get_armor_formspec = function(self, name, listring)
|
||||||
if not armor.textures[name] then
|
if not armor.textures[name] then
|
||||||
minetest.log("error", "3d_armor: Player texture["..name.."] is nil [get_armor_formspec]")
|
minetest.log("error", "3d_armor: Player texture["..name.."] is nil [get_armor_formspec]")
|
||||||
return ""
|
return ""
|
||||||
@ -307,11 +308,16 @@ armor.get_armor_formspec = function(self, name)
|
|||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
local formspec = armor.formspec.."list[detached:"..name.."_armor;armor;0,0.5;2,3;]"
|
local formspec = armor.formspec.."list[detached:"..name.."_armor;armor;0,0.5;2,3;]"
|
||||||
|
if listring == true then
|
||||||
|
formspec = formspec.."listring[current_player;main]"..
|
||||||
|
"listring[detached:"..name.."_armor;armor]"
|
||||||
|
end
|
||||||
formspec = formspec:gsub("armor_preview", armor.textures[name].preview)
|
formspec = formspec:gsub("armor_preview", armor.textures[name].preview)
|
||||||
formspec = formspec:gsub("armor_level", armor.def[name].level)
|
formspec = formspec:gsub("armor_level", armor.def[name].level)
|
||||||
formspec = formspec:gsub("armor_heal", armor.def[name].heal)
|
formspec = formspec:gsub("armor_heal", armor.def[name].heal)
|
||||||
formspec = formspec:gsub("armor_fire", armor.def[name].fire)
|
formspec = formspec:gsub("armor_fire", armor.def[name].fire)
|
||||||
formspec = formspec:gsub("armor_radiation", armor.def[name].radiation)
|
formspec = formspec:gsub("armor_radiation", armor.def[name].radiation)
|
||||||
|
formspec = formspec:gsub("player_name", armor.def[name].radiation)
|
||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -339,15 +345,14 @@ armor.update_inventory = function(self, player)
|
|||||||
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)
|
|
||||||
if inv_mod == "inventory_plus" then
|
if inv_mod == "inventory_plus" then
|
||||||
formspec = formspec.."listring[current_player;main]"
|
local formspec = armor:get_armor_formspec(name, true)
|
||||||
.."listring[detached:"..name.."_armor;armor]"
|
|
||||||
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)
|
||||||
end
|
end
|
||||||
elseif not core.setting_getbool("creative_mode") then
|
elseif not core.setting_getbool("creative_mode") then
|
||||||
|
local formspec = armor:get_armor_formspec(name)
|
||||||
player:set_inventory_formspec(formspec)
|
player:set_inventory_formspec(formspec)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -414,7 +419,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if inv_mod == "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, true)
|
||||||
inventory_plus.set_inventory_formspec(player, formspec)
|
inventory_plus.set_inventory_formspec(player, formspec)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user