From dd9716e30d56a21cafb0bcae57b2bfcb3a4cbcf4 Mon Sep 17 00:00:00 2001 From: Dirk Sohler Date: Thu, 27 Jul 2017 21:20:11 +0200 Subject: [PATCH] make independent from xtend_default --- init.lua | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/init.lua b/init.lua index c34fc58..8e58e4d 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,3 @@ -_xtend.i() - - -- Convert a given x,y string into a table {x=given_x, y=given_y} and return -- it to be used of the screen location parameters in the HUD definition local _mtimer_location_value = function (o) @@ -10,23 +7,42 @@ local _mtimer_location_value = function (o) end -local interval = _xtend.g('mtimer_update_interval') -local placeholder = _xtend.g('mtimer_placeholder') -local font_color = _xtend.g('mtimer_font_color') +local _mtimer_get_options = function () + local path = minetest.get_modpath(minetest.get_current_modname()) + local file = io.open(path..DIR_DELIM..'settingtypes.txt', 'rb') + local result = {} + + for line in file:lines() do + if line:match("^([a-zA-Z])") then + local name = line:gsub(' .+', '') + local default_value = line:gsub('^[^ ]+ %b() %a+ ', '') + local set_value = minetest.setting_get(name) + result[name] = set_value or default_value + end + end + + return result +end + +local _options = _mtimer_get_options() + +local interval = _options['mtimer_update_interval'] +local placeholder = _options['mtimer_placeholder'] +local font_color = _options['mtimer_font_color'] local format = { - locale = _xtend.g('mtimer_locale'), - start = _xtend.g('mtimer_session_start'), - runtime = _xtend.g('mtimer_session_runtime'), - current = _xtend.g('mtimer_current_time'), - ingame = _xtend.g('mtimer_ingame_time'), - output = _xtend.g('mtimer_output_format') + locale = _options['mtimer_locale'], + start = _options['mtimer_session_start'], + runtime = _options['mtimer_session_runtime'], + current = _options['mtimer_current_time'], + ingame = _options['mtimer_ingame_time'], + output = _options['mtimer_output_format'] } local location = { - position = _mtimer_location_value(_xtend.g('mtimer_position')), - alignment = _mtimer_location_value(_xtend.g('mtimer_alignment')), - offset = _mtimer_location_value(_xtend.g('mtimer_offset')) + position = _mtimer_location_value(_options['mtimer_position']), + alignment = _mtimer_location_value(_options['mtimer_alignment']), + offset = _mtimer_location_value(_options['mtimer_offset']) } local playerData = {}