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  
7 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 28 ## [0.18.1] - 2020-06-06
10 29 Based on user feedback updated the mod
11 30 ### Added
... ...
calcui-styles.lua
... ... @@ -64,6 +64,13 @@ data:extend({
64 64 },
65 65 {
66 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 74 name = "sprite_calcui_calculator",
68 75 filename = "__calculator-ui__/graphics/calculator.png",
69 76 width = 64,
... ...
calculator.lua
... ... @@ -6,6 +6,19 @@ local function get_gui_root(player)
6 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 22 function show_rant(player, enabled)
10 23 local root = get_gui_root(player)
11 24  
... ... @@ -218,21 +231,30 @@ function fix_equation(equation)
218 231 ["acos"] = "math.acos",
219 232 ["asin"] = "math.asin",
220 233 ["atan"] = "math.atan",
  234 + ["atan2"] = "math.atan2",
221 235 ["ceil"] = "math.ceil",
222 236 ["floor"] = "math.floor",
223 237 ["cos"] = "math.cos",
  238 + ["cosh"] = "math.cosh",
224 239 ["sin"] = "math.sin",
  240 + ["sinh"] = "math.sinh",
225 241 ["tan"] = "math.tan",
  242 + ["tanh"] = "math.tanh",
226 243 ["deg"] = "math.deg",
227 244 ["rad"] = "math.rad",
228 245 ["exp"] = "math.exp",
229 246 ["log"] = "math.log",
  247 + ["log10"] = "math.log10",
230 248 ["min"] = "math.min",
231 249 ["max"] = "math.max",
232 250 ["modf"] = "math.modf",
  251 + ["fmod"] = "math.fmod",
  252 + ["frexp"] = "math.frexp",
  253 + ["ldexp"] = "math.ldexp",
233 254 ["sqrt"] = "math.sqrt",
234 255 ["huge"] = "math.huge",
235   - ["pi"] = "math.pi"
  256 + ["pi"] = "math.pi",
  257 + ["pow"] = "math.pow"
236 258 }
237 259 for key, val in pairs(math_lib) do
238 260 result = result:gsub(key, val)
... ... @@ -243,6 +265,7 @@ function fix_equation(equation)
243 265  
244 266 -- fix danish keyboard
245 267 result = result:gsub(",", ".")
  268 + result = result:gsub(";", ",")
246 269  
247 270 return result
248 271 end
... ... @@ -263,13 +286,17 @@ function process_equal_key(player, button)
263 286 return load("return " .. equation)()
264 287 end)
265 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 300 if retval_show == nil or retval_show == "" then
274 301 status = false
275 302 end
... ... @@ -278,7 +305,7 @@ function process_equal_key(player, button)
278 305 show_rant(player, true)
279 306 else
280 307 if retval <= 0 then
281   - show_rant(player, true)
  308 + show_think(player, true)
282 309 else
283 310 show_rant(player, false)
284 311 end
... ...
graphics/nilausThink.png 0 → 100644

7.77 KB

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