summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFaceDeer <derksenmobile@gmail.com>2017-02-01 20:32:58 -0700
committerFaceDeer <derksenmobile@gmail.com>2017-02-01 20:32:58 -0700
commitf63e7b7a9be93b69c033fe62d17669e0eab5033c (patch)
treede88dea1e8fb9226903a9941e9d5792d6a534a83
parent43b10262fcb89c90eceb8dff253f541cb4dc67f3 (diff)
add "help" buttons to various formspecs when doc is installed
-rw-r--r--node_builders.lua58
-rw-r--r--node_controllers.lua15
-rw-r--r--node_crate.lua28
-rw-r--r--node_diggers.lua36
4 files changed, 96 insertions, 41 deletions
diff --git a/node_builders.lua b/node_builders.lua
index 01186f4..e7faf0c 100644
--- a/node_builders.lua
+++ b/node_builders.lua
@@ -1,5 +1,34 @@
-- Note: builders go in group 4 and have both test_build and execute_build methods.
+local builder_formspec =
+ "size[8,5.2]" ..
+ default.gui_bg ..
+ default.gui_bg_img ..
+ default.gui_slots ..
+ "list[current_name;main;0.5,0;1,1;]" ..
+ "label[0.5,0.8;Block to build]" ..
+ "field[2.3,0.8;1,0.1;period;Periodicity;${period}]" ..
+ "tooltip[period;Builder will build once every n steps.\nThese steps are globally aligned, so all builders with the\nsame period and offset will build on the same location.]" ..
+ "field[3.3,0.8;1,0.1;offset;Offset;${offset}]" ..
+ "tooltip[offset;Offsets the start of periodicity counting by this amount.\nFor example, a builder with period 2 and offset 0 builds\nevery even-numbered block and one with period 2 and\noffset 1 builds every odd-numbered block.]" ..
+ "button_exit[4.0,0.5;1,0.1;set;Save &\nShow]" ..
+ "tooltip[set;Saves settings]" ..
+ "field[5.3,0.8;1,0.1;build_facing;Facing;${build_facing}]" ..
+ "tooltip[build_facing;Value from 0-23. Not all block types make use of this.\nUse the 'Read & Save' button to copy the facing of the block\ncurrently in the builder output location]" ..
+ "button_exit[6.0,0.5;1,0.1;read;Read &\nSave]" ..
+ "tooltip[read;Reads the facing of the block currently in the build location,\nthen saves all settings]" ..
+ "list[current_player;main;0,1.3;8,1;]" ..
+ default.get_hotbar_bg(0,1.3) ..
+ "list[current_player;main;0,2.5;8,3;8]" ..
+ "listring[current_player;main]" ..
+ "listring[current_name;main]"
+
+if minetest.get_modpath("doc") then
+ builder_formspec = builder_formspec ..
+ "button_exit[7.0,0.5;1,0.1;help;Help]" ..
+ "tooltip[help;Show documentation about this block]"
+end
+
-- Builds objects in the targeted node. This is a complicated beastie.
minetest.register_node("digtron:builder", {
description = "Digtron Builder Module",
@@ -43,30 +72,7 @@ minetest.register_node("digtron:builder", {
on_construct = function(pos)
local meta = minetest.get_meta(pos)
- meta:set_string("formspec",
- "size[8,5.2]" ..
- default.gui_bg ..
- default.gui_bg_img ..
- default.gui_slots ..
- "list[current_name;main;0.5,0;1,1;]" ..
--- "tooltip[main;Builder will build the type of block in this slot.\nNote that only one item needs to be placed here, to 'program' it.\nThe builder will draw construction materials from the central inventory when building.]" ..
- "label[0.5,0.8;Block to build]" ..
- "field[2.5,0.8;1,0.1;period;Periodicity;${period}]" ..
- "tooltip[period;Builder will build once every n steps.\nThese steps are globally aligned, so all builders with the\nsame period and offset will build on the same location.]" ..
- "field[3.5,0.8;1,0.1;offset;Offset;${offset}]" ..
- "tooltip[offset;Offsets the start of periodicity counting by this amount.\nFor example, a builder with period 2 and offset 0 builds\nevery even-numbered block and one with period 2 and\noffset 1 builds every odd-numbered block.]" ..
- "button_exit[4.2,0.5;1,0.1;set;Save &\nShow]" ..
- "tooltip[set;Saves settings]" ..
- "field[5.7,0.8;1,0.1;build_facing;Facing;${build_facing}]" ..
- "tooltip[build_facing;Value from 0-23. Not all block types make use of this.\nUse the 'Read & Save' button to copy the facing of the block\ncurrently in the builder output location]" ..
- "button_exit[6.4,0.5;1,0.1;read;Read &\nSave]" ..
- "tooltip[read;Reads the facing of the block currently in the build location,\nthen saves all settings]" ..
- "list[current_player;main;0,1.3;8,1;]" ..
- default.get_hotbar_bg(0,1.3) ..
- "list[current_player;main;0,2.5;8,3;8]" ..
- "listring[current_player;main]" ..
- "listring[current_name;main]"
- )
+ meta:set_string("formspec", builder_formspec)
meta:set_int("period", 1)
meta:set_int("offset", 0)
meta:set_int("build_facing", 0)
@@ -131,6 +137,10 @@ minetest.register_node("digtron:builder", {
local buildpos = digtron.find_new_pos(pos, facing)
meta:set_int("build_facing", minetest.get_node(buildpos).param2)
end
+
+ if fields.help and minetest.get_modpath("doc") then --check for mod in case someone disabled it after this digger was built
+ doc.show_entry(sender:get_player_name(), "nodes", "digtron:builder")
+ end
digtron.update_builder_item(pos)
end,
diff --git a/node_controllers.lua b/node_controllers.lua
index c51b48f..2a3c629 100644
--- a/node_controllers.lua
+++ b/node_controllers.lua
@@ -75,7 +75,7 @@ local auto_formspec = "size[8,6.2]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
- "container[2.5,0]" ..
+ "container[2.0,0]" ..
"field[0.0,0.8;1,0.1;cycles;Cycles;${cycles}]" ..
"tooltip[cycles;When triggered, this controller will try to run for the given number of cycles.\nThe cycle count will decrement as it runs, so if it gets halted by a problem\nyou can fix the problem and restart.]" ..
"button_exit[0.7,0.5;1,0.1;set;Set]" ..
@@ -97,7 +97,12 @@ local auto_formspec = "size[8,6.2]" ..
"listring[current_player;main]" ..
"listring[current_name;stop]"
-
+if minetest.get_modpath("doc") then
+ auto_formspec = auto_formspec ..
+ "button_exit[7.0,0.5;1,0.1;help;Help]" ..
+ "tooltip[help;Show documentation about this block]"
+end
+
-- Needed to make this global so that it could recurse into minetest.after
digtron.auto_cycle = function(pos)
local node = minetest.get_node(pos)
@@ -263,7 +268,11 @@ minetest.register_node("digtron:auto_controller", {
markerpos[controlling_coordinate] = x_pos + slope
minetest.add_entity(markerpos, "digtron:marker_vertical")
end
- end
+ end
+
+ if fields.help and minetest.get_modpath("doc") then --check for mod in case someone disabled it after this digger was built
+ doc.show_entry(sender:get_player_name(), "nodes", "digtron:auto_controller")
+ end
end,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
diff --git a/node_crate.lua b/node_crate.lua
index 170b258..21c056a 100644
--- a/node_crate.lua
+++ b/node_crate.lua
@@ -40,17 +40,37 @@ minetest.register_node("digtron:empty_crate", {
end,
})
-local loaded_formspec = "size[4,1.5]" ..
+local loaded_formspec
+
+if minetest.get_modpath("doc") then
+ loaded_formspec =
+ "size[4.1,1.5]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"field[0.3,0.5;4,0.5;title;Digtron Name;${title}]" ..
- "button_exit[0.5,1.2;1,0.1;save;Save\nTitle]" ..
+ "button_exit[0.0,1.2;1,0.1;save;Save\nTitle]" ..
"tooltip[save;Saves the title of this Digtron]" ..
+ "button_exit[1.0,1.2;1,0.1;show;Show\nBlocks]" ..
+ "tooltip[show;Shows which blocks the packed Digtron will occupy if unpacked]" ..
+ "button_exit[2.0,1.2;1,0.1;unpack;Unpack]" ..
+ "tooltip[unpack;Attempts to unpack the Digtron on this location]" ..
+ "button_exit[3.0,1.2;1,0.1;help;Help]" ..
+ "tooltip[help;Show documentation about this block]"
+else
+ loaded_formspec =
+ "size[4,1.5]" ..
+ default.gui_bg ..
+ default.gui_bg_img ..
+ default.gui_slots ..
+ "field[0.3,0.5;4,0.5;title;Digtron Name;${title}]" ..
+ "button_exit[0.5,1.2;1,0.1;save;Save\nTitle]" ..
+ "tooltip[show;Saves the title of this Digtron]" ..
"button_exit[1.5,1.2;1,0.1;show;Show\nBlocks]" ..
"tooltip[save;Shows which blocks the packed Digtron will occupy if unpacked]" ..
"button_exit[2.5,1.2;1,0.1;unpack;Unpack]" ..
"tooltip[unpack;Attempts to unpack the Digtron on this location]"
+end
minetest.register_node("digtron:loaded_crate", {
description = "Digtron Crate (Loaded)",
@@ -75,6 +95,10 @@ minetest.register_node("digtron:loaded_crate", {
meta:set_string("infotext", fields.title)
end
+ if fields.help and minetest.get_modpath("doc") then --check for mod in case someone disabled it after this digger was built
+ doc.show_entry(sender:get_player_name(), "nodes", "digtron:loaded_crate")
+ end
+
if not (fields.unpack or fields.show) then
return
end
diff --git a/node_diggers.lua b/node_diggers.lua
index b0bf59b..7505606 100644
--- a/node_diggers.lua
+++ b/node_diggers.lua
@@ -21,20 +21,28 @@ local dual_digger_nodebox = {
{-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125}, -- Lower_Cutter_2
}
+local intermittent_formspec =
+ default.gui_bg ..
+ default.gui_bg_img ..
+ default.gui_slots ..
+ "field[0.5,0.8;1,0.1;period;Periodicity;${period}]" ..
+ "tooltip[period;Digger will dig once every n steps.\nThese steps are globally aligned, all diggers with\nthe same period and offset will dig on the same location.]" ..
+ "field[1.5,0.8;1,0.1;offset;Offset;${offset}]" ..
+ "tooltip[offset;Offsets the start of periodicity counting by this amount.\nFor example, a digger with period 2 and offset 0 digs\nevery even-numbered block and one with period 2 and\noffset 1 digs every odd-numbered block.]" ..
+ "button_exit[2.2,0.5;1,0.1;set;Save]" ..
+ "tooltip[set;Saves settings]"
+
local intermittent_on_construct = function(pos)
+ local formspec = intermittent_formspec
+ if minetest.get_modpath("doc") then
+ formspec = "size[4.5,1]" .. formspec ..
+ "button_exit[3.2,0.5;1,0.1;help;Help]" ..
+ "tooltip[help;Show documentation about this block]"
+ else
+ formspec = "size[3.5,1]" .. formspec
+ end
local meta = minetest.get_meta(pos)
- meta:set_string("formspec",
- "size[3.5,1]" ..
- default.gui_bg ..
- default.gui_bg_img ..
- default.gui_slots ..
- "field[0.5,0.8;1,0.1;period;Periodicity;${period}]" ..
- "tooltip[period;Digger will dig once every n steps.\nThese steps are globally aligned, all diggers with\nthe same period and offset will dig on the same location.]" ..
- "field[1.5,0.8;1,0.1;offset;Offset;${offset}]" ..
- "tooltip[offset;Offsets the start of periodicity counting by this amount.\nFor example, a digger with period 2 and offset 0 digs\nevery even-numbered block and one with period 2 and\noffset 1 digs every odd-numbered block.]" ..
- "button_exit[2.2,0.5;1,0.1;set;Save]" ..
- "tooltip[set;Saves settings]"
- )
+ meta:set_string("formspec", formspec)
meta:set_int("period", 1)
meta:set_int("offset", 0)
end
@@ -49,6 +57,10 @@ local intermittent_on_receive_fields = function(pos, formname, fields, sender)
if offset then
meta:set_int("offset", math.floor(offset))
end
+ if fields.help and minetest.get_modpath("doc") then --check for mod in case someone disabled it after this digger was built
+ local node_name = minetest.get_node(pos).name
+ doc.show_entry(sender:get_player_name(), "nodes", node_name)
+ end
end,
-- Digs out nodes that are "in front" of the digger head.