From 4af1d1ded70727e2e6217b77df74c8d0d6e0bfcc Mon Sep 17 00:00:00 2001 From: Afforess Date: Mon, 2 Nov 2015 18:20:36 -0500 Subject: [PATCH] Add missing locale text Fix misnamed parameter / variable in remote_sensor.lua (style -> color) Simplify font color code in template.lua --- locale/en/locale.cfg | 5 +++++ remote.lua | 12 ++++++------ value_sensors/remote_sensor.lua | 4 ++-- value_sensors/template.lua | 10 ++-------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index 96d4a3f..a0c9a34 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -78,3 +78,8 @@ err_settings_whatsettings=__1__ called for settings-less sensor! err_needplayername=[EvoGUI] Need a player name! err_nosuchplayer=[EvoGUI] No such player: __1__! err_noplayerdata=[EvoGUI] No player data for __1__! + +err_nosensorname=[EvoGUI] Missing a sensor name! +err_nosensortext=[EvoGUI] Missing sensor text for __1__! +err_nosensorcaption=[EvoGUI] Missing caption text for __1__! +err_nosensorfound=[EvoGUI] No sensor was previously created matching the name __1__! Create a sensor first. diff --git a/remote.lua b/remote.lua index 2e08528..c8968e5 100644 --- a/remote.lua +++ b/remote.lua @@ -45,12 +45,12 @@ local function create_remote_sensor(sensor_name, sensor_text, sensor_caption, se end if not sensor_text then - evogui.log({"err_nosensortext"}) + evogui.log({"err_nosensortext", sensor_name}) return end if not sensor_caption then - evogui.log({"err_nosensorcaption"}) + evogui.log({"err_nosensorcaption", sensor_name}) return end @@ -70,13 +70,13 @@ local function update_remote_sensor(sensor_name, sensor_text, sensor_color) end if not sensor_text then - evogui.log({"err_nosensortext"}) + evogui.log({"err_nosensortext", sensor_name}) return end local sensor = RemoteSensor.get_by_name(sensor_name) if not sensor then - evogui.log({"err_nosensorfound"}) + evogui.log({"err_nosensorfound", sensor_name}) return end @@ -95,12 +95,12 @@ interface = { create_remote_sensor = function(sensor_name, sensor_text, sensor_caption, sensor_color) local status, err = pcall(create_remote_sensor, sensor_name, sensor_text, sensor_caption, sensor_color) - if err then evogui.log({"err_generic", "remote.sensor", err}) end + if err then evogui.log({"err_generic", "remote.create_remote_sensor", err}) end end, update_remote_sensor = function(sensor_name, sensor_text, sensor_color) local status, err = pcall(update_remote_sensor, sensor_name, sensor_text, sensor_color) - if err then evogui.log({"err_generic", "remote.sensor", err}) end + if err then evogui.log({"err_generic", "remote.update_remote_sensor", err}) end end } diff --git a/value_sensors/remote_sensor.lua b/value_sensors/remote_sensor.lua index 1dc57f9..b23bdb0 100644 --- a/value_sensors/remote_sensor.lua +++ b/value_sensors/remote_sensor.lua @@ -1,11 +1,11 @@ require "template" RemoteSensor = {} -function RemoteSensor.new(name, line, caption, style) +function RemoteSensor.new(name, line, caption, color) local sensor = ValueSensor.new("remote_sensor_" .. name) sensor["line"] = line sensor["display_name"] = caption - sensor["style"] = style + sensor["color"] = color function sensor:set_line(text) self.line = text diff --git a/value_sensors/template.lua b/value_sensors/template.lua index 6cdf3a0..aea25c1 100644 --- a/value_sensors/template.lua +++ b/value_sensors/template.lua @@ -9,13 +9,9 @@ function ValueSensor.new(name) ["name"] = name, ["display_name"] = { "sensor."..name..".name" }, ["format_key"] = "sensor."..name..".format", - ["color"] = nil, + ["color"] = { r = 255, g = 255, b = 255 }, } - function sensor:get_font_color() - return self.color - end - function sensor:get_line() return self.display_name end @@ -33,9 +29,7 @@ function ValueSensor.new(name) self.settings = sensor_settings owner[self.name].caption = self:get_line() - if self:get_font_color() ~= nil then - owner[self.name].style.font_color = self:get_font_color() - end + owner[self.name].style.font_color = self.color end function sensor:delete_ui(owner)