CMI registration examples

This commit is contained in:
Raymoo 2017-06-17 23:51:55 -07:00
parent 47e1664f8b
commit c09e2da079
2 changed files with 16 additions and 0 deletions

View File

@ -1,3 +1,4 @@
local modpath = minetest.get_modpath(minetest.get_current_modname()) .. "/" local modpath = minetest.get_modpath(minetest.get_current_modname()) .. "/"
dofile(modpath .. "implementation.lua") dofile(modpath .. "implementation.lua")
dofile(modpath .. "showdamage.lua")

15
showdamage.lua Normal file
View 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)