[Solved] Error trying to get player name

User avatar
yawin
Member
 
Posts: 18
Joined: Fri Dec 30, 2016 17:09
In-game: Yawin

[Solved] Error trying to get player name

by yawin » Tue Jan 31, 2017 20:59

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"
Last edited by yawin on Wed Feb 01, 2017 00:30, edited 1 time in total.
dynamic_cast<Signature*>(me→signature)
 

User avatar
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: Error trying to get player name

by Nathan.S » Tue Jan 31, 2017 23:01

That error is saying that wrap isn't a valid function. Which looking at your code u don't see a wrap function.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

User avatar
yawin
Member
 
Posts: 18
Joined: Fri Dec 30, 2016 17:09
In-game: Yawin

Re: Error trying to get player name

by yawin » Wed Feb 01, 2017 00:30

I just found the error, chat_send_player needs two arguments and I only send one hahaha
dynamic_cast<Signature*>(me→signature)
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Error trying to get player name

by kaeza » Wed Feb 01, 2017 06:11

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?
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 9 guests

cron