forked from minetest/minetest_game
Separate formspecs of active furnace and chests
Makes its possible to override formspecs by mods
This commit is contained in:
parent
c3c5f8a228
commit
486509876a
|
@ -598,6 +598,21 @@ minetest.register_node("default:sign_wall", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
default.chest_formspec =
|
||||||
|
"size[8,9]"..
|
||||||
|
"list[current_name;main;0,0;8,4;]"..
|
||||||
|
"list[current_player;main;0,5;8,4;]"
|
||||||
|
|
||||||
|
function default.get_locked_chest_formspec(pos)
|
||||||
|
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
||||||
|
local formspec =
|
||||||
|
"size[8,9]"..
|
||||||
|
"list[nodemeta:".. spos .. ";main;0,0;8,4;]"..
|
||||||
|
"list[current_player;main;0,5;8,4;]"
|
||||||
|
return formspec
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("default:chest", {
|
minetest.register_node("default:chest", {
|
||||||
description = "Chest",
|
description = "Chest",
|
||||||
tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
|
tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
|
||||||
|
@ -608,10 +623,7 @@ minetest.register_node("default:chest", {
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec",default.chest_formspec)
|
||||||
"size[8,9]"..
|
|
||||||
"list[current_name;main;0,0;8,4;]"..
|
|
||||||
"list[current_player;main;0,5;8,4;]")
|
|
||||||
meta:set_string("infotext", "Chest")
|
meta:set_string("infotext", "Chest")
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("main", 8*4)
|
inv:set_size("main", 8*4)
|
||||||
|
@ -716,15 +728,27 @@ minetest.register_node("default:chest_locked", {
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if has_locked_chest_privilege(meta, clicker) then
|
if has_locked_chest_privilege(meta, clicker) then
|
||||||
local pos = pos.x .. "," .. pos.y .. "," ..pos.z
|
minetest.show_formspec(
|
||||||
minetest.show_formspec(clicker:get_player_name(), "default:chest_locked",
|
clicker:get_player_name(),
|
||||||
"size[8,9]"..
|
"default:chest_locked",
|
||||||
"list[nodemeta:".. pos .. ";main;0,0;8,4;]"..
|
default.get_locked_chest_formspec(pos)
|
||||||
"list[current_player;main;0,5;8,4;]")
|
)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function default.get_furnace_active_formspec(pos, percent)
|
||||||
|
local formspec =
|
||||||
|
"size[8,9]"..
|
||||||
|
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
||||||
|
(100-percent)..":default_furnace_fire_fg.png]"..
|
||||||
|
"list[current_name;fuel;2,3;1,1;]"..
|
||||||
|
"list[current_name;src;2,1;1,1;]"..
|
||||||
|
"list[current_name;dst;5,1;2,2;]"..
|
||||||
|
"list[current_player;main;0,5;8,4;]"
|
||||||
|
return formspec
|
||||||
|
end
|
||||||
|
|
||||||
default.furnace_inactive_formspec =
|
default.furnace_inactive_formspec =
|
||||||
"size[8,9]"..
|
"size[8,9]"..
|
||||||
"image[2,2;1,1;default_furnace_fire_bg.png]"..
|
"image[2,2;1,1;default_furnace_fire_bg.png]"..
|
||||||
|
@ -937,14 +961,7 @@ minetest.register_abm({
|
||||||
meta:get_float("fuel_totaltime") * 100)
|
meta:get_float("fuel_totaltime") * 100)
|
||||||
meta:set_string("infotext","Furnace active: "..percent.."%")
|
meta:set_string("infotext","Furnace active: "..percent.."%")
|
||||||
hacky_swap_node(pos,"default:furnace_active")
|
hacky_swap_node(pos,"default:furnace_active")
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec",default.get_furnace_active_formspec(pos, percent))
|
||||||
"size[8,9]"..
|
|
||||||
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
|
||||||
(100-percent)..":default_furnace_fire_fg.png]"..
|
|
||||||
"list[current_name;fuel;2,3;1,1;]"..
|
|
||||||
"list[current_name;src;2,1;1,1;]"..
|
|
||||||
"list[current_name;dst;5,1;2,2;]"..
|
|
||||||
"list[current_player;main;0,5;8,4;]")
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user