From c0c9bd5a609e016d0b9607bf1d7a2ddce80df754 Mon Sep 17 00:00:00 2001 From: Gabriel PĂ©rez-Cerezo Date: Wed, 5 Oct 2016 17:39:53 +0200 Subject: Fixed bug (unable to send message to player) --- trackplacer.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/trackplacer.lua b/trackplacer.lua index ca1ebc7..f5d3ad3 100644 --- a/trackplacer.lua +++ b/trackplacer.lua @@ -1,7 +1,11 @@ --trackplacer.lua --holds code for the track-placing system. the default 'track' item will be a craftitem that places rails as needed. this will neither place or change switches nor place vertical rails. -local print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_player(table.concat({t, ...}, " ")) end +local print=function(player, t, ...) minetest.log("action", table.concat({t, ...}, " ")) + if player then + minetest.chat_send_player(player,table.concat({t, ...}, " ")) + end +end --all new trackplacer code local tp={ @@ -214,7 +218,7 @@ minetest.register_craftitem("advtrains:trackworker",{ local nnprefix, suffix, rotation=string.match(node.name, "^([^_]+)_([^_]+)(_?.*)$") --print(node.name.."\npattern recognizes:"..nodeprefix.." / "..railtype.." / "..rotation) if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twrotate[suffix] then - print("[advtrains]railtype not workable by trackworker") + print(placer, "[advtrains]railtype not workable by trackworker") return end local modext=tp.tracks[nnprefix].twrotate[suffix] @@ -226,7 +230,7 @@ minetest.register_craftitem("advtrains:trackworker",{ local modpos for k,v in pairs(modext) do if v==rotation then modpos=k end end if not modpos then - print("[advtrains]rail not workable by trackworker") + print(placer,"[advtrains]rail not workable by trackworker") return end minetest.set_node(pos, {name=nnprefix.."_"..suffix..modext[modpos+1], param2=node.param2}) @@ -247,7 +251,7 @@ minetest.register_craftitem("advtrains:trackworker",{ local nnprefix, suffix, rotation=string.match(node.name, "^([^_]+)_([^_]+)(_?.*)$") if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twcycle[suffix] then - print("[advtrains]railtype not workable by trackworker") + print(user,"[advtrains]railtype not workable by trackworker") return end local nextsuffix=tp.tracks[nnprefix].twcycle[suffix] -- cgit v1.2.3