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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 -- -- HP Change Reasons -- local expect = nil minetest.register_on_player_hpchange(function(player, hp, reason) if expect == nil then return end 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) local function run_hpchangereason_tests(player) local old_hp = player:get_hp() player:set_hp(20) expect = { type = "set_hp", from = "mod" } player:set_hp(3) assert(expect == nil) expect = { a = 234, type = "set_hp", from = "mod" } player:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Created with Inkscape (http://www.inkscape.org/) --> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="512" height="512" viewBox="0 0 135.46666 135.46667" version="1.1" id="svg8" inkscape:version="0.92.1 r15371" sodipodi:docname="drop_btn.svg" inkscape:export-filename="/home/stu/Desktop/icons/png/drop_btn.png" inkscape:export-xdpi="24.000002" inkscape:export-ydpi="24.000002"> <defs id="defs2"> <filter style="color-interpolation-filters:sRGB;" inkscape:label="Colorize" id="filter4628"> <feComposite in2="SourceGraphic" operator="arithmetic" k1="0" k2="1" result="composite1" id="feComposite4614" /> <feColorMatrix in="composite1" values="1" type="saturate" result="colormatrix1" id="feColorMatrix4616" /> <feFlood flood-opacity="1" flood-color="rgb(158,0,0)" result="flood1" id="feFlood4618" /> <feBlend in="flood1" in2="colormatrix1" mode="multiply" result="blend1" id="feBlend4620" /> <feBlend in2="blend1" mode="screen" result="blend2" id="feBlend4622" /> <feColorMatrix in="blend2" values="1" type="saturate" result="colormatrix2" id="feColorMatrix4624" /> <feComposite in="colormatrix2" in2="SourceGraphic" operator="in" k2="1" result="composite2" id="feComposite4626" /> </filter> </defs> <sodipodi:namedview id="base" pagecolor="#404040" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:zoom="0.49497475" inkscape:cx="-435.15132" inkscape:cy="209.28829" inkscape:document-units="mm" inkscape:current-layer="layer2" showgrid="true" units="px" inkscape:window-wi end unittests.register("test_player_meta", run_player_meta_tests, {player=true})