From d7b81613e1463d726805473d936896815f7bc07c Mon Sep 17 00:00:00 2001 From: Wichu Date: Sat, 6 Jun 2020 22:19:01 +0200 Subject: [PATCH] Minor fixed - release as 0.18.2 --- CHANGELOG.md | 19 +++++++++++++++++++ calcui-styles.lua | 7 +++++++ calculator.lua | 45 ++++++++++++++++++++++++++++++++++++--------- graphics/nilausThink.png | Bin 0 -> 7961 bytes info.json | 2 +- 5 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 graphics/nilausThink.png diff --git a/CHANGELOG.md b/CHANGELOG.md index 0847a17..f6b42be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,25 @@ and this project adheres to the versioning of Factorio, so 0.18.x will be at lea ## [Released] +## [0.18.2] - 2020-06-06 +Based on user feedback updated the mod +### Added +- new easter egg :-) +- added more math.lib functions + - atan2() -> math.atan2() + - cosh() -> math.cosh() + - sinh() -> math.sinh() + - tanh() -> math.tanh() + - log10() -> math.log10() + - fmod() -> math.fmod() + - frexp() -> math.frexp() + - ldexp() -> math.ldexp() + - pow() -> math.pow() + +### Fixed +- Interpreting ";" as "," in the equation, because of the fix in 0.18.1, so that math functions with more than 1 parameter work. They have to use ";" as a separator for inputs +- Fixed sqrt(-1) equaling "na" because of the rounding fix from 0.18.1. It does now show "NaN" again + ## [0.18.1] - 2020-06-06 Based on user feedback updated the mod ### Added diff --git a/calcui-styles.lua b/calcui-styles.lua index a19b393..9111c3c 100644 --- a/calcui-styles.lua +++ b/calcui-styles.lua @@ -64,6 +64,13 @@ data:extend({ }, { type = "sprite", + name = "sprite_calcui_think", + filename = "__calculator-ui__/graphics/nilausThink.png", + width = 56, + height = 56 + }, + { + type = "sprite", name = "sprite_calcui_calculator", filename = "__calculator-ui__/graphics/calculator.png", width = 64, diff --git a/calculator.lua b/calculator.lua index 1d3af5a..34448dc 100644 --- a/calculator.lua +++ b/calculator.lua @@ -6,6 +6,19 @@ local function get_gui_root(player) end -- ---------------------------------------------------------------- +function show_think(player, enabled) + local root = get_gui_root(player) + + if enabled then + root.calcui.calcui_table.calcui_table_col2.calcui_rant.sprite = "sprite_calcui_think" + root.calcui.calcui_table.calcui_table_col2.calcui_scroll_pane.style.height = 196 + else + root.calcui.calcui_table.calcui_table_col2.calcui_rant.sprite = nil + root.calcui.calcui_table.calcui_table_col2.calcui_scroll_pane.style.height = 252 + end +end + +-- ---------------------------------------------------------------- function show_rant(player, enabled) local root = get_gui_root(player) @@ -218,21 +231,30 @@ function fix_equation(equation) ["acos"] = "math.acos", ["asin"] = "math.asin", ["atan"] = "math.atan", + ["atan2"] = "math.atan2", ["ceil"] = "math.ceil", ["floor"] = "math.floor", ["cos"] = "math.cos", + ["cosh"] = "math.cosh", ["sin"] = "math.sin", + ["sinh"] = "math.sinh", ["tan"] = "math.tan", + ["tanh"] = "math.tanh", ["deg"] = "math.deg", ["rad"] = "math.rad", ["exp"] = "math.exp", ["log"] = "math.log", + ["log10"] = "math.log10", ["min"] = "math.min", ["max"] = "math.max", ["modf"] = "math.modf", + ["fmod"] = "math.fmod", + ["frexp"] = "math.frexp", + ["ldexp"] = "math.ldexp", ["sqrt"] = "math.sqrt", ["huge"] = "math.huge", - ["pi"] = "math.pi" + ["pi"] = "math.pi", + ["pow"] = "math.pow" } for key, val in pairs(math_lib) do result = result:gsub(key, val) @@ -243,6 +265,7 @@ function fix_equation(equation) -- fix danish keyboard result = result:gsub(",", ".") + result = result:gsub(";", ",") return result end @@ -263,13 +286,17 @@ function process_equal_key(player, button) return load("return " .. equation)() end) root.calcui.calcui_table.calcui_table_col2.calcui_display_result.tooltip = retval - status, retval_show = pcall(function() - local result = string.format("%0." .. settings.get_player_settings(player)["calcui-decimal-places"].value .. "f", retval) - if result:len() > tostring(retval):len() then - result = retval - end - return result - end) + if not (retval == math.huge or retval ~= retval) then + status, retval_show = pcall(function() + local result = string.format("%0." .. settings.get_player_settings(player)["calcui-decimal-places"].value .. "f", retval) + if result:len() > tostring(retval):len() then + result = retval + end + return result + end) + else + status = false + end if retval_show == nil or retval_show == "" then status = false end @@ -278,7 +305,7 @@ function process_equal_key(player, button) show_rant(player, true) else if retval <= 0 then - show_rant(player, true) + show_think(player, true) else show_rant(player, false) end diff --git a/graphics/nilausThink.png b/graphics/nilausThink.png new file mode 100644 index 0000000..56c163a Binary files /dev/null and b/graphics/nilausThink.png differ diff --git a/info.json b/info.json index cc51c76..e6e7215 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "calculator-ui", - "version": "0.18.1", + "version": "0.18.2", "title": "Calculator UI", "author": "Wichu", "factorio_version": "0.18", -- libgit2 0.22.2