I haven't found as much time as I would like to improve my coding skills with lua, so I'll ask an easy question, maybe...
When a player dies, I would like to see an item dropped on the ground, but instead of just a piece of "dirt", I want it to say the player's name - "Bob's Dirt". How do you assign a name to an item?
Code: Select all
minetest.register_on_dieplayer( function (player)
local pos = player:getpos()
local x = math.random(0, 15)/10 - 1.25
local z = math.random(0, 15)/10 - 1.25
pos.x = pos.x + x
pos.z = pos.z + z
pos.y = pos.y + .25
local name = player:get_player_name()
local obj = minetest.add_item(pos, "default:dirt")
obj.name = name + "'s dirt" <-- ???
if obj then
obj:get_luaentity().collect = true
end
end )
-RavonTUS