`default.LIGHT_MAX` The maximum light level (see [Node definition] light_source)
+
+GUI and formspecs
+-----------------
+
+`default.get_hotbar_bg(x, y)`
+
+ * Get the hotbar background as string, containing the formspec elements
+ * x: Horizontal position in the formspec
+ * y: Vertical position in the formspec
+
+`default.gui_bg`
+
+ * Background color formspec element
+
+`default.gui_bg_img`
+
+ * Image overlay formspec element for the background to use in formspecs
+
+`default.gui_slots`
+
+ * `listcolors` formspec element that is used to format the slots in formspecs
+
+`default.gui_survival_form`
+
+ * Entire formspec for the survival inventory
+
+`default.get_chest_formspec(pos)`
+
+ * Get the chest formspec using the defined GUI elements
+ * pos: Location of the node
+
+`default.get_furnace_active_formspec(fuel_percent, item_percent)`
+
+ * Get the active furnace formspec using the defined GUI elements
+ * fuel_percent: Percent of how much the fuel is used
+ * item_percent: Percent of how much the item is cooked
+
+`default.get_furnace_inactive_formspec()`
+
+ * Get the inactive furnace formspec using the defined GUI elements
+
+
Player API
----------
-- Formspecs
--
-local function active_formspec(fuel_percent, item_percent)
- local formspec =
- "size[8,8.5]"..
+function default.get_furnace_active_formspec(fuel_percent, item_percent)
+ return "size[8,8.5]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"listring[context;fuel]"..
"listring[current_player;main]"..
default.get_hotbar_bg(0, 4.25)
- return formspec
end
-local inactive_formspec =
- "size[8,8.5]"..
- default.gui_bg..
- default.gui_bg_img..
- default.gui_slots..
- "list[context;src;2.75,0.5;1,1;]"..
- "list[context;fuel;2.75,2.5;1,1;]"..
- "image[2.75,1.5;1,1;default_furnace_fire_bg.png]"..
- "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
- "list[context;dst;4.75,0.96;2,2;]"..
- "list[current_player;main;0,4.25;8,1;]"..
- "list[current_player;main;0,5.5;8,3;8]"..
- "listring[context;dst]"..
- "listring[current_player;main]"..
- "listring[context;src]"..
- "listring[current_player;main]"..
- "listring[context;fuel]"..
- "listring[current_player;main]"..
- default.get_hotbar_bg(0, 4.25)
+function default.get_furnace_inactive_formspec()
+ return "size[8,8.5]"..
+ default.gui_bg..
+ default.gui_bg_img..
+ default.gui_slots..
+ "list[context;src;2.75,0.5;1,1;]"..
+ "list[context;fuel;2.75,2.5;1,1;]"..
+ "image[2.75,1.5;1,1;default_furnace_fire_bg.png]"..
+ "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
+ "list[context;dst;4.75,0.96;2,2;]"..
+ "list[current_player;main;0,4.25;8,1;]"..
+ "list[current_player;main;0,5.5;8,3;8]"..
+ "listring[context;dst]"..
+ "listring[current_player;main]"..
+ "listring[context;src]"..
+ "listring[current_player;main]"..
+ "listring[context;fuel]"..
+ "listring[current_player;main]"..
+ default.get_hotbar_bg(0, 4.25)
+end
--
-- Node callback functions that are the same for active and inactive furnace
--
-- Update formspec, infotext and node
--
- local formspec = inactive_formspec
+ local formspec
local item_state
local item_percent = 0
if cookable then
active = "active "
local fuel_percent = math.floor(fuel_time / fuel_totaltime * 100)
fuel_state = fuel_percent .. "%"
- formspec = active_formspec(fuel_percent, item_percent)
+ formspec = default.get_furnace_active_formspec(fuel_percent, item_percent)
swap_node(pos, "default:furnace_active")
-- make sure timer restarts automatically
result = true
if not fuellist[1]:is_empty() then
fuel_state = "0%"
end
+ formspec = default.get_furnace_inactive_formspec()
swap_node(pos, "default:furnace")
-- stop timer on the inactive furnace
minetest.get_node_timer(pos):stop()
end
- local infotext = "Furnace " .. active .. "(Item: " .. item_state .. "; Fuel: " .. fuel_state .. ")"
+ local infotext = "Furnace " .. active .. "(Item: " .. item_state ..
+ "; Fuel: " .. fuel_state .. ")"
--
-- Set meta values
on_construct = function(pos)
local meta = minetest.get_meta(pos)
- meta:set_string("formspec", inactive_formspec)
+ meta:set_string("formspec", default.get_furnace_inactive_formspec())
local inv = meta:get_inventory()
inv:set_size('src', 1)
inv:set_size('fuel', 1)
allow_metadata_inventory_move = allow_metadata_inventory_move,
allow_metadata_inventory_take = allow_metadata_inventory_take,
})
-
-- Tools / "Advanced" crafting / Non-"natural"
--
-local function get_chest_formspec(pos)
+function default.get_chest_formspec(pos)
local spos = pos.x .. "," .. pos.y .. "," .. pos.z
local formspec =
"size[8,9]" ..
end
minetest.after(0.2, minetest.show_formspec,
clicker:get_player_name(),
- "default:chest", get_chest_formspec(pos))
+ "default:chest", default.get_chest_formspec(pos))
open_chests[clicker:get_player_name()] = { pos = pos,
sound = def.sound_close, swap = name }
end
minetest.show_formspec(
player:get_player_name(),
"default:chest_locked",
- get_chest_formspec(pos)
+ default.get_chest_formspec(pos)
)
end
def.on_skeleton_key_use = function(pos, player, newsecret)
end
minetest.after(0.2, minetest.show_formspec,
clicker:get_player_name(),
- "default:chest", get_chest_formspec(pos))
+ "default:chest", default.get_chest_formspec(pos))
open_chests[clicker:get_player_name()] = { pos = pos,
sound = def.sound_close, swap = name }
end