[UPDATE] Complete formspec

This commit is contained in:
tacigar 2016-09-16 10:13:39 +09:00
parent 5767f4c262
commit 414943137b
7 changed files with 36 additions and 4 deletions

View File

@ -8,7 +8,7 @@ local dye_core_map = {
}
-- register a definition of a core writer.
(function()
;(function()
local node_box = {
type = "fixed",
fixed = {
@ -43,6 +43,36 @@ local dye_core_map = {
.. "list[current_player;main;0,5;8,1;]"
.. "list[current_player;main;0,6.2;8,3;8]"
local function generate_formspec_active(writing_time)
local arrow_percent = (100 / 40) * writing_time
local merter_percent = 0
if writing_time % 16 >= 8 then
meter_percent = (8 - (writing_time % 8)) * (100 / 8)
else
meter_percent = (writing_time % 8) * (100 / 8)
end
return "size[8,9]"
.. default.gui_bg
.. default.gui_bg_img
.. default.gui_slots
.. "label[3.75,0;Core]"
.. "list[current_name;core;3.5,0.5;1,1;]"
.. "label[2.75,2;Coal]"
.. "list[current_name;fuel;2.5,2.5;1,1;]"
.. "label[4.75,2;Dye]"
.. "list[current_name;dye;4.5,2.5;1,1;]"
.. "image[3.5,1.5;1,2;maidroid_tool_gui_arrow.png^[lowpart:"
.. arrow_percent
.. ":maidroid_tool_gui_arrow_filled.png]"
.. "image[3.1,3.5;2,1;maidroid_tool_gui_meter.png^[lowpart:"
.. meter_percent
.. ":maidroid_tool_gui_meter_filled.png^[transformR270]"
.. "list[current_player;main;0,5;8,1;]"
.. "list[current_player;main;0,6.2;8,3;8]"
end
-- get_nearest_core_entity returns the nearest core entity.
local function get_nearest_core_entity(pos)
local all_objects = minetest.get_objects_inside_radius(pos, 1.0)
@ -75,17 +105,19 @@ local dye_core_map = {
local dye_list = inventory:get_list("dye")
local writing_time = meta:get_float("writing_time")
local writing_total_time = 20
local writing_total_time = 40
local output_core = meta:get_string("output_core")
-- if writing time is positive, the core writer is active.
if writing_time >= 0 then
if writing_time <= writing_total_time then
meta:set_float("writing_time", writing_time + 1)
meta:set_string("formspec", generate_formspec_active(writing_time))
else -- else place output core to core list.
meta:set_float("writing_time", -1)
meta:set_string("output_core", "")
meta:set_string("formspec", formspec_inactive)
inventory:set_stack("core", 1, ItemStack(output_core))
minetest.swap_node(pos, {name = "maidroid_tool:core_writer"})
@ -168,14 +200,14 @@ local dye_core_map = {
local function on_metadata_inventory_put(pos, listname, index, stack, player)
local timer = minetest.get_node_timer(pos)
timer:start(1.0)
timer:start(0.25)
local meta = minetest.get_meta(pos)
if listname == "core" then
local entity_position = {
x = pos.x, y = pos.y + 0.65, z = pos.z
}
local object = minetest.add_entity(entity_position, "maidroid_tool:core_entity")
minetest.add_entity(entity_position, "maidroid_tool:core_entity")
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

After

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B