diff options
author | BlockMen <nmuelll@web.de> | 2015-04-02 16:08:02 +0200 |
---|---|---|
committer | BlockMen <nmuelll@web.de> | 2015-04-03 12:33:53 +0200 |
commit | 1071c7f13e491b2f3bc09bbbcb1bd6aaed6071c5 (patch) | |
tree | fbc4937b87c213cea5822d8b86eff2cafee36965 /functions.lua | |
parent | 69a993861ef19f17626c72f6b0f9c03e137c5051 (diff) |
Rewrite mod, push to 2.0
- Seperated hunger -> https://github.com/BlockMen/hunger
- Added API
Diffstat (limited to 'functions.lua')
-rw-r--r-- | functions.lua | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/functions.lua b/functions.lua new file mode 100644 index 0000000..a7063d9 --- /dev/null +++ b/functions.lua @@ -0,0 +1,46 @@ +function hud.read_conf() + local mod_path = minetest.get_modpath("hud") + local set = io.open(mod_path .. "/hud.conf", "r") + if set then + dofile(mod_path .. "/hud.conf") + set:close() + end +end + +function hud.notify_hunger(delay, use) + local txt_part = "enable" + if use then + txt_part = "use" + end + minetest.after(delay, function() + minetest.chat_send_all("#Better HUD: You can't " .. txt_part .. " hunger without the \"hunger\" mod") + minetest.chat_send_all(" Enable it or download it from \"https://github.com/BlockMen/hunger\"") + end) +end + +function hud.player_event(player, event) + --needed for first update called by on_join + minetest.after(0, function() + if event == "health_changed" then + for _,v in pairs(hud.damage_events) do + if v.func then + v.func(player) + end + end + end + + if event == "breath_changed" then + for _,v in pairs(hud.breath_events) do + if v.func then + v.func(player) + end + end + end + + if event == "hud_changed" then--called when flags changed + + end + end) +end + +core.register_playerevent(hud.player_event) |