diff --git a/README.md b/README.md index f58f047..5f742ef 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Well ... ehm ... search for the mod ingame and install it :-) Press the 3 little dots on the shortcuts UI of Factorio to select the "Calculator". Afterwards you can click on the calculator symbol to open it. ## Changelog -see separate [changelog](CHANGELOG.md) +see separate [changelog](changelog.txt) ## License [MIT](https://choosealicense.com/licenses/mit/) \ No newline at end of file diff --git a/calculator.lua b/calculator.lua index 21fdd5c..0fd496b 100644 --- a/calculator.lua +++ b/calculator.lua @@ -5,8 +5,8 @@ local function get_gui_root(player) return player.gui.screen end -local nilaus_think = { "calcui_nilaus_really", "calcui_nilaus_ugghhhh" } -local nilaus_rant = { "calcui_nilaus_fuck1", "calcui_nilaus_fuck2", "calcui_nilaus_fuck3" } +local nilaus_think = { "calcui_nilaus_really" } +local nilaus_rant = { "calcui_nilaus_ugghhhh", "utility/cannot_build" } -- ---------------------------------------------------------------- local function play_sfx(player, sfx) @@ -387,6 +387,19 @@ local function fix_equation(equation, root) end -- fix percentage + -- complex equations like "20+10%" = 22, before it was 20.1 -- big thanks to GWulf + result = result:gsub("(%d+)(.)(%d+)%%", function (base, sign, perc) + if sign == "+" then + return base .. "*1." .. perc + elseif sign == "-" then + return base .. "*(1-0." ..perc .. ")" + elseif sign == "*" then + return "(" .. base .. "/100)*" .. perc + elseif sign == "/" then + return "(" .. base .. "*100)/" .. perc + end + end) + -- still the simple equation needs some work: 1% = 0.01 result = result:gsub("(%%)", "/100") -- fix danish keyboard diff --git a/CHANGELOG.md b/changelog.txt index 3025471..0d431e2 100644 --- a/CHANGELOG.md +++ b/changelog.txt @@ -1,126 +1,122 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to the versioning of Factorio, so 0.18.x will be at least compatible / tested with Factorio 0.18.x. - -## [Released] - -## [0.18.5] - 2020-06-08 -Added some fancy sound effects and a special [Nilaus](https://www.youtube.com/c/Nilaus) mode. - -### Added -- Added sound effects to the calculator whenever a result may be not the desired one (has be enabled in the settings) - -### Changed -- Emotes will no longer be displayed at default, "Nilaus mode" has to be enabled for the emotes to appear again - -### Fixed -- Recent results weren't properly cleared in 0.18.4 - -### Misc -- Some code rework, not too fancy stuff - -## [0.18.4] - 2020-06-07 -### General -Based on user feedback updated the mod - -### Added -- Added the possibility to copy the results (from recent and also the current) to the display - -### Changed -- Window now remember last location when opened -- Updated the BS button (it's backspace people...) so it now has a nice icon instead of the letters -- Recent results now add to the top, instead of the bottom -- When calculator is opened it focues on the display for entering the equation -- You can click pretty much anywhere now and it focues on the display for entering the equation - -### Fixed -- On multiplayer session the window would lag behind while dragging, because the location would be saved on server. This isn't going to happen anymore, hopefully (not tested yet). -- When window is moved out of boundaries, when reopened, it will correct itself to be fully in sight again. -- Settings had weird default values (were set 2 times) - -## [0.18.3] - 2020-06-07 -### General -A small visual overhaul of the mod -### Added -- Added the possibility to "calculate further" (especially usefull when setting "Clear equation on calculation" is set). When the equation doesn't start with a number, character or parenthesis (so it assumes it starts with a math symbol) it will take the previous result and prepend it to the current equation. - -### Changed -- Updated the UI a bit to match it in color a bit more to the Windows calculator -- Updated also the icon on the shortcut to better distinguish it - -## [0.18.2] - 2020-06-06 -### General -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 -### General -Based on user feedback updated the mod - -### Added -- Shortcut for opening the calculator and automatically focus on the input (Default: Ctrl+Shift+C) - -### Fixed -- Rounding removed 0 at the end, will now stand as it should. So 2.0000001 -> 2.00 -- Interpreting "," as "." in the equation, because of some European countries do have a weird keyboard layout - -## [0.18.0] - 2020-06-06 -### General -- Initial Release of the mod -- Compatible with Factorio >0.18.0; tested on 0.18.30 -- Based on the 4-Function Calculator found in the [Max Rate Calculator](https://mods.factorio.com/mod/MaxRateCalculator) mod by [Theanderblast](https://mods.factorio.com/user/theanderblast) - -### Added -- History of recent calculations -- Possibility to copy recent calculations to the current one (with shift+left-click) -- Substitutes some functions & "constants" of the Lua [math-lib](http://lua-users.org/wiki/MathLibraryTutorial) - - abs() -> math.abs() - - acos() -> math.acos() - - asin() -> math.asin() - - atan() -> math.atan() - - ceil() -> math.ceil() - - floor() -> math.floor() - - cos() -> math.cos() - - sin() -> math.sin() - - tan() -> math.tan() - - deg() -> math.deg() - - rad() -> math.rad() - - exp() -> math.exp() - - log() -> math.log() - - min() -> math.min() - - max() -> math.max() - - modf() -> math.modf() - - sqrt() -> math.sqrt() - - huge -> math.huge - - pi -> math.pi -- Allows the use of "%" (percent sign) in the calculation -- A little easter egg :-) -- Setting for number of decimal places in result (Default: 2). Exact value will be displayed in the tooltip -- Setting if triggering the calculation should clear the current equation (Default: no) - -### Changed -- Made the buttons slightly bigger, so that it's better readable on streams. -- Allows to make "complex" calculations with parentheses -- Allows pretty much all characters in the equation field - - but the "=" (equal sign) will trigger the calculation - -### Removed -- Got rid of the memory functions - but introduced the list of recent calculations instead \ No newline at end of file +--------------------------------------------------------------------------------------------------- +Version: 0.18.6 +Date: 2020-06-11 + Fixed: + - Percentage calculations fixed; big thanks to GWulf for raising the issue and also providing the fix for it <3 + +--------------------------------------------------------------------------------------------------- +Version: 0.18.5 +Date: 2020-06-08 + General: + - Added some fancy sound effects and a special [Nilaus](https://www.youtube.com/c/Nilaus) mode. + Added: + - Added sound effects to the calculator whenever a result may be not the desired one (has be enabled in the settings) + Changed: + - Emotes will no longer be displayed at default, "Nilaus mode" has to be enabled for the emotes to appear again + Fixed: + - Recent results weren't properly cleared in 0.18.4 + Misc: + - Some code rework, not too fancy stuff + +--------------------------------------------------------------------------------------------------- +Version: 0.18.4 +Date: 2020-06-07 + General: + - Based on user feedback updated the mod + Added: + - Added the possibility to copy the results (from recent and also the current) to the display + Changed: + - Window now remember last location when opened + - Updated the BS button (it's backspace people...) so it now has a nice icon instead of the letters + - Recent results now add to the top, instead of the bottom + - When calculator is opened it focues on the display for entering the equation + - You can click pretty much anywhere now and it focues on the display for entering the equation + Fixed: + - On multiplayer session the window would lag behind while dragging, because the location would be saved on server. This isn't going to happen anymore, hopefully (not tested yet). + - When window is moved out of boundaries, when reopened, it will correct itself to be fully in sight again. + - Settings had weird default values (were set 2 times) + +--------------------------------------------------------------------------------------------------- +Version: 0.18.3 +Date: 2020-06-07 + General: + - A small visual overhaul of the mod + Added: + - Added the possibility to "calculate further" (especially usefull when setting "Clear equation on calculation" is set). When the equation doesn't start with a number, character or parenthesis (so it assumes it starts with a math symbol) it will take the previous result and prepend it to the current equation. + Changed: + - Updated the UI a bit to match it in color a bit more to the Windows calculator + - Updated also the icon on the shortcut to better distinguish it + +--------------------------------------------------------------------------------------------------- +Version: 0.18.2 +Date: 2020-06-06 + General: + - 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 + +--------------------------------------------------------------------------------------------------- +Version: 0.18.1 +Date: 2020-06-06 + General: + - Based on user feedback updated the mod + Added: + - Shortcut for opening the calculator and automatically focus on the input (Default: Ctrl+Shift+C) + Fixed: + - Rounding removed 0 at the end, will now stand as it should. So 2.0000001 -> 2.00 + - Interpreting "," as "." in the equation, because of some European countries do have a weird keyboard layout + +--------------------------------------------------------------------------------------------------- +Version: 0.18.0 +Date: 2020-06-06 + General: + - Initial Release of the mod + - Compatible with Factorio >0.18.0; tested on 0.18.30 + - Based on the 4-Function Calculator found in the [Max Rate Calculator](https://mods.factorio.com/mod/MaxRateCalculator) mod by [Theanderblast](https://mods.factorio.com/user/theanderblast) + Added: + - History of recent calculations + - Possibility to copy recent calculations to the current one (with shift+left-click) + - Substitutes some functions & "constants" of the Lua [math-lib](http://lua-users.org/wiki/MathLibraryTutorial) + - abs() -> math.abs() + - acos() -> math.acos() + - asin() -> math.asin() + - atan() -> math.atan() + - ceil() -> math.ceil() + - floor() -> math.floor() + - cos() -> math.cos() + - sin() -> math.sin() + - tan() -> math.tan() + - deg() -> math.deg() + - rad() -> math.rad() + - exp() -> math.exp() + - log() -> math.log() + - min() -> math.min() + - max() -> math.max() + - modf() -> math.modf() + - sqrt() -> math.sqrt() + - huge -> math.huge + - pi -> math.pi + - Allows the use of "%" (percent sign) in the calculation + - A little easter egg :-) + - Setting for number of decimal places in result (Default: 2). Exact value will be displayed in the tooltip + - Setting if triggering the calculation should clear the current equation (Default: no) + Changed: + - Made the buttons slightly bigger, so that it's better readable on streams. + - Allows to make "complex" calculations with parentheses + - Allows pretty much all characters in the equation field + - but the "=" (equal sign) will trigger the calculation + Removed: + - Got rid of the memory functions - but introduced the list of recent calculations instead \ No newline at end of file diff --git a/sounds/homeImprovement.ogg b/sounds/homeImprovement.ogg index 2257fd6..36c9bbc 100644 --- a/sounds/homeImprovement.ogg +++ b/sounds/homeImprovement.ogg diff --git a/sounds/homeImprovement.xmp b/sounds/homeImprovement.xmp index b807747..248a4ec 100644 --- a/sounds/homeImprovement.xmp +++ b/sounds/homeImprovement.xmp @@ -2,34 +2,15 @@ - - - - CuePoint Markers - Cue - f44100 - - - CD Track Markers - Track - f44100 - - - Subclip Markers - InOut - f44100 - - - - 2020-06-08T22:48:45+02:00 - 2020-06-08T22:48:45+02:00 - xmp.iid:348e6d2e-d8a6-df45-9e77-8ef3de39a2a9 + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:xmpDM="http://ns.adobe.com/xmp/1.0/DynamicMedia/"> + 2020-06-11T21:27:59+02:00 + 2020-06-11T21:27:59+02:00 + xmp.iid:441f611f-aa4a-c046-8fb0-a5571e0bb4dc xmp.did:348e6d2e-d8a6-df45-9e77-8ef3de39a2a9 xmp.did:8b6d840b-f07a-aa4f-9a1d-d8ddd54194ee @@ -48,6 +29,20 @@ Adobe Audition 13.0 (Windows) / + + saved + xmp.iid:af16a411-701d-3449-87de-83e3753690bd + 2020-06-11T21:27:59+02:00 + Adobe Audition 13.0 (Windows) + /metadata + + + saved + xmp.iid:441f611f-aa4a-c046-8fb0-a5571e0bb4dc + 2020-06-11T21:27:59+02:00 + Adobe Audition 13.0 (Windows) + / + @@ -56,6 +51,25 @@ xmp.did:8b6d840b-f07a-aa4f-9a1d-d8ddd54194ee audio/ogg; codec="vorbis" + + + + CuePoint Markers + Cue + f44100 + + + CD Track Markers + Track + f44100 + + + Subclip Markers + InOut + f44100 + + + diff --git a/sounds/nilausFuck1.ogg b/sounds/nilausFuck1.ogg index 82a1b8f..7c2dd0c 100644 --- a/sounds/nilausFuck1.ogg +++ b/sounds/nilausFuck1.ogg diff --git a/sounds/nilausFuck1.xmp b/sounds/nilausFuck1.xmp index e91b4f2..ea5a134 100644 --- a/sounds/nilausFuck1.xmp +++ b/sounds/nilausFuck1.xmp @@ -10,8 +10,8 @@ xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:dc="http://purl.org/dc/elements/1.1/"> 1904-01-01T00:00Z - 2020-06-08T22:51:31+02:00 - 2020-06-08T22:51:31+02:00 + 2020-06-11T21:27:52+02:00 + 2020-06-11T21:27:52+02:00 28000 1/1000 @@ -36,7 +36,7 @@ 1 - xmp.iid:19f54cb5-05b0-bd45-9512-cc051c7c1549 + xmp.iid:6fa34f64-9809-0c43-acf6-d2f715443d03 xmp.did:19f54cb5-05b0-bd45-9512-cc051c7c1549 xmp.did:e08c1858-6717-7d41-8e0f-68619fef6920 @@ -55,6 +55,20 @@ Adobe Audition 13.0 (Windows) / + + saved + xmp.iid:5277fef7-a811-ea46-9e77-1960972d00e9 + 2020-06-11T21:27:52+02:00 + Adobe Audition 13.0 (Windows) + /metadata + + + saved + xmp.iid:6fa34f64-9809-0c43-acf6-d2f715443d03 + 2020-06-11T21:27:52+02:00 + Adobe Audition 13.0 (Windows) + / + diff --git a/sounds/nilausFuck2.ogg b/sounds/nilausFuck2.ogg index 39bc206..135e045 100644 --- a/sounds/nilausFuck2.ogg +++ b/sounds/nilausFuck2.ogg diff --git a/sounds/nilausFuck2.xmp b/sounds/nilausFuck2.xmp index 8d77a4d..e55a069 100644 --- a/sounds/nilausFuck2.xmp +++ b/sounds/nilausFuck2.xmp @@ -10,8 +10,8 @@ xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:dc="http://purl.org/dc/elements/1.1/"> 1904-01-01T00:00Z - 2020-06-08T22:53:49+02:00 - 2020-06-08T22:53:49+02:00 + 2020-06-11T21:27:48+02:00 + 2020-06-11T21:27:48+02:00 9250 1/1000 @@ -36,7 +36,7 @@ 1 - xmp.iid:88c525af-9cae-674c-9801-4a2338864f83 + xmp.iid:3bd395ca-aad3-d64b-b5b7-1b0ecac2538f xmp.did:88c525af-9cae-674c-9801-4a2338864f83 xmp.did:4eb6adb6-83de-d64e-ad4a-814c729baa62 @@ -55,6 +55,20 @@ Adobe Audition 13.0 (Windows) / + + saved + xmp.iid:f1084259-ffda-ab43-b4b7-b1454017ccf3 + 2020-06-11T21:27:48+02:00 + Adobe Audition 13.0 (Windows) + /metadata + + + saved + xmp.iid:3bd395ca-aad3-d64b-b5b7-1b0ecac2538f + 2020-06-11T21:27:48+02:00 + Adobe Audition 13.0 (Windows) + / + diff --git a/sounds/nilausFuck3.ogg b/sounds/nilausFuck3.ogg index 11e1519..5fcbe14 100644 --- a/sounds/nilausFuck3.ogg +++ b/sounds/nilausFuck3.ogg diff --git a/sounds/nilausFuck3.xmp b/sounds/nilausFuck3.xmp index 3fc6c9a..84fc1fe 100644 --- a/sounds/nilausFuck3.xmp +++ b/sounds/nilausFuck3.xmp @@ -10,8 +10,8 @@ xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:dc="http://purl.org/dc/elements/1.1/"> 1904-01-01T00:00Z - 2020-06-08T22:55:39+02:00 - 2020-06-08T22:55:39+02:00 + 2020-06-11T21:27:28+02:00 + 2020-06-11T21:27:28+02:00 55104 1/1000 @@ -36,7 +36,7 @@ 1 - xmp.iid:63049797-52fc-df4b-993e-4bc5ff8d05e3 + xmp.iid:f3c40aa8-8b36-1c48-b05c-91c5ef9d5382 xmp.did:63049797-52fc-df4b-993e-4bc5ff8d05e3 xmp.did:e4d64a27-8ddd-f244-b27c-e0ca8738bbbb @@ -55,6 +55,20 @@ Adobe Audition 13.0 (Windows) / + + saved + xmp.iid:92db2310-a99d-794a-985d-dbd76356f20d + 2020-06-11T21:27:28+02:00 + Adobe Audition 13.0 (Windows) + /metadata + + + saved + xmp.iid:f3c40aa8-8b36-1c48-b05c-91c5ef9d5382 + 2020-06-11T21:27:28+02:00 + Adobe Audition 13.0 (Windows) + / + diff --git a/sounds/nilausReally.ogg b/sounds/nilausReally.ogg index dff853d..55b6961 100644 --- a/sounds/nilausReally.ogg +++ b/sounds/nilausReally.ogg diff --git a/sounds/nilausReally.xmp b/sounds/nilausReally.xmp index e497a1c..866bfc3 100644 --- a/sounds/nilausReally.xmp +++ b/sounds/nilausReally.xmp @@ -10,8 +10,8 @@ xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:dc="http://purl.org/dc/elements/1.1/"> 1904-01-01T00:00Z - 2020-06-08T22:56:47+02:00 - 2020-06-08T22:56:47+02:00 + 2020-06-11T21:27:26+02:00 + 2020-06-11T21:27:26+02:00 20715 1/1000 @@ -36,7 +36,7 @@ 1 - xmp.iid:a12c3623-760d-1e41-8f2a-672b53d6b765 + xmp.iid:ce3279e1-4802-5347-bcff-9a6c33d80c85 xmp.did:a12c3623-760d-1e41-8f2a-672b53d6b765 xmp.did:a335e3fb-695e-674b-9904-32f8d742164f @@ -55,6 +55,20 @@ Adobe Audition 13.0 (Windows) / + + saved + xmp.iid:9d325b53-f75e-1246-8a27-42ca0d516535 + 2020-06-11T21:27:26+02:00 + Adobe Audition 13.0 (Windows) + /metadata + + + saved + xmp.iid:ce3279e1-4802-5347-bcff-9a6c33d80c85 + 2020-06-11T21:27:26+02:00 + Adobe Audition 13.0 (Windows) + / + diff --git a/sounds/nilausUgghhhh.ogg b/sounds/nilausUgghhhh.ogg index d4bf372..a975342 100644 --- a/sounds/nilausUgghhhh.ogg +++ b/sounds/nilausUgghhhh.ogg diff --git a/sounds/nilausUgghhhh.xmp b/sounds/nilausUgghhhh.xmp index e606a9a..830c587 100644 --- a/sounds/nilausUgghhhh.xmp +++ b/sounds/nilausUgghhhh.xmp @@ -10,8 +10,8 @@ xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:dc="http://purl.org/dc/elements/1.1/"> 1904-01-01T00:00Z - 2020-06-08T22:52:37+02:00 - 2020-06-08T22:52:37+02:00 + 2020-06-11T21:27:24+02:00 + 2020-06-11T21:27:24+02:00 5952 1/1000 @@ -36,7 +36,7 @@ 1 - xmp.iid:1a789f0f-2049-7541-ba6c-b39c82cd9d35 + xmp.iid:f2eea28f-91fd-0440-8a5e-05000636daba xmp.did:1a789f0f-2049-7541-ba6c-b39c82cd9d35 xmp.did:aeb5b9ad-7d85-764f-aa5d-4349d913404f @@ -55,6 +55,20 @@ Adobe Audition 13.0 (Windows) / + + saved + xmp.iid:70ac829b-03e4-d844-9c2e-df8b9065fae3 + 2020-06-11T21:27:24+02:00 + Adobe Audition 13.0 (Windows) + /metadata + + + saved + xmp.iid:f2eea28f-91fd-0440-8a5e-05000636daba + 2020-06-11T21:27:24+02:00 + Adobe Audition 13.0 (Windows) + / +