Skip to content

Commit 5919f43

Browse files
authored
Remove extra print() calls and copy Luacontroller's print behavior (#127)
1 parent 71fe600 commit 5919f43

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

autoplace_pipes.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ function pipeworks.scan_pipe_surroundings(pos)
211211
pzm = 1
212212
end
213213

214-
print("stage 2 returns "..pxm+8*pxp+2*pym+16*pyp+4*pzm+32*pzp..
214+
minetest.log("info", "stage 2 returns "..pxm+8*pxp+2*pym+16*pyp+4*pzm+32*pzp..
215215
" for nodes surrounding "..minetest.get_node(pos).name.." at "..minetest.pos_to_string(pos))
216216
return pxm+8*pxp+2*pym+16*pyp+4*pzm+32*pzp
217217
end

settingtypes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,7 @@ pipeworks_entity_update_interval (Entity Update Interval) float 0 0 0.8
8787

8888
# if set to true, items passing through teleport tubes will log log where they came from and where they went.
8989
pipeworks_log_teleport_tubes (Log Teleport Tubes) bool false
90+
91+
# Behavior of print() inside a lua tube. By default, this emits a message into actionstream.
92+
# Set it to noop if you wish to disable that behavior.
93+
pipeworks_lua_tube_print_behavior (Behavior of print in Lua Tube) enum log log,noop

tubes/lua.lua

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,13 @@ end
229229
-------------------------
230230

231231
local function safe_print(param)
232-
local string_meta = getmetatable("")
233-
local sandbox = string_meta.__index
234-
string_meta.__index = string -- Leave string sandbox temporarily
235-
print(dump(param))
236-
string_meta.__index = sandbox -- Restore string sandbox
232+
if (minetest.settings:get("pipeworks_lua_tube_print_behavior") or "log") == "log" then
233+
local string_meta = getmetatable("")
234+
local sandbox = string_meta.__index
235+
string_meta.__index = string -- Leave string sandbox temporarily
236+
minetest.log("action", string.format("[pipeworks.tubes.lua] print(%s)", dump(param)))
237+
string_meta.__index = sandbox -- Restore string sandbox
238+
end
237239
end
238240

239241
local function safe_date()
@@ -603,7 +605,7 @@ local function save_memory(pos, meta, mem)
603605
meta:set_string("lc_memory", memstring)
604606
meta:mark_as_private("lc_memory")
605607
else
606-
print("Error: lua_tube memory overflow. "..memsize_max.." bytes available, "
608+
minetest.log("info", "lua_tube memory overflow. "..memsize_max.." bytes available, "
607609
..#memstring.." required. Controller overheats.")
608610
burn_controller(pos)
609611
end

wielder.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ if pipeworks.enable_node_breaker then
281281
-- Don't mechanically wear out tool
282282
if stack:get_wear() ~= old_stack:get_wear() and stack:get_count() == old_stack:get_count()
283283
and (item_def.wear_represents == nil or item_def.wear_represents == "mechanical_wear") then
284-
print("replaced")
285284
fakeplayer:set_wielded_item(old_stack)
286285
end
287286
elseif not stack:is_empty() then

0 commit comments

Comments
 (0)