Page 1 of 1

[Solved] Error trying to get player name

PostPosted: Tue Jan 31, 2017 20:59
by yawin
Hi! I'm trying to get the name of the player who places a node and I don't know what I'm doing wrong but it says
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
2017-01-31 21:58:11: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'magic' in callback item_OnPlace(): ....minetest/games/redblokers/mods/magic/home_stone.lua:111: bad argument #2 to 'chat_send_player' (string expected, got no value)
2017-01-31 21:58:11: ERROR[Main]: stack traceback:
2017-01-31 21:58:11: ERROR[Main]:    [C]: in function 'chat_send_player'
2017-01-31 21:58:11: ERROR[Main]:    ....minetest/games/redblokers/mods/magic/home_stone.lua:111: in function 'warp'
2017-01-31 21:58:11: ERROR[Main]:    ....minetest/games/redblokers/mods/magic/home_stone.lua:9: in function <....minetest/games/redblokers/mods/magic/home_stone.lua:7>
2017-01-31 21:58:11: ACTION[Server]: singleplayer leaves game. List of players:


My function is:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_craftitem("magic:home_stone",{
   description = "Home stone",
   inventory_image = "home_stone.png",

   on_place = function(itemstack, placer, pointed_thing)
      minetest.chat_send_all(placer:get_player_name())
      magic.warp(placer:get_player_name())
   end,
})


Edit: Solution -> "I just found the error, chat_send_player needs two arguments and I only send one hahaha"

Re: Error trying to get player name

PostPosted: Tue Jan 31, 2017 23:01
by Nathan.S
That error is saying that wrap isn't a valid function. Which looking at your code u don't see a wrap function.

Re: Error trying to get player name

PostPosted: Wed Feb 01, 2017 00:30
by yawin
I just found the error, chat_send_player needs two arguments and I only send one hahaha

Re: Error trying to get player name

PostPosted: Wed Feb 01, 2017 06:11
by kaeza
yawin wrote:I just found the error, chat_send_player needs two arguments and I only send one hahaha

You say chat_send_player, but your code uses chat_send_all. So care to update your code?