summaryrefslogtreecommitdiff
path: root/games/minimal/mods/test/init.lua
blob: b08ddfa94e00063accded14801cb56ebfd4727b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
--
-- Minimal Development Test
-- Mod: test
--

-- Try out PseudoRandom
pseudo = PseudoRandom(13)
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)