Add a tell command
This commit is contained in:
parent
ff2da40fb4
commit
b44926e824
@ -58,6 +58,15 @@ minetest.register_chatcommand("npcf", {
|
||||
minetest.chat_send_player(name, "Invalid position "..args)
|
||||
end
|
||||
end
|
||||
elseif cmd == "tell" then
|
||||
if admin or name == index[npc_name] then
|
||||
local luaentity = npcf:get_luaentity(npc_name)
|
||||
if luaentity and luaentity.on_tell then
|
||||
luaentity.on_tell(luaentity, name, args)
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(name, "You don't have permission to tell "..npc_name.." things")
|
||||
end
|
||||
elseif cmd == "setskin" then
|
||||
if admin or name == index[npc_name] then
|
||||
if args == "random" then
|
||||
|
@ -276,6 +276,18 @@ function npcf:register_npc(name, def)
|
||||
def.on_step(self, dtime)
|
||||
end
|
||||
end,
|
||||
on_tell = function(self, sender, message)
|
||||
if type(def.on_tell) == "function" and get_valid_entity(self) then
|
||||
local player = minetest.get_player_by_name(sender)
|
||||
local senderpos
|
||||
if player then
|
||||
senderpos = player:getpos()
|
||||
else
|
||||
senderpos = {0,0,0}
|
||||
end
|
||||
def.on_tell(self, sender, senderpos, message)
|
||||
end
|
||||
end,
|
||||
get_staticdata = function(self)
|
||||
local npc_data = {
|
||||
name = self.name,
|
||||
|
Loading…
x
Reference in New Issue
Block a user