aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-01-22 00:20:55 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-03-13 23:56:05 +0100
commit9978f5af828550d819890fed1fc56d65838a2c4c (patch)
tree34ba1ca2f7b2607fcd60166419a3ca9ab436e9bb /builtin
parentcb3a61f8db6b7020dd69f7786a1086f6fe014dfc (diff)
downloadminetest-9978f5af828550d819890fed1fc56d65838a2c4c.tar.gz
minetest-9978f5af828550d819890fed1fc56d65838a2c4c.tar.bz2
minetest-9978f5af828550d819890fed1fc56d65838a2c4c.zip
[CSM] Add on_death, on_hp_modification & oh_damage_taken callbacks (#5093)
* Add on_death callback * Add on_hp_modification & on_damage_taken callbacks * move preview code to preview.lua
Diffstat (limited to 'builtin')
-rw-r--r--builtin/client/init.lua17
-rw-r--r--builtin/client/preview.lua24
-rw-r--r--builtin/client/register.lua3
3 files changed, 30 insertions, 14 deletions
diff --git a/builtin/client/init.lua b/builtin/client/init.lua
index d14301ade..e06dfc995 100644
--- a/builtin/client/init.lua
+++ b/builtin/client/init.lua
@@ -3,20 +3,9 @@ local scriptpath = core.get_builtin_path()..DIR_DELIM
local clientpath = scriptpath.."client"..DIR_DELIM
dofile(clientpath .. "register.lua")
+dofile(clientpath .. "preview.lua")
--- This is an example function to ensure it's working properly, should be removed before merge
-core.register_on_shutdown(function()
- print("shutdown client")
+core.register_on_death(function()
+ core.display_chat_message("You died.")
end)
--- This is an example function to ensure it's working properly, should be removed before merge
-core.register_on_receiving_chat_messages(function(message)
- print("Received message " .. message)
- return false
-end)
-
--- This is an example function to ensure it's working properly, should be removed before merge
-core.register_on_sending_chat_messages(function(message)
- print("Sending message " .. message)
- return false
-end)
diff --git a/builtin/client/preview.lua b/builtin/client/preview.lua
new file mode 100644
index 000000000..4b277b0c6
--- /dev/null
+++ b/builtin/client/preview.lua
@@ -0,0 +1,24 @@
+-- This is an example function to ensure it's working properly, should be removed before merge
+core.register_on_shutdown(function()
+ print("shutdown client")
+end)
+
+-- This is an example function to ensure it's working properly, should be removed before merge
+core.register_on_receiving_chat_messages(function(message)
+ print("[PREVIEW] Received message " .. message)
+ return false
+end)
+
+-- This is an example function to ensure it's working properly, should be removed before merge
+core.register_on_sending_chat_messages(function(message)
+ print("[PREVIEW] Sending message " .. message)
+ return false
+end)
+
+core.register_on_hp_modification(function(hp)
+ print("[PREVIEW] HP modified " .. hp)
+end)
+
+core.register_on_damage_taken(function(hp)
+ print("[PREVIEW] Damage taken " .. hp)
+end)
diff --git a/builtin/client/register.lua b/builtin/client/register.lua
index c793195a1..ddaf4f424 100644
--- a/builtin/client/register.lua
+++ b/builtin/client/register.lua
@@ -58,5 +58,8 @@ end
core.registered_on_shutdown, core.register_on_shutdown = make_registration()
core.registered_on_receiving_chat_messages, core.register_on_receiving_chat_messages = make_registration()
core.registered_on_sending_chat_messages, core.register_on_sending_chat_messages = make_registration()
+core.registered_on_death, core.register_on_death = make_registration()
+core.registered_on_hp_modification, core.register_on_hp_modification = make_registration()
+core.registered_on_damage_taken, core.register_on_damage_taken = make_registration()