aboutsummaryrefslogtreecommitdiff
path: root/trackplacer.lua
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2016-10-05 21:56:21 +0200
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2016-10-05 21:56:21 +0200
commit08f957f1895f18a8bc017c9a99c5d5ef139694fc (patch)
tree994c3301fc062aa9331319b8cbde0bc8214337cb /trackplacer.lua
parentc0c9bd5a609e016d0b9607bf1d7a2ddce80df754 (diff)
downloadadvtrains-08f957f1895f18a8bc017c9a99c5d5ef139694fc.tar.gz
advtrains-08f957f1895f18a8bc017c9a99c5d5ef139694fc.tar.bz2
advtrains-08f957f1895f18a8bc017c9a99c5d5ef139694fc.zip
Fixed Bug introduced by bugfix
Diffstat (limited to 'trackplacer.lua')
-rw-r--r--trackplacer.lua18
1 files changed, 13 insertions, 5 deletions
diff --git a/trackplacer.lua b/trackplacer.lua
index f5d3ad3..e1033a4 100644
--- a/trackplacer.lua
+++ b/trackplacer.lua
@@ -205,9 +205,13 @@ minetest.register_craftitem("advtrains:trackworker",{
wield_image = "advtrains_trackworker.png",
stack_max = 1,
on_place = function(itemstack, placer, pointed_thing)
+ local name = placer:get_player_name()
+ if not name then
+ return
+ end
if pointed_thing.type=="node" then
local pos=pointed_thing.under
- if minetest.is_protected(pos, placer) then
+ if minetest.is_protected(pos, name) then
return
end
local node=minetest.get_node(pos)
@@ -218,7 +222,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(placer, "[advtrains]railtype not workable by trackworker")
+ print(name, "[advtrains]railtype not workable by trackworker")
return
end
local modext=tp.tracks[nnprefix].twrotate[suffix]
@@ -239,10 +243,14 @@ minetest.register_craftitem("advtrains:trackworker",{
end
end,
on_use=function(itemstack, user, pointed_thing)
+ local name = user:get_player_name()
+ if not name then
+ return
+ end
if pointed_thing.type=="node" then
local pos=pointed_thing.under
local node=minetest.get_node(pos)
- if minetest.is_protected(pos, user) then
+ if minetest.is_protected(pos, name) then
return
end
@@ -251,7 +259,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(user,"[advtrains]railtype not workable by trackworker")
+ print(name,"[advtrains]railtype not workable by trackworker")
return
end
local nextsuffix=tp.tracks[nnprefix].twcycle[suffix]
@@ -259,7 +267,7 @@ minetest.register_craftitem("advtrains:trackworker",{
--invalidate trains
advtrains.invalidate_all_paths()
else
- print(dump(tp.tracks))
+ print(name, dump(tp.tracks))
end
end,
})