diff options
author | FaceDeer <derksenmobile@gmail.com> | 2016-12-31 21:19:52 -0700 |
---|---|---|
committer | FaceDeer <derksenmobile@gmail.com> | 2016-12-31 21:19:52 -0700 |
commit | 68e0ca21c6ff335d1b27c3bebc796de56cb2a49b (patch) | |
tree | 773926f57c8ec78f628d1620800f081a48404324 /node_controllers.lua | |
parent | 70803f1f44febe19da436194d36afe85e983d473 (diff) |
Changed sand digger to a more generic soft material digger, added more sophisticated traction, made structure climbable, added infotexts
Diffstat (limited to 'node_controllers.lua')
-rw-r--r-- | node_controllers.lua | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/node_controllers.lua b/node_controllers.lua index f8b0b6b..e3f8ccb 100644 --- a/node_controllers.lua +++ b/node_controllers.lua @@ -45,12 +45,14 @@ minetest.register_node("digtron:controller", { if layout.all == nil then -- get_all_digtron_neighbours returns nil if the digtron array touches unloaded nodes, too dangerous to do anything in that situation. Abort. minetest.sound_play("buzzer", {gain=0.5, pos=pos}) + meta:set_string("infotext", "Digtron is adjacent to unloaded nodes.") return end - if layout.traction == false then + if layout.traction * digtron.traction_factor < table.getn(layout.all) then -- digtrons can't fly minetest.sound_play("squeal", {gain=1.0, pos=pos}) + meta:set_string("infotext", string.format("Digtron has %d nodes but only enough traction to move %d nodes.", table.getn(layout.all), layout.traction * digtron.traction_factor)) return end @@ -103,6 +105,7 @@ minetest.register_node("digtron:controller", { ) minetest.sound_play("squeal", {gain=1.0, pos=pos}) minetest.sound_play("buzzer", {gain=0.5, pos=pos}) + meta:set_string("infotext", "Digtron is obstructed.") return --Abort, don't dig and don't build. end @@ -145,8 +148,10 @@ minetest.register_node("digtron:controller", { ) if test_build_return == 1 then minetest.sound_play("honk", {gain=0.5, pos=pos}) -- A builder is not configured + meta:set_string("infotext", "Digtron connected to at least one builder node that hasn't had an output material assigned.") elseif test_build_return == 2 then minetest.sound_play("dingding", {gain=1.0, pos=pos}) -- Insufficient inventory + meta:set_string("infotext", "Digtron has insufficient materials in inventory to execute all build operations.") end return --Abort, don't dig and don't build. end @@ -192,7 +197,7 @@ minetest.register_node("digtron:controller", { local targetdef = minetest.registered_nodes[target.name] if targetdef.execute_build ~= nil then --using the old location of the controller as fallback so that any leftovers land with the rest of the digger output. Not that there should be any. - can_build = targetdef.execute_build(location, clicker, layout.inventories, layout.protected, nodes_dug, controlling_coordinate, oldpos) + can_build = can_build and targetdef.execute_build(location, clicker, layout.inventories, layout.protected, nodes_dug, controlling_coordinate, oldpos) else minetest.log(string.format("%s has builder group but is missing execute_build method! This is an error in mod programming, file a bug.", targetdef.name)) end @@ -201,6 +206,7 @@ minetest.register_node("digtron:controller", { -- We weren't able to detect this build failure ahead of time, so make a big noise now. This is strange, shouldn't happen often. minetest.sound_play("dingding", {gain=1.0, pos=pos}) minetest.sound_play("buzzer", {gain=0.5, pos=pos}) + meta:set_string("infotext", "Digtron unexpectedly failed to execute a build operation.") end -- finally, dig out any nodes remaining to be dug. Some of these will have had their flag revoked because @@ -250,12 +256,14 @@ minetest.register_node("digtron:pusher", { if layout.all == nil then -- get_all_digtron_neighbours returns nil if the digtron array touches unloaded nodes, too dangerous to do anything in that situation. Abort. minetest.sound_play("buzzer", {gain=0.5, pos=pos}) + meta:set_string("infotext", "Digtron is adjacent to unloaded nodes.") return end - if layout.traction == false then + if layout.traction * digtron.traction_factor < table.getn(layout.all) then -- digtrons can't fly minetest.sound_play("squeal", {gain=1.0, pos=pos}) + meta:set_string("infotext", string.format("Digtron has %d nodes but only enough traction to move %d nodes.", table.getn(layout.all), layout.traction * digtron.traction_factor)) return end @@ -276,7 +284,7 @@ minetest.register_node("digtron:pusher", { if not can_move then -- mark this node as waiting, will clear this flag in digtron.refractory seconds - minetest.get_meta(pos):set_string("waiting", "true") + meta:set_string("waiting", "true") minetest.after(digtron.refractory, function (pos) minetest.get_meta(pos):set_string("waiting", nil) @@ -284,6 +292,7 @@ minetest.register_node("digtron:pusher", { ) minetest.sound_play("squeal", {gain=1.0, pos=pos}) minetest.sound_play("buzzer", {gain=0.5, pos=pos}) + meta:set_string("infotext", "Digtron is obstructed.") return --Abort end |