summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFaceDeer <derksenmobile@gmail.com>2017-01-02 16:05:48 -0700
committerFaceDeer <derksenmobile@gmail.com>2017-01-02 16:05:48 -0700
commitec1ee19893c3e645b34607e9df069f164be7f31c (patch)
tree275abf701f3ac1d0be0ce77b3c39b6a347b6d7bc
parent5ba5b76ba74f1c71eb89dc5935a19cfea2b0a014 (diff)
adding output location visualizer entities for the build heads.
-rw-r--r--README.txt10
-rw-r--r--entities.lua51
-rw-r--r--init.lua1
-rw-r--r--node_builders.lua34
-rw-r--r--textures/digtron_marker.pngbin0 -> 212 bytes
-rw-r--r--textures/digtron_marker_side.pngbin0 -> 216 bytes
6 files changed, 94 insertions, 2 deletions
diff --git a/README.txt b/README.txt
index 2849878..0c67e69 100644
--- a/README.txt
+++ b/README.txt
@@ -68,6 +68,8 @@ Builder Head
A builder head is the most complex component of this system. It has period and offset properties, and also an inventory slot where you "program" it by placing an example of the node type that you want it to build. Only a single item is needed here, any additional items in this inventory stack will be shunted into the digger's general inventory (or ejected from the control node if there's no space for it).
+When the "Save & Show" button is clicked the properties for period and offset will be saved, and markers will briefly be shown to indicate where the nearest spots corresponding to those values are. The builder will build its output at those locations provided it is moving along the matching axis.
+
The "output" side of a builder is the side with a black crosshair on it.
Builders also have a "facing" setting. If you haven't memorized the meaning of the 24 facing values yet, builder heads have a helpful "Read & Save" button to fill this value in for you. Simply build a temporary instance of the node in the output location in front of the builder, adjust it to the orientation you want using the screwdriver tool, and then when you click the "Read & Save" button the node's facing will be read and saved.
@@ -190,3 +192,11 @@ Pusher controller:
[ , coal , ]
[coal, core , coal]
[ , coal , ]
+
+
+Tips and tricks
+===============
+
+If you're building a repeating pattern of nodes, your periodicity should be one larger than your largest offset. For example, if you've laid out builders to create a set of spiral stairs and the offsets are from 0 to 11, you'll want to use periodicity 12.
+
+A good way to program a set of builders is to build a complete example of the structure you want them to create, then place builders against the structure and have them "read" all of its facings. This also lets you more easily visualize the tricks that might be needed to allow the digtron to pass through the structure as it's being built. \ No newline at end of file
diff --git a/entities.lua b/entities.lua
new file mode 100644
index 0000000..b3d12cb
--- /dev/null
+++ b/entities.lua
@@ -0,0 +1,51 @@
+minetest.register_entity("digtron:marker", {
+ initial_properties = {
+ visual = "cube",
+ visual_size = {x=1.1, y=1.1},
+ textures = {"digtron_marker_side.png","digtron_marker_side.png","digtron_marker.png","digtron_marker.png","digtron_marker_side.png","digtron_marker_side.png"},
+ collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},
+ physical = false,
+ },
+
+ on_activate = function(self, staticdata)
+ minetest.after(5.0,
+ function(self)
+ self.object:remove()
+ end,
+ self)
+ end,
+
+ on_rightclick=function(self, clicker)
+ self.object:remove()
+ end,
+
+ on_punch = function(self, hitter)
+ self.object:remove()
+ end,
+})
+
+minetest.register_entity("digtron:marker_vertical", {
+ initial_properties = {
+ visual = "cube",
+ visual_size = {x=1.1, y=1.1},
+ textures = {"digtron_marker.png","digtron_marker.png","digtron_marker_side.png^[transformR90","digtron_marker_side.png^[transformR90","digtron_marker_side.png^[transformR90","digtron_marker_side.png^[transformR90"},
+ collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},
+ physical = false,
+ },
+
+ on_activate = function(self, staticdata)
+ minetest.after(5.0,
+ function(self)
+ self.object:remove()
+ end,
+ self)
+ end,
+
+ on_rightclick=function(self, clicker)
+ self.object:remove()
+ end,
+
+ on_punch = function(self, hitter)
+ self.object:remove()
+ end,
+})
diff --git a/init.lua b/init.lua
index 58b6a19..8ba1842 100644
--- a/init.lua
+++ b/init.lua
@@ -1,5 +1,6 @@
dofile( minetest.get_modpath( "digtron" ) .. "/util.lua" )
dofile( minetest.get_modpath( "digtron" ) .. "/pointset.lua" )
+dofile( minetest.get_modpath( "digtron" ) .. "/entities.lua" )
dofile( minetest.get_modpath( "digtron" ) .. "/node_misc.lua" ) -- contains inventory and structure nodes
dofile( minetest.get_modpath( "digtron" ) .. "/node_diggers.lua" ) -- contains all diggers
diff --git a/node_builders.lua b/node_builders.lua
index ceed288..04431fc 100644
--- a/node_builders.lua
+++ b/node_builders.lua
@@ -52,7 +52,7 @@ minetest.register_node("digtron:builder", {
"tooltip[period;Builder will build once every n steps. These steps are globally aligned, so all builders with the same 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. For example, a builder with period 2 and offset 0 builds every even-numbered node and one with period 2 and offset 1 builds every odd-numbered node.]" ..
- "button_exit[4.2,0.5;1,0.1;set;Save]" ..
+ "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 node types make use of this. Use the 'Read & Save' button to copy the facing of the node currently in the builder output location]" ..
@@ -83,7 +83,37 @@ minetest.register_node("digtron:builder", {
meta:set_int("offset", math.floor(tonumber(fields.offset)))
end
- if fields.read then
+ if fields.set then
+ local buildpos = digtron.find_new_pos(pos, minetest.get_node(pos).param2)
+ local offset_mod_period = math.abs(offset%period)
+ local x_pos = math.floor(buildpos.x/period)*period - offset_mod_period
+ minetest.add_entity({x=x_pos, y=buildpos.y, z=buildpos.z}, "digtron:marker")
+ if x_pos >= buildpos.x then
+ minetest.add_entity({x=x_pos - period, y=buildpos.y, z=buildpos.z}, "digtron:marker")
+ end
+ if x_pos <= buildpos.x then
+ minetest.add_entity({x=x_pos + period, y=buildpos.y, z=buildpos.z}, "digtron:marker")
+ end
+
+ local y_pos = math.floor(buildpos.y/period)*period - offset_mod_period
+ minetest.add_entity({x=buildpos.x, y=y_pos, z=buildpos.z}, "digtron:marker_vertical")
+ if y_pos >= buildpos.y then
+ minetest.add_entity({x=buildpos.x, y=y_pos - period, z=buildpos.z}, "digtron:marker_vertical")
+ end
+ if y_pos <= buildpos.y then
+ minetest.add_entity({x=buildpos.x, y=y_pos + period, z=buildpos.z}, "digtron:marker_vertical")
+ end
+
+ local z_pos = math.floor(buildpos.z/period)*period - offset_mod_period
+ minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos}, "digtron:marker"):setyaw(1.5708)
+ if z_pos >= buildpos.z then
+ minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos - period}, "digtron:marker"):setyaw(1.5708)
+ end
+ if z_pos <= buildpos.z then
+ minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos + period}, "digtron:marker"):setyaw(1.5708)
+ end
+
+ elseif fields.read then
local meta = minetest.get_meta(pos)
local facing = minetest.get_node(pos).param2
local buildpos = digtron.find_new_pos(pos, facing)
diff --git a/textures/digtron_marker.png b/textures/digtron_marker.png
new file mode 100644
index 0000000..f625ef4
--- /dev/null
+++ b/textures/digtron_marker.png
Binary files differ
diff --git a/textures/digtron_marker_side.png b/textures/digtron_marker_side.png
new file mode 100644
index 0000000..0ed3cfb
--- /dev/null
+++ b/textures/digtron_marker_side.png
Binary files differ