[Solved] Error trying to get player name

Post Reply
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 » Post

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

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:

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: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: Error trying to get player name

by Nathan.S » Post

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, and brand new Minetest Modding Course

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 » Post

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
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

Re: Error trying to get player name

by kaeza » Post

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

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests