diff options
author | FaceDeer <derksenmobile@gmail.com> | 2017-01-05 20:58:36 -0700 |
---|---|---|
committer | FaceDeer <derksenmobile@gmail.com> | 2017-01-05 20:58:36 -0700 |
commit | e9e8e202f9a9d8be64ec331873791d03413bde41 (patch) | |
tree | fe2ed42c89cb6123f1670f50d309e86a68d6f05a | |
parent | 253ff1281571b888cfbfeb1a719eb98a1b5b98de (diff) |
Add logging of various events.
-rw-r--r-- | node_builders.lua | 3 | ||||
-rw-r--r-- | node_controllers.lua | 3 | ||||
-rw-r--r-- | util.lua | 8 |
3 files changed, 10 insertions, 4 deletions
diff --git a/node_builders.lua b/node_builders.lua index 394b627..f173c63 100644 --- a/node_builders.lua +++ b/node_builders.lua @@ -197,6 +197,7 @@ minetest.register_node("digtron:builder", { local build_facing = meta:get_int("build_facing") local facing = minetest.get_node(pos).param2 local buildpos = digtron.find_new_pos(pos, facing) + local oldnode = minetest.get_node(buildpos) if (buildpos[controlling_coordinate] + meta:get_int("offset")) % meta:get_int("period") ~= 0 then return nil @@ -210,6 +211,7 @@ minetest.register_node("digtron:builder", { if digtron.creative_mode then local returned_stack, success = digtron.item_place_node(item_stack, player, buildpos, tonumber(build_facing)) if success == true then + minetest.log("action", string.format("%s uses Digtron to build %s at (%d, %d, %d), displacing %s", player:get_player_name(), item_stack:get_name(), buildpos.x, buildpos.y, buildpos.z, oldnode.name)) nodes_dug:set(buildpos.x, buildpos.y, buildpos.z, false) return true end @@ -223,6 +225,7 @@ minetest.register_node("digtron:builder", { end local returned_stack, success = digtron.item_place_node(item_stack, player, buildpos, tonumber(build_facing)) if success == true then + minetest.log("action", string.format("%s uses Digtron to build %s at (%d, %d, %d), displacing %s", player:get_player_name(), item_stack:get_name(), buildpos.x, buildpos.y, buildpos.z, oldnode.name)) --flag this node as *not* to be dug. nodes_dug:set(buildpos.x, buildpos.y, buildpos.z, false) return true diff --git a/node_controllers.lua b/node_controllers.lua index c897502..4c521da 100644 --- a/node_controllers.lua +++ b/node_controllers.lua @@ -190,7 +190,7 @@ local execute_cycle = function(pos, clicker) end --move the array - digtron.move_digtron(facing, layout.all, layout.extents, nodes_dug) + digtron.move_digtron(facing, layout.all, layout.extents, nodes_dug, clicker:get_player_name()) local oldpos = {x=pos.x, y=pos.y, z=pos.z} pos = digtron.find_new_pos(pos, facing) meta = minetest.get_meta(pos) @@ -246,6 +246,7 @@ local execute_cycle = function(pos, clicker) local node_to_dig, whether_to_dig = nodes_dug:pop() while node_to_dig ~= nil do if whether_to_dig == true then + minetest.log("action", string.format("%s uses Digtron to dig %s at (%d, %d, %d)", clicker:get_player_name(), minetest.get_node(node_to_dig).name, node_to_dig.x, node_to_dig.y, node_to_dig.z)) minetest.remove_node(node_to_dig) end -- all of the digtron's nodes wind up in nodes_dug, so this is an ideal place to stick @@ -95,9 +95,11 @@ digtron.can_move_to = function(pos, protected_nodes, dug_nodes) return false end -digtron.move_node = function(pos, newpos) +digtron.move_node = function(pos, newpos, player_name) -- Moves nodes, preserving digtron metadata and inventory local node = minetest.get_node(pos) + local oldnode = minetest.get_node(newpos) + minetest.log("action", string.format("%s moves %s from (%d, %d, %d) to (%d, %d, %d), displacing %s", player_name, node.name, pos.x, pos.y, pos.z, newpos.x, newpos.y, newpos.z, oldnode.name)) minetest.add_node(newpos, { name=node.name, param1=node.param1, param2=node.param2 }) local oldmeta = minetest.get_meta(pos) @@ -276,7 +278,7 @@ digtron.take_from_inventory = function(itemname, inventory_positions) return nil end -digtron.move_digtron = function(facing, digtrons, extents, nodes_dug) +digtron.move_digtron = function(facing, digtrons, extents, nodes_dug, player_name) -- move everything. Note! order is important or they'll step on each other, that's why this has complicated loops and filtering. -- Nodes are moved in a "caterpillar" pattern - front plane first, then next plane back, then next plane back, etc. -- positions in the digtron list will be updated when this method executes. Note that the inventories list shares @@ -334,7 +336,7 @@ digtron.move_digtron = function(facing, digtrons, extents, nodes_dug) for k, location in pairs(digtrons) do if location[filter] == index then local newpos = digtron.find_new_pos(location, facing) - digtron.move_node(location, newpos) + digtron.move_node(location, newpos, player_name) --By updating the digtron position table in-place we also update all the special node tables as well digtrons[k].x= newpos.x digtrons[k].y= newpos.y |