Commit d7b81613e1463d726805473d936896815f7bc07c

Authored by Stefan Wichmann
1 parent c6cb1d22

Minor fixed - release as 0.18.2

CHANGELOG.md
@@ -6,6 +6,25 @@ and this project adheres to the versioning of Factorio, so 0.18.x will be at lea @@ -6,6 +6,25 @@ and this project adheres to the versioning of Factorio, so 0.18.x will be at lea
6 6
7 ## [Released] 7 ## [Released]
8 8
  9 +## [0.18.2] - 2020-06-06
  10 +Based on user feedback updated the mod
  11 +### Added
  12 +- new easter egg :-)
  13 +- added more math.lib functions
  14 + - atan2() -> math.atan2()
  15 + - cosh() -> math.cosh()
  16 + - sinh() -> math.sinh()
  17 + - tanh() -> math.tanh()
  18 + - log10() -> math.log10()
  19 + - fmod() -> math.fmod()
  20 + - frexp() -> math.frexp()
  21 + - ldexp() -> math.ldexp()
  22 + - pow() -> math.pow()
  23 +
  24 +### Fixed
  25 +- 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
  26 +- Fixed sqrt(-1) equaling "na" because of the rounding fix from 0.18.1. It does now show "NaN" again
  27 +
9 ## [0.18.1] - 2020-06-06 28 ## [0.18.1] - 2020-06-06
10 Based on user feedback updated the mod 29 Based on user feedback updated the mod
11 ### Added 30 ### Added
calcui-styles.lua
@@ -64,6 +64,13 @@ data:extend({ @@ -64,6 +64,13 @@ data:extend({
64 }, 64 },
65 { 65 {
66 type = "sprite", 66 type = "sprite",
  67 + name = "sprite_calcui_think",
  68 + filename = "__calculator-ui__/graphics/nilausThink.png",
  69 + width = 56,
  70 + height = 56
  71 + },
  72 + {
  73 + type = "sprite",
67 name = "sprite_calcui_calculator", 74 name = "sprite_calcui_calculator",
68 filename = "__calculator-ui__/graphics/calculator.png", 75 filename = "__calculator-ui__/graphics/calculator.png",
69 width = 64, 76 width = 64,
calculator.lua
@@ -6,6 +6,19 @@ local function get_gui_root(player) @@ -6,6 +6,19 @@ local function get_gui_root(player)
6 end 6 end
7 7
8 -- ---------------------------------------------------------------- 8 -- ----------------------------------------------------------------
  9 +function show_think(player, enabled)
  10 + local root = get_gui_root(player)
  11 +
  12 + if enabled then
  13 + root.calcui.calcui_table.calcui_table_col2.calcui_rant.sprite = "sprite_calcui_think"
  14 + root.calcui.calcui_table.calcui_table_col2.calcui_scroll_pane.style.height = 196
  15 + else
  16 + root.calcui.calcui_table.calcui_table_col2.calcui_rant.sprite = nil
  17 + root.calcui.calcui_table.calcui_table_col2.calcui_scroll_pane.style.height = 252
  18 + end
  19 +end
  20 +
  21 +-- ----------------------------------------------------------------
9 function show_rant(player, enabled) 22 function show_rant(player, enabled)
10 local root = get_gui_root(player) 23 local root = get_gui_root(player)
11 24
@@ -218,21 +231,30 @@ function fix_equation(equation) @@ -218,21 +231,30 @@ function fix_equation(equation)
218 ["acos"] = "math.acos", 231 ["acos"] = "math.acos",
219 ["asin"] = "math.asin", 232 ["asin"] = "math.asin",
220 ["atan"] = "math.atan", 233 ["atan"] = "math.atan",
  234 + ["atan2"] = "math.atan2",
221 ["ceil"] = "math.ceil", 235 ["ceil"] = "math.ceil",
222 ["floor"] = "math.floor", 236 ["floor"] = "math.floor",
223 ["cos"] = "math.cos", 237 ["cos"] = "math.cos",
  238 + ["cosh"] = "math.cosh",
224 ["sin"] = "math.sin", 239 ["sin"] = "math.sin",
  240 + ["sinh"] = "math.sinh",
225 ["tan"] = "math.tan", 241 ["tan"] = "math.tan",
  242 + ["tanh"] = "math.tanh",
226 ["deg"] = "math.deg", 243 ["deg"] = "math.deg",
227 ["rad"] = "math.rad", 244 ["rad"] = "math.rad",
228 ["exp"] = "math.exp", 245 ["exp"] = "math.exp",
229 ["log"] = "math.log", 246 ["log"] = "math.log",
  247 + ["log10"] = "math.log10",
230 ["min"] = "math.min", 248 ["min"] = "math.min",
231 ["max"] = "math.max", 249 ["max"] = "math.max",
232 ["modf"] = "math.modf", 250 ["modf"] = "math.modf",
  251 + ["fmod"] = "math.fmod",
  252 + ["frexp"] = "math.frexp",
  253 + ["ldexp"] = "math.ldexp",
233 ["sqrt"] = "math.sqrt", 254 ["sqrt"] = "math.sqrt",
234 ["huge"] = "math.huge", 255 ["huge"] = "math.huge",
235 - ["pi"] = "math.pi" 256 + ["pi"] = "math.pi",
  257 + ["pow"] = "math.pow"
236 } 258 }
237 for key, val in pairs(math_lib) do 259 for key, val in pairs(math_lib) do
238 result = result:gsub(key, val) 260 result = result:gsub(key, val)
@@ -243,6 +265,7 @@ function fix_equation(equation) @@ -243,6 +265,7 @@ function fix_equation(equation)
243 265
244 -- fix danish keyboard 266 -- fix danish keyboard
245 result = result:gsub(",", ".") 267 result = result:gsub(",", ".")
  268 + result = result:gsub(";", ",")
246 269
247 return result 270 return result
248 end 271 end
@@ -263,13 +286,17 @@ function process_equal_key(player, button) @@ -263,13 +286,17 @@ function process_equal_key(player, button)
263 return load("return " .. equation)() 286 return load("return " .. equation)()
264 end) 287 end)
265 root.calcui.calcui_table.calcui_table_col2.calcui_display_result.tooltip = retval 288 root.calcui.calcui_table.calcui_table_col2.calcui_display_result.tooltip = retval
266 - status, retval_show = pcall(function()  
267 - local result = string.format("%0." .. settings.get_player_settings(player)["calcui-decimal-places"].value .. "f", retval)  
268 - if result:len() > tostring(retval):len() then  
269 - result = retval  
270 - end  
271 - return result  
272 - end) 289 + if not (retval == math.huge or retval ~= retval) then
  290 + status, retval_show = pcall(function()
  291 + local result = string.format("%0." .. settings.get_player_settings(player)["calcui-decimal-places"].value .. "f", retval)
  292 + if result:len() > tostring(retval):len() then
  293 + result = retval
  294 + end
  295 + return result
  296 + end)
  297 + else
  298 + status = false
  299 + end
273 if retval_show == nil or retval_show == "" then 300 if retval_show == nil or retval_show == "" then
274 status = false 301 status = false
275 end 302 end
@@ -278,7 +305,7 @@ function process_equal_key(player, button) @@ -278,7 +305,7 @@ function process_equal_key(player, button)
278 show_rant(player, true) 305 show_rant(player, true)
279 else 306 else
280 if retval <= 0 then 307 if retval <= 0 then
281 - show_rant(player, true) 308 + show_think(player, true)
282 else 309 else
283 show_rant(player, false) 310 show_rant(player, false)
284 end 311 end
graphics/nilausThink.png 0 → 100644

7.77 KB

info.json
1 { 1 {
2 "name": "calculator-ui", 2 "name": "calculator-ui",
3 - "version": "0.18.1", 3 + "version": "0.18.2",
4 "title": "Calculator UI", 4 "title": "Calculator UI",
5 "author": "Wichu", 5 "author": "Wichu",
6 "factorio_version": "0.18", 6 "factorio_version": "0.18",