From 1071c7f13e491b2f3bc09bbbcb1bd6aaed6071c5 Mon Sep 17 00:00:00 2001 From: BlockMen Date: Thu, 2 Apr 2015 16:08:02 +0200 Subject: Rewrite mod, push to 2.0 - Seperated hunger -> https://github.com/BlockMen/hunger - Added API --- functions.lua | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 functions.lua (limited to 'functions.lua') 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) -- cgit v1.2.3