CMI registration examples
This commit is contained in:
parent
47e1664f8b
commit
c09e2da079
1
init.lua
1
init.lua
@ -1,3 +1,4 @@
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname()) .. "/"
|
||||
|
||||
dofile(modpath .. "implementation.lua")
|
||||
dofile(modpath .. "showdamage.lua")
|
||||
|
15
showdamage.lua
Normal file
15
showdamage.lua
Normal file
@ -0,0 +1,15 @@
|
||||
cmi.register_on_punchmob(function(mob, hitter, tflp, toolcaps, dir, damage)
|
||||
if hitter and hitter:is_player() then
|
||||
local pname = hitter:get_player_name()
|
||||
local id = cmi.get_uid(mob)
|
||||
minetest.chat_send_all(id .. " got hit by " .. pname .. "!")
|
||||
end
|
||||
end)
|
||||
|
||||
cmi.register_on_diemob(function(mob, cause)
|
||||
if cause.type == "punch" and cause.puncher and cause.puncher:is_player() then
|
||||
local id = cmi.get_uid(mob)
|
||||
local pname = cause.puncher:get_player_name()
|
||||
minetest.chat_send_all(id .. " was killed by " .. pname .. "!")
|
||||
end
|
||||
end)
|
Loading…
x
Reference in New Issue
Block a user