diff options
author | Andrew Ward <rw@rubenwardy.com> | 2018-03-28 16:05:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-28 16:05:18 +0100 |
commit | dfc81983491417c5cd1c99d7db05e421c409379d (patch) | |
tree | 7b0457f0ff86f038cfad1a095d3ab0b6c44f2def /games/minimal/mods | |
parent | 2323842dd3dd336b087ca3cf9756e0680b3a1244 (diff) | |
download | minetest-dfc81983491417c5cd1c99d7db05e421c409379d.tar.gz minetest-dfc81983491417c5cd1c99d7db05e421c409379d.tar.bz2 minetest-dfc81983491417c5cd1c99d7db05e421c409379d.zip |
Add reasons to on_dieplayer and on_hpchange
Diffstat (limited to 'games/minimal/mods')
-rw-r--r-- | games/minimal/mods/test/init.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/games/minimal/mods/test/init.lua b/games/minimal/mods/test/init.lua index 051b47906..b08ddfa94 100644 --- a/games/minimal/mods/test/init.lua +++ b/games/minimal/mods/test/init.lua @@ -9,3 +9,32 @@ assert(pseudo:next() == 22290) assert(pseudo:next() == 13854) +-- +-- HP Change Reasons +-- +local expect = nil +minetest.register_on_joinplayer(function(player) + expect = { type = "set_hp", from = "mod" } + player:set_hp(3) + assert(expect == nil) + + expect = { a = 234, type = "set_hp", from = "mod" } + player:set_hp(10, { a= 234 }) + assert(expect == nil) + + expect = { df = 3458973454, type = "fall", from = "mod" } + player:set_hp(10, { type = "fall", df = 3458973454 }) + assert(expect == nil) +end) + +minetest.register_on_player_hpchange(function(player, hp, reason) + for key, value in pairs(reason) do + assert(expect[key] == value) + end + + for key, value in pairs(expect) do + assert(reason[key] == value) + end + + expect = nil +end) |