diff --git a/.luarc.json b/.luarc.json index bde783a..ff67fe2 100644 --- a/.luarc.json +++ b/.luarc.json @@ -6,6 +6,7 @@ ], "hint.enable": false, "diagnostics.globals": [ - "os" + "os", + "storage" ] } \ No newline at end of file diff --git a/changelog.txt b/changelog.txt index 37a8029..9c27787 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 2.0.0 +Date: 21-10-204 + Features: + - Support Factorio 2.0 (I did not check with Space Age playthrough, so there might be bugs!) +--------------------------------------------------------------------------------------------------- Version: 1.5.2 Date: 21-10-204 Minor Features: diff --git a/control.lua b/control.lua index 4db8e0f..4936743 100644 --- a/control.lua +++ b/control.lua @@ -18,14 +18,14 @@ local function init_new_player(index, player) -- initialize player(s) when mod is loaded into existing game player.print("init_new_player") TLBE.Config.reload({ player_index = index }) - TLBE.GUI.initialize(player, global.playerSettings[index]) + TLBE.GUI.initialize(player, storage.playerSettings[index]) player.print({ "mod-loaded" }, { r = 1, g = 0.5, b = 0 }) player.print({ "mod-loaded2" }) end local function on_init() - global.playerSettings = {} + storage.playerSettings = {} for index, player in pairs(game.players) do -- initialize player(s) when mod is loaded into existing game @@ -37,7 +37,7 @@ local function on_init() if baseBBox ~= nil then -- Update base trackers of each player for index, _ in pairs(game.players) do - local baseTracker = global.playerSettings[index].trackers[3] + local baseTracker = storage.playerSettings[index].trackers[3] baseTracker.minPos = baseBBox.minPos baseTracker.maxPos = baseBBox.maxPos TLBE.Tracker.updateCenterAndSize(baseTracker) @@ -57,7 +57,7 @@ local function on_configuration_changed(event) -- Sometimes playerSettings does not seem to be present when upgrading -- from older versions. We can just fix this issue here. for index, player in pairs(game.players) do - if global.playerSettings[index] == nil then + if storage.playerSettings[index] == nil then player.print({ "migration-fix-missing-player-data" }) init_new_player(index, player) end @@ -73,7 +73,7 @@ local function on_player_created(event) local player = game.players[event.player_index] player.print({ "mod-loaded2" }, { r = 1, g = 0.5, b = 0 }) - TLBE.GUI.initialize(player, global.playerSettings[event.player_index]) + TLBE.GUI.initialize(player, storage.playerSettings[event.player_index]) end diff --git a/graphics/logo-24.png b/graphics/logo-24.png new file mode 100644 index 0000000..55e15b0 Binary files /dev/null and b/graphics/logo-24.png differ diff --git a/graphics/logo-32.png b/graphics/logo-32.png new file mode 100644 index 0000000..f3d534a Binary files /dev/null and b/graphics/logo-32.png differ diff --git a/graphics/logo.png b/graphics/logo.png deleted file mode 100644 index 3630d67..0000000 Binary files a/graphics/logo.png and /dev/null differ diff --git a/graphics/pause-camera-24.png b/graphics/pause-camera-24.png new file mode 100644 index 0000000..cd44db7 Binary files /dev/null and b/graphics/pause-camera-24.png differ diff --git a/graphics/pause-camera-32.png b/graphics/pause-camera-32.png new file mode 100644 index 0000000..3a70e45 Binary files /dev/null and b/graphics/pause-camera-32.png differ diff --git a/graphics/pause-camera.png b/graphics/pause-camera.png deleted file mode 100644 index 1c594fc..0000000 Binary files a/graphics/pause-camera.png and /dev/null differ diff --git a/graphics/play-white.png b/graphics/play-white.png deleted file mode 100755 index 4c31d57..0000000 Binary files a/graphics/play-white.png and /dev/null differ diff --git a/graphics/take-screenshot-24.png b/graphics/take-screenshot-24.png new file mode 100644 index 0000000..6f2cbc6 Binary files /dev/null and b/graphics/take-screenshot-24.png differ diff --git a/graphics/take-screenshot-32.png b/graphics/take-screenshot-32.png new file mode 100644 index 0000000..f2761fb Binary files /dev/null and b/graphics/take-screenshot-32.png differ diff --git a/graphics/take-screenshot.png b/graphics/take-screenshot.png deleted file mode 100644 index c6a7e57..0000000 Binary files a/graphics/take-screenshot.png and /dev/null differ diff --git a/info.json b/info.json index a452415..0bb7aa7 100644 --- a/info.json +++ b/info.json @@ -1,14 +1,14 @@ { "name": "TLBE", - "version": "1.5.2", + "version": "2.0.0", "title": "Time Lapse Base Edition", "author": "veger", "contact": "", "homepage": "", "license": "MIT https://opensource.org/licenses/MIT", - "factorio_version": "1.1", + "factorio_version": "2.0", "dependencies": [ - "base >= 1.0.0", + "base >= 2.0.0", "? StatsGui >= 1.1.0" ], "description": "Takes screenshots of your base at specified intervals." diff --git a/migrations/tlbe-0.2.1.lua b/migrations/tlbe-0.2.1.lua index c3c7b1b..a9e243a 100644 --- a/migrations/tlbe-0.2.1.lua +++ b/migrations/tlbe-0.2.1.lua @@ -4,12 +4,12 @@ local Tracker = require("scripts.tracker") local ticks_per_second = 60 -if global.playerSettings == nil then +if storage.playerSettings == nil then goto SkipMigration end for player_index, player in pairs(game.players) do - local playerSettings = global.playerSettings[player_index] + local playerSettings = storage.playerSettings[player_index] if playerSettings == nil or playerSettings.cameras == nil then goto NextPlayer end @@ -68,7 +68,7 @@ for player_index, player in pairs(game.players) do playerSettings.trackers = { table.unpack(mainCamera.trackers) } -- Remove obsolete entries - global.rocketLaunching = nil + storage.rocketLaunching = nil playerSettings.enabled = nil playerSettings.noticesEnabled = nil playerSettings.followPlayer = nil diff --git a/migrations/tlbe-1.0.0.lua b/migrations/tlbe-1.0.0.lua index 2cc8d48..00f0e44 100644 --- a/migrations/tlbe-1.0.0.lua +++ b/migrations/tlbe-1.0.0.lua @@ -1,16 +1,16 @@ -if global.playerSettings == nil then +if storage.playerSettings == nil then goto SkipMigration end for player_index, _ in pairs(game.players) do - local playerSettings = global.playerSettings[player_index] + local playerSettings = storage.playerSettings[player_index] if playerSettings == nil then goto NextPlayer end for _, tracker in pairs(playerSettings.trackers) do if tracker.type == "player" then - tracker.size = {x = 1, y = 1} + tracker.size = { x = 1, y = 1 } tracker.smooth = false else tracker.smooth = true diff --git a/migrations/tlbe.1.1.1.lua b/migrations/tlbe.1.1.1.lua index 5f3aad3..2502d5a 100644 --- a/migrations/tlbe.1.1.1.lua +++ b/migrations/tlbe.1.1.1.lua @@ -1,12 +1,12 @@ -if global.playerSettings == nil then +if storage.playerSettings == nil then goto SkipMigration end -- Set to old default value for smooth experience for player_index, player in pairs(game.players) do local guiSettings = settings.get_player_settings(player) - local playerSettings = global.playerSettings[player_index] - guiSettings["tlbe-sequential-names"] = {value = false} + local playerSettings = storage.playerSettings[player_index] + guiSettings["tlbe-sequential-names"] = { value = false } if playerSettings ~= nil then playerSettings.screenshotNumber = game.tick + 1 diff --git a/migrations/tlbe.1.2.0.lua b/migrations/tlbe.1.2.0.lua index fc2b60c..aac11bb 100644 --- a/migrations/tlbe.1.2.0.lua +++ b/migrations/tlbe.1.2.0.lua @@ -1,10 +1,10 @@ -if global.playerSettings == nil then +if storage.playerSettings == nil then goto SkipMigration end -- Set new camera setting to its previous (default) value for player_index, _ in pairs(game.players) do - local playerSettings = global.playerSettings[player_index] + local playerSettings = storage.playerSettings[player_index] if playerSettings == nil then goto NextPlayer end diff --git a/migrations/tlbe.1.3.1.lua b/migrations/tlbe.1.3.1.lua index 548c5ff..c3ecdd1 100644 --- a/migrations/tlbe.1.3.1.lua +++ b/migrations/tlbe.1.3.1.lua @@ -1,10 +1,10 @@ -if global.playerSettings == nil then +if storage.playerSettings == nil then goto SkipMigration end -- Set camera and tracker surfaces to the default surface for player_index, _ in pairs(game.players) do - local playerSettings = global.playerSettings[player_index] + local playerSettings = storage.playerSettings[player_index] if playerSettings == nil then goto NextPlayer end diff --git a/migrations/tlbe.1.4.2.lua b/migrations/tlbe.1.4.2.lua index 3e8c2f2..12ca7d0 100644 --- a/migrations/tlbe.1.4.2.lua +++ b/migrations/tlbe.1.4.2.lua @@ -1,4 +1,4 @@ -if global.playerSettings == nil then +if storage.playerSettings == nil then goto SkipMigration end @@ -7,13 +7,13 @@ local Tracker = require("scripts.tracker") -- Update camera with current active tracker to prevent possible (zooming) issues for player_index, _ in pairs(game.players) do - local playerSettings = global.playerSettings[player_index] + local playerSettings = storage.playerSettings[player_index] if playerSettings == nil then goto NextPlayer end for _, camera in pairs(playerSettings.cameras) do - local _, activeTracker = Tracker.findActiveTracker(camera.trackers, camera.surfaceName) + local _, activeTracker = Tracker.findActiveTracker(camera.trackers, camera.surfaceName) Camera.SetActiveTracker(camera, activeTracker) end diff --git a/migrations/tlbe.1.4.3.lua b/migrations/tlbe.1.4.3.lua index a2bac5c..edc8726 100644 --- a/migrations/tlbe.1.4.3.lua +++ b/migrations/tlbe.1.4.3.lua @@ -1,4 +1,4 @@ -if global.playerSettings == nil then +if storage.playerSettings == nil then goto SkipMigration end @@ -7,14 +7,14 @@ local Camera = require("scripts.camera") -- Update camera save folder and name -- Move sequential screenshot number to camera(s) for player_index, _ in pairs(game.players) do - local playerSettings = global.playerSettings[player_index] + local playerSettings = storage.playerSettings[player_index] if playerSettings == nil then goto NextPlayer end for _, camera in pairs(playerSettings.cameras) do - Camera.setName(camera, camera.name) - camera.screenshotNumber = playerSettings.screenshotNumber + Camera.setName(camera, camera.name) + camera.screenshotNumber = playerSettings.screenshotNumber end playerSettings.screenshotNumber = nil diff --git a/migrations/tlbe.1.4.4.lua b/migrations/tlbe.1.4.4.lua index 89415ae..baa51e7 100644 --- a/migrations/tlbe.1.4.4.lua +++ b/migrations/tlbe.1.4.4.lua @@ -1,11 +1,11 @@ -if global.playerSettings == nil then +if storage.playerSettings == nil then goto SkipMigration end -- Set camera alwaysDay to true for backwards compatibility -- Make tracker untilBuild available for all trackers for player_index, _ in pairs(game.players) do - local playerSettings = global.playerSettings[player_index] + local playerSettings = storage.playerSettings[player_index] if playerSettings == nil then goto NextPlayer end diff --git a/migrations/tlbe.1.4.5.lua b/migrations/tlbe.1.4.5.lua index 57b1e03..0e41c7f 100644 --- a/migrations/tlbe.1.4.5.lua +++ b/migrations/tlbe.1.4.5.lua @@ -1,4 +1,4 @@ -if global.playerSettings == nil then +if storage.playerSettings == nil then goto SkipMigration end @@ -8,7 +8,7 @@ local GUI = require("scripts.gui") -- Convert to new Camera transitionData for player_index, player in pairs(game.players) do ---@type playerSettings - local playerSettings = global.playerSettings[player_index] + local playerSettings = storage.playerSettings[player_index] if playerSettings == nil then goto NextPlayer end diff --git a/prototypes/shortcuts.lua b/prototypes/shortcuts.lua index 24255a4..7534ce1 100644 --- a/prototypes/shortcuts.lua +++ b/prototypes/shortcuts.lua @@ -26,36 +26,10 @@ data:extend( action = "lua", localised_name = { "shortcut.tlbe" }, associated_control_input = "tlbe-main-window-toggle", - icon = { - -- tlbe-logo - filename = "__TLBE__/graphics/logo.png", - priority = "extra-high-no-scale", - width = 64, - height = 50, - position = { 0, 0 }, - scale = 1, - flags = { "icon" } - }, - small_icon = { - -- tlbe-logo - filename = "__TLBE__/graphics/logo.png", - priority = "extra-high-no-scale", - width = 64, - height = 50, - position = { 0, 0 }, - scale = 1, - flags = { "icon" } - }, - disabled_small_icon = { - -- tlbe-logo-white - filename = "__TLBE__/graphics/logo.png", - priority = "extra-high-no-scale", - width = 64, - height = 50, - position = { 65, 0 }, - scale = 1, - flags = { "icon" } - } + icon = "__TLBE__/graphics/logo-32.png", + icon_size = 32, + small_icon = "__TLBE__/graphics/logo-24.png", + small_icon_size = 24 }, { type = "shortcut", @@ -65,36 +39,10 @@ data:extend( action = "lua", localised_name = { "shortcut.tlbe-pause" }, associated_control_input = "tlbe-pause-cameras", - icon = { - -- tlbe-pause-camera - filename = "__TLBE__/graphics/pause-camera.png", - priority = "extra-high-no-scale", - width = 64, - height = 64, - position = { 0, 0 }, - scale = 1, - flags = { "icon" } - }, - small_icon = { - -- tlbe-pause-camera - filename = "__TLBE__/graphics/pause-camera.png", - priority = "extra-high-no-scale", - width = 64, - height = 64, - position = { 0, 0 }, - scale = 1, - flags = { "icon" } - }, - disabled_small_icon = { - -- tlbe-pause-camera-white - filename = "__TLBE__/graphics/pause-camera.png", - priority = "extra-high-no-scale", - width = 64, - height = 50, - position = { 65, 0 }, - scale = 1, - flags = { "icon" } - } + icon = "__TLBE__/graphics/pause-camera-32.png", + icon_size = 32, + small_icon = "__TLBE__/graphics/pause-camera-24.png", + small_icon_size = 24 }, { type = "shortcut", @@ -104,36 +52,10 @@ data:extend( action = "lua", localised_name = { "shortcut.tlbe-screenshot" }, associated_control_input = "tlbe-take-screenshot", - icon = { - -- tlbe-take-screenshot - filename = "__TLBE__/graphics/take-screenshot.png", - priority = "extra-high-no-scale", - width = 64, - height = 64, - position = { 0, 0 }, - scale = 1, - flags = { "icon" } - }, - small_icon = { - -- tlbe-take-screenshot - filename = "__TLBE__/graphics/take-screenshot.png", - priority = "extra-high-no-scale", - width = 64, - height = 64, - position = { 0, 0 }, - scale = 1, - flags = { "icon" } - }, - disabled_small_icon = { - -- tlbe-take-screenshot-white - filename = "__TLBE__/graphics/take-screenshot.png", - priority = "extra-high-no-scale", - width = 64, - height = 50, - position = { 65, 0 }, - scale = 1, - flags = { "icon" } - } + icon = "__TLBE__/graphics/take-screenshot-32.png", + icon_size = 32, + small_icon = "__TLBE__/graphics/take-screenshot-24.png", + small_icon_size = 24, } } ) diff --git a/prototypes/signal.lua b/prototypes/signal.lua index 3a7170b..6fc6503 100644 --- a/prototypes/signal.lua +++ b/prototypes/signal.lua @@ -14,13 +14,14 @@ data:extend({ icons = { { icon = "__TLBE__/graphics/box-north-west.png", + icon_size = 32, tint = capture_tint } }, - icon_size = 32, - icon_mipmaps = 1, + scale = 0.5, subgroup = "tlbe-virtual-signal", - order = "a" + order = "a", + hidden_in_factoriopedia = true }, { type = "virtual-signal", @@ -28,13 +29,14 @@ data:extend({ icons = { { icon = "__TLBE__/graphics/box-south-west.png", + icon_size = 32, tint = capture_tint, } }, - icon_size = 32, - icon_mipmaps = 1, + scale = 0.5, subgroup = "tlbe-virtual-signal", - order = "b" + order = "b", + hidden_in_factoriopedia = true }, { type = "virtual-signal", @@ -42,14 +44,15 @@ data:extend({ icons = { { icon = "__TLBE__/graphics/box-south-east.png", + icon_size = 32, tint = capture_tint } }, - icon_size = 32, + scale = 0.5, tint = { 0, 1, 0 }, - icon_mipmaps = 1, subgroup = "tlbe-virtual-signal", - order = "c" + order = "c", + hidden_in_factoriopedia = true }, { type = "virtual-signal", @@ -57,13 +60,14 @@ data:extend({ icons = { { icon = "__TLBE__/graphics/box-north-east.png", + icon_size = 32, tint = capture_tint, } }, - icon_size = 32, - icon_mipmaps = 1, + scale = 0.5, subgroup = "tlbe-virtual-signal", - order = "d" + order = "d", + hidden_in_factoriopedia = true }, { type = "virtual-signal", @@ -71,13 +75,14 @@ data:extend({ icons = { { icon = "__TLBE__/graphics/box-north-west.png", + icon_size = 32, tint = target_tint } }, - icon_size = 32, - icon_mipmaps = 1, + scale = 0.5, subgroup = "tlbe-virtual-signal", - order = "e" + order = "e", + hidden_in_factoriopedia = true }, { type = "virtual-signal", @@ -85,13 +90,14 @@ data:extend({ icons = { { icon = "__TLBE__/graphics/box-south-west.png", - tint = target_tint, + icon_size = 32, + tint = target_tint } }, - icon_size = 32, - icon_mipmaps = 1, + scale = 0.5, subgroup = "tlbe-virtual-signal", - order = "f" + order = "f", + hidden_in_factoriopedia = true }, { type = "virtual-signal", @@ -99,13 +105,14 @@ data:extend({ icons = { { icon = "__TLBE__/graphics/box-south-east.png", + icon_size = 32, tint = target_tint } }, - icon_size = 32, - icon_mipmaps = 1, + scale = 0.5, subgroup = "tlbe-virtual-signal", - order = "g" + order = "g", + hidden_in_factoriopedia = true }, { type = "virtual-signal", @@ -113,12 +120,13 @@ data:extend({ icons = { { icon = "__TLBE__/graphics/box-north-east.png", + icon_size = 32, tint = target_tint, } }, - icon_size = 32, - icon_mipmaps = 1, + scale = 0.5, subgroup = "tlbe-virtual-signal", - order = "h" + order = "h", + hidden_in_factoriopedia = true } }) diff --git a/prototypes/sprites.lua b/prototypes/sprites.lua index bac7b24..fa8a296 100644 --- a/prototypes/sprites.lua +++ b/prototypes/sprites.lua @@ -1,60 +1,5 @@ data:extend( { - { - type = "sprite", - name = "tlbe-logo", - filename = "__TLBE__/graphics/logo.png", - priority = "extra-high-no-scale", - width = 64, - height = 50, - position = { 0, 0 }, - scale = 0.5, - flags = { "gui-icon" } - }, - { - type = "sprite", - name = "tlbe-logo-white", - filename = "__TLBE__/graphics/logo.png", - priority = "extra-high-no-scale", - width = 64, - height = 50, - position = { 65, 0 }, - scale = 0.5, - flags = { "gui-icon" } - }, - { - type = "sprite", - name = "tlbe-pause-camera", - filename = "__TLBE__/graphics/pause-camera.png", - priority = "extra-high-no-scale", - width = 64, - height = 64, - position = { 0, 0 }, - scale = 0.5, - flags = { "gui-icon" } - }, - { - type = "sprite", - name = "tlbe-take-screenshot", - filename = "__TLBE__/graphics/take-screenshot.png", - priority = "extra-high-no-scale", - width = 64, - height = 64, - position = { 0, 0 }, - scale = 0.5, - flags = { "gui-icon" } - }, - { - type = "sprite", - name = "play-white", - filename = "__TLBE__/graphics/play-white.png", - priority = "medium", - width = 32, - height = 32, - mipmap_count = 2, - scale = 0.5, - flags = { "gui-icon" } - }, { type = "sprite", name = "pause-white", diff --git a/prototypes/styles.lua b/prototypes/styles.lua index 3dbbd5d..954f1b1 100644 --- a/prototypes/styles.lua +++ b/prototypes/styles.lua @@ -48,7 +48,7 @@ default_gui["tlbe_fancy_list_box"] = { default_gui["tlbe_fancy_list_box_item"] = { type = "frame_style", - parent = "dark_frame", + parent = "shallow_frame", padding = 0, width = fancy_list_box_width } @@ -153,7 +153,7 @@ default_gui["tlbe_tracker_list"] = { right_margin = camera_flow_left_side_margin } -default_gui["tble_tracker_add_dropdown"] = { +default_gui["tlbe_tracker_add_dropdown"] = { type = "dropdown_style", width = fancy_list_box_width, right_margin = camera_flow_left_side_margin diff --git a/scripts/camera.lua b/scripts/camera.lua index f759acb..a941e6b 100644 --- a/scripts/camera.lua +++ b/scripts/camera.lua @@ -475,7 +475,7 @@ end --- @param player LuaPlayer function Camera.recordingSensor(player) - local playerSettings = global.playerSettings[player.index] + local playerSettings = storage.playerSettings[player.index] if not playerSettings.showCameraStatus then return nil diff --git a/scripts/config.lua b/scripts/config.lua index 21b84b1..4b1053a 100644 --- a/scripts/config.lua +++ b/scripts/config.lua @@ -31,10 +31,10 @@ function Config.reload(event) local player = game.players[event.player_index] local guiSettings = settings.get_player_settings(player) - local playerSettings = global.playerSettings[event.player_index] + local playerSettings = storage.playerSettings[event.player_index] if playerSettings == nil then playerSettings = Config.newPlayerSettings(player) - global.playerSettings[event.player_index] = playerSettings + storage.playerSettings[event.player_index] = playerSettings end ---@diagnostic disable: assign-type-mismatch diff --git a/scripts/gui.lua b/scripts/gui.lua index c9d224b..c99ef28 100644 --- a/scripts/gui.lua +++ b/scripts/gui.lua @@ -47,7 +47,7 @@ function GUI.tick() -- TODO performance: Use some kind of event system to update the GUI for for _, player in pairs(game.players) do - local playerSettings = global.playerSettings[player.index] + local playerSettings = storage.playerSettings[player.index] if playerSettings.gui ~= nil then if playerSettings.gui.cameraInfo.valid then local camera = playerSettings.cameras[playerSettings.guiPersist.selectedCamera] @@ -97,7 +97,7 @@ end function GUI.onClick(event) local player = game.players[event.player_index] ---@type playerSettings - local playerSettings = global.playerSettings[event.player_index] + local playerSettings = storage.playerSettings[event.player_index] if event.element.name == "tlbe-main-window-close" then GUI.closeMainWindow(event) @@ -416,7 +416,7 @@ end --- @param event EventData.on_gui_selection_state_changed function GUI.onSelected(event) local player = game.players[event.player_index] - local playerSettings = global.playerSettings[event.player_index] + local playerSettings = storage.playerSettings[event.player_index] if event.element.name == "tlbe-cameras-list" then GUI.setSelectedCamera(player, playerSettings, event.element.selected_index) @@ -514,7 +514,7 @@ end function GUI.onTextChanged(event) ---@type playerSettings - local playerSettings = global.playerSettings[event.player_index] + local playerSettings = storage.playerSettings[event.player_index] local selectedTracker = playerSettings.trackers[playerSettings.guiPersist.selectedTracker] if event.element.name == "camera-name" then @@ -666,7 +666,7 @@ function GUI.onTextChanged(event) end function GUI.onGuiConfirmed(event) - local playerSettings = global.playerSettings[event.player_index] + local playerSettings = storage.playerSettings[event.player_index] if event.element.name == "tlbe-tracker-cityblock-blockScale-value" and event.element.text ~= nil then local selectedTracker = playerSettings.trackers[playerSettings.guiPersist.selectedTracker] local value = tonumber(event.element.text) @@ -682,7 +682,7 @@ end function GUI.onStateChanged(event) ---@type playerSettings - local playerSettings = global.playerSettings[event.player_index] + local playerSettings = storage.playerSettings[event.player_index] if event.element.name == "camera-entity-info" then playerSettings.cameras[playerSettings.guiPersist.selectedCamera].entityInfo = event.element.state elseif event.element.name == "camera-show-gui" then @@ -713,7 +713,7 @@ function GUI.takeScreenshot(event) local active = player.is_shortcut_available("tlbe-screenshot-shortcut") if active then ---@type playerSettings - local playerSettings = global.playerSettings[event.player_index] + local playerSettings = storage.playerSettings[event.player_index] local camera = playerSettings.cameras[playerSettings.guiPersist.selectedCamera] local _, activeTracker = Tracker.findActiveTracker(camera.trackers, camera.surfaceName) @@ -724,7 +724,7 @@ end function GUI.onSurfacesUpdated() -- Surface list got updated so refresh GUI for _, player in pairs(game.players) do - local playerSettings = global.playerSettings[player.index] + local playerSettings = storage.playerSettings[player.index] if playerSettings.gui ~= nil then GUI.updateCameraConfig( playerSettings.useInterval, @@ -747,7 +747,7 @@ function GUI.onSurfaceChanged(event) end for _, player in pairs(game.players) do - local playerSettings = global.playerSettings[player.index] + local playerSettings = storage.playerSettings[player.index] for _, camera in pairs(playerSettings.cameras) do if camera.surfaceName == surfaceName then @@ -777,7 +777,7 @@ end function GUI.togglePauseCameras(event) local player = game.players[event.player_index] - local playerSettings = global.playerSettings[event.player_index] + local playerSettings = storage.playerSettings[event.player_index] playerSettings.pauseCameras = playerSettings.pauseCameras ~= true player.set_shortcut_toggled("tlbe-pause-shortcut", playerSettings.pauseCameras) @@ -793,7 +793,7 @@ end function GUI.toggleMainWindow(event) local player = game.players[event.player_index] ---@type playerSettings - local playerSettings = global.playerSettings[event.player_index] + local playerSettings = storage.playerSettings[event.player_index] local mainWindowOpen = player.gui.screen["tlbe-main-window"] ~= nil player.set_shortcut_toggled("tlbe-shortcut", not mainWindowOpen) @@ -835,7 +835,7 @@ function GUI.toggleMainWindow(event) title_bar.add { type = "sprite-button", style = "frame_action_button", - sprite = "utility/close_white", + sprite = "utility/close", name = "tlbe-main-window-close" } @@ -889,13 +889,13 @@ function GUI.createCameraSettings(parent, playerGUI, guiPersist, useInterval, ca -- Camera info playerGUI.cameraInfo = cameraBox.add { type = "table", column_count = 2 } - playerGUI.cameraInfo.add { type = "label", caption = { "gui.label-name" }, style = "description_property_name_label" } + playerGUI.cameraInfo.add { type = "label", caption = { "gui.label-name" }, style = "bold_label" } playerGUI.cameraInfo.add { type = "textfield", name = "camera-name", style = "tlbe_config_textfield" } playerGUI.cameraInfo.add { type = "label", name = "camera-surface-label", caption = { "gui.label-surface" }, - style = "description_property_name_label" + style = "bold_label" } playerGUI.cameraInfo.add { type = "drop-down", @@ -906,7 +906,7 @@ function GUI.createCameraSettings(parent, playerGUI, guiPersist, useInterval, ca playerGUI.cameraInfo.add { type = "label", caption = { "gui.label-resolution" }, - style = "description_property_name_label" + style = "bold_label" } local resolutionFlow = playerGUI.cameraInfo.add { type = "flow", name = "camera-resolution" } resolutionFlow.add { @@ -926,7 +926,7 @@ function GUI.createCameraSettings(parent, playerGUI, guiPersist, useInterval, ca type = "label", caption = { "gui.label-framerate" }, tooltip = { "tooltip.camera-framerate" }, - style = "description_property_name_label" + style = "bold_label" } playerGUI.cameraInfo.add { type = "textfield", @@ -940,7 +940,7 @@ function GUI.createCameraSettings(parent, playerGUI, guiPersist, useInterval, ca type = "label", caption = { "gui.label-interval" }, tooltip = { "tooltip.camera-interval" }, - style = "description_property_name_label" + style = "bold_label" } playerGUI.cameraInfo.add { @@ -956,7 +956,7 @@ function GUI.createCameraSettings(parent, playerGUI, guiPersist, useInterval, ca type = "label", caption = { "gui.label-speedgain" }, tooltip = { "tooltip.camera-speedgain" }, - style = "description_property_name_label" + style = "bold_label" } playerGUI.cameraInfo.add { @@ -972,7 +972,7 @@ function GUI.createCameraSettings(parent, playerGUI, guiPersist, useInterval, ca type = "label", caption = { "gui.label-transitionperiod" }, tooltip = { "tooltip.camera-transitionperiod" }, - style = "description_property_name_label" + style = "bold_label" } playerGUI.cameraInfo.add { type = "textfield", @@ -987,7 +987,7 @@ function GUI.createCameraSettings(parent, playerGUI, guiPersist, useInterval, ca type = "label", caption = { "gui.label-transition-interval" }, tooltip = { "tooltip.camera-transition-interval" }, - style = "description_property_name_label" + style = "bold_label" } playerGUI.cameraInfo.add { type = "textfield", @@ -1002,7 +1002,7 @@ function GUI.createCameraSettings(parent, playerGUI, guiPersist, useInterval, ca type = "label", caption = { "gui.label-transition-speedgain" }, tooltip = { "tooltip.camera-transition-speedgain" }, - style = "description_property_name_label" + style = "bold_label" } playerGUI.cameraInfo.add { type = "textfield", @@ -1040,10 +1040,10 @@ function GUI.createCameraSettings(parent, playerGUI, guiPersist, useInterval, ca playerGUI.cameraInfo.add { type = "label", caption = { "gui.label-position" }, - style = "description_property_name_label" + style = "bold_label" } playerGUI.cameraInfo.add { type = "label", name = "camera-position" } - playerGUI.cameraInfo.add { type = "label", caption = { "gui.label-zoom" }, style = "description_property_name_label" } + playerGUI.cameraInfo.add { type = "label", caption = { "gui.label-zoom" }, style = "bold_label" } playerGUI.cameraInfo.add { type = "label", name = "camera-zoom" } GUI.updateCameraConfig(useInterval, playerGUI.cameraInfo, cameras[guiPersist.selectedCamera]) @@ -1051,7 +1051,7 @@ function GUI.createCameraSettings(parent, playerGUI, guiPersist, useInterval, ca -- Trackers flow.add { type = "line" } - flow.add { type = "label", caption = { "gui.label-camera-trackers" }, style = "description_property_name_label" } + flow.add { type = "label", caption = { "gui.label-camera-trackers" }, style = "bold_label" } local trackerBox = flow.add { type = "flow" } playerGUI.cameraTrackerListFlow = trackerBox.add { type = "flow", direction = "vertical", style = "tlbe_fancy_list_parent" } @@ -1078,19 +1078,19 @@ function GUI.createCameraSettings(parent, playerGUI, guiPersist, useInterval, ca playerGUI.cameraTrackerInfo.add { type = "label", caption = { "gui.label-type" }, - style = "description_property_name_label" + style = "bold_label" } playerGUI.cameraTrackerInfo.add { type = "label", name = "tracker-type" } playerGUI.cameraTrackerInfo.add { type = "label", caption = { "gui.label-center" }, - style = "description_property_name_label" + style = "bold_label" } playerGUI.cameraTrackerInfo.add { type = "label", name = "tracker-position" } playerGUI.cameraTrackerInfo.add { type = "label", caption = { "gui.label-size" }, - style = "description_property_name_label" + style = "bold_label" } playerGUI.cameraTrackerInfo.add { type = "label", name = "tracker-size" } GUI.updateTrackerInfo( @@ -1111,7 +1111,7 @@ function GUI.createTrackerSettings(parent, playerGUI, guiPersist, cameras, track selected_index = 1, name = "tlbe-tracker-add", items = { { "gui.item-new-tracker" }, table.unpack(GUI.allTrackersLabels) }, - style = "tble_tracker_add_dropdown" + style = "tlbe_tracker_add_dropdown" } -- Trackers @@ -1326,7 +1326,7 @@ function GUI.createCameraAddTracker(parent, allTrackers, camera) selected_index = 1, name = "tlbe-camera-add-tracker", items = { { "gui.item-add-tracker" }, table.unpack(availableTrackerNames) }, - style = "tble_tracker_add_dropdown" + style = "tlbe_tracker_add_dropdown" } end end @@ -1453,13 +1453,13 @@ end function GUI.createTrackerConfigAndInfo(trackerInfo, tracker) trackerInfo.clear() - trackerInfo.add { type = "label", caption = { "gui.label-name" }, style = "description_property_name_label" } + trackerInfo.add { type = "label", caption = { "gui.label-name" }, style = "bold_label" } trackerInfo.add { type = "textfield", name = "tracker-name", style = "tlbe_config_textfield" } trackerInfo.add { type = "label", name = "tracker-surface-label", caption = { "gui.label-surface" }, - style = "description_property_name_label" + style = "bold_label" } trackerInfo.add { type = "drop-down", @@ -1481,7 +1481,7 @@ function GUI.createTrackerConfigAndInfo(trackerInfo, tracker) trackerInfo.add { type = "label", caption = { "gui.label-top-right" }, - style = "description_property_name_label" + style = "bold_label" } local trFlow = trackerInfo.add { type = "flow", name = "tracker-tr" } trFlow.add { @@ -1515,7 +1515,7 @@ function GUI.createTrackerConfigAndInfo(trackerInfo, tracker) } trackerInfo.add { type = "label", caption = { "gui.label-bottom-left" }, - style = "description_property_name_label" } + style = "bold_label" } local blFlow = trackerInfo.add { type = "flow", name = "tracker-bl" } blFlow.add { type = "textfield", @@ -1560,7 +1560,7 @@ function GUI.createTrackerConfigAndInfo(trackerInfo, tracker) type = "label", caption = { "gui.label-cityblock-size" }, tooltip = { "tooltip.tracker-cityblock-size" }, - style = "description_property_name_label" + style = "bold_label" } local sizeFlow = trackerInfo.add { type = "flow", name = "cityblock-size" } sizeFlow.add { @@ -1585,7 +1585,7 @@ function GUI.createTrackerConfigAndInfo(trackerInfo, tracker) type = "label", caption = { "gui.label-cityblock-offset" }, tooltip = { "tooltip.tracker-cityblock-offset" }, - style = "description_property_name_label" + style = "bold_label" } local offsetFlow = trackerInfo.add { type = "flow", name = "cityblock-offset" } offsetFlow.add { @@ -1610,7 +1610,7 @@ function GUI.createTrackerConfigAndInfo(trackerInfo, tracker) type = "label", caption = { "gui.label-cityblock-currentblock" }, tooltip = { "tooltip.tracker-cityblock-currentblock" }, - style = "description_property_name_label" + style = "bold_label" } local blockFlow = trackerInfo.add { type = "flow", name = "cityblock-block" } blockFlow.add { @@ -1635,7 +1635,7 @@ function GUI.createTrackerConfigAndInfo(trackerInfo, tracker) type = "label", caption = { "gui.label-cityblock-blockScale" }, tooltip = { "tooltip.tracker-cityblock-blockScale" }, - style = "description_property_name_label" + style = "bold_label" } trackerInfo.add { type = "textfield", @@ -1650,7 +1650,7 @@ function GUI.createTrackerConfigAndInfo(trackerInfo, tracker) trackerInfo.add { type = "label", caption = { "gui.label-cityblock-centerOnPlayer" }, - style = "description_property_name_label" + style = "bold_label" } trackerInfo.add { type = "sprite-button", @@ -1665,16 +1665,16 @@ function GUI.createTrackerConfigAndInfo(trackerInfo, tracker) trackerInfo.add { type = "label", caption = { "gui.label-type" }, - style = "description_property_name_label" + style = "bold_label" } trackerInfo.add { type = "label", name = "tracker-type" } trackerInfo.add { type = "label", caption = { "gui.label-center" }, - style = "description_property_name_label" + style = "bold_label" } trackerInfo.add { type = "label", name = "tracker-position" } - trackerInfo.add { type = "label", caption = { "gui.label-size" }, style = "description_property_name_label" } + trackerInfo.add { type = "label", caption = { "gui.label-size" }, style = "bold_label" } trackerInfo.add { type = "label", name = "tracker-size" } GUI.updateTrackerConfig(trackerInfo, tracker) GUI.updateTrackerInfo(trackerInfo, tracker) diff --git a/scripts/main.lua b/scripts/main.lua index edb4a11..b67d09c 100644 --- a/scripts/main.lua +++ b/scripts/main.lua @@ -6,7 +6,7 @@ local Utils = require("scripts.utils") function Main.tick() for _, player in pairs(game.players) do - local playerSettings = global.playerSettings[player.index] + local playerSettings = storage.playerSettings[player.index] if playerSettings.pauseCameras == true then -- Skip this player as the pause-cameras toggle is enabled @@ -56,9 +56,9 @@ function Main.tick() end function Main.entity_built(event) - local newEntityBBox = Utils.entityBBox(event.created_entity) + local newEntityBBox = Utils.entityBBox(event.entity) - for _, playerSettings in pairs(global.playerSettings) do + for _, playerSettings in pairs(storage.playerSettings) do for _, tracker in pairs(playerSettings.trackers) do if not tracker.enabled then goto nextTracker @@ -67,7 +67,7 @@ function Main.entity_built(event) if tracker.untilBuild then Tracker.moveToNextTracker(tracker) elseif tracker.type == "base" then - if tracker.surfaceName ~= event.created_entity.surface.name then + if tracker.surfaceName ~= event.entity.surface.name then goto nextTracker end @@ -100,7 +100,7 @@ function Main.entity_built(event) end function Main.rocket_launch(event) - for _, playerSettings in pairs(global.playerSettings) do + for _, playerSettings in pairs(storage.playerSettings) do for _, tracker in pairs(playerSettings.trackers) do if tracker.type ~= "rocket" or tracker.surfaceName ~= event.rocket_silo.surface.name then goto nextTracker @@ -120,9 +120,9 @@ function Main.rocket_launch(event) end function Main.rocket_launched(event) - for _, playerSettings in pairs(global.playerSettings) do + for _, playerSettings in pairs(storage.playerSettings) do for _, tracker in pairs(playerSettings.trackers) do - if tracker.type ~= "rocket" or tracker.surfaceName ~= event.rocket_silo.surface.name then + if tracker.type ~= "rocket" or event.rocket_silo == nil or tracker.surfaceName ~= event.rocket_silo.surface.name then goto nextTracker end diff --git a/tests/camera.lua b/tests/camera.lua index 8c8c5b8..2f80ec5 100644 --- a/tests/camera.lua +++ b/tests/camera.lua @@ -56,8 +56,8 @@ local function nextTick() end function TestCamera:SetUp() - -- mock Factorio provided globals - global = {} + -- mock Factorio provided storage + storage = {} game = { tick = 0, surfaces = { { name = "nauvis" } }, @@ -66,7 +66,7 @@ function TestCamera:SetUp() } -- mock TLBE tables - global.playerSettings = { + storage.playerSettings = { TLBE.Config.newPlayerSettings({ position = { x = 0, y = 0 } }), TLBE.Config.newPlayerSettings({ position = { x = 0, y = 0 } }) } @@ -77,12 +77,12 @@ function TestCamera:SetUp() } -- Enable player1 camera - global.playerSettings[1].cameras[1].enabled = true + storage.playerSettings[1].cameras[1].enabled = true -- Make cameras easier to test - self.testCameraPlayer1 = global.playerSettings[1].cameras[1] - self.testCameraPlayer2 = global.playerSettings[2].cameras[1] - for _, playerSettings in pairs(global.playerSettings) do + self.testCameraPlayer1 = storage.playerSettings[1].cameras[1] + self.testCameraPlayer2 = storage.playerSettings[2].cameras[1] + for _, playerSettings in pairs(storage.playerSettings) do for _, camera in pairs(playerSettings.cameras) do for k, v in pairs( { @@ -113,7 +113,7 @@ function TestCamera:TestTransitionFromPlayerToBaseTracker() game.players[1].position = { x = 2, y = 2 } TLBE.Main.entity_built( { - created_entity = { + entity = { surface = game.surfaces[1], bounding_box = { left_top = { x = 1, y = 3 }, @@ -141,7 +141,7 @@ function TestCamera:TestRocketLaunch1() -- Initialize base tracker TLBE.Main.entity_built( { - created_entity = { + entity = { surface = game.surfaces[1], bounding_box = { left_top = { x = -1, y = -1 }, @@ -179,7 +179,7 @@ function TestCamera:TestResolutionChange() TLBE.Main.entity_built( { - created_entity = { + entity = { surface = game.surfaces[1], bounding_box = { left_top = { x = -20, y = -20 }, diff --git a/tests/main.lua b/tests/main.lua index 31ce91f..371a774 100644 --- a/tests/main.lua +++ b/tests/main.lua @@ -127,20 +127,20 @@ function TestTick:Setup() self.screenshotTaken = true end } - global = { + storage = { playerSettings = { Config.newPlayerSettings(game.players[1]) } } self.areaTracker = Tracker.newTracker "area" - self.camera = global.playerSettings[1].cameras[1] + self.camera = storage.playerSettings[1].cameras[1] self.camera.enabled = true self.camera.screenshotInterval = 1 -- take screenshot every tick self.camera.screenshotIntervalTransition = 1 -- take screenshot every tick - global.playerSettings[1].trackers = { self.areaTracker } + storage.playerSettings[1].trackers = { self.areaTracker } self.camera.trackers = { self.areaTracker } - global.playerSettings[1].sequentialNames = true + storage.playerSettings[1].sequentialNames = true Camera.SetActiveTracker(self.camera, self.areaTracker) end diff --git a/tests/surface.lua b/tests/surface.lua index 59977b1..fb77a15 100644 --- a/tests/surface.lua +++ b/tests/surface.lua @@ -10,7 +10,7 @@ TestSurfaceEvents = {} function TestSurfaceEvents:SetUp() -- mock Factorio provided globals - global = {} + storage = {} -- luacheck: globals game game = { tick = 0, @@ -18,7 +18,7 @@ function TestSurfaceEvents:SetUp() } -- mock TLBE tables - global.playerSettings = { + storage.playerSettings = { TLBE.Config.newPlayerSettings({ position = { x = 0, y = 0 } }), } @@ -27,7 +27,7 @@ function TestSurfaceEvents:SetUp() } -- Make camera easier to test - self.testCamera = global.playerSettings[1].cameras[1] + self.testCamera = storage.playerSettings[1].cameras[1] self.testCamera.surfaceName = "active-surface" end diff --git a/tests/tracker-base.lua b/tests/tracker-base.lua index 735b1b9..7924b18 100644 --- a/tests/tracker-base.lua +++ b/tests/tracker-base.lua @@ -12,18 +12,18 @@ TestTrackerBase = {} function TestTrackerBase:SetUp() -- mock Factorio provided globals - global = {} + storage = {} game = { surfaces = { { name = "nauvis" }, { name = "other-surface" } } } -- mock TLBE tables - global.playerSettings = { + storage.playerSettings = { TLBE.Config.newPlayerSettings({ position = { x = 0, y = 0 } }) } -- Update base tracker with our test settings - self.baseTracker = global.playerSettings[1].trackers[3] + self.baseTracker = storage.playerSettings[1].trackers[3] for k, v in pairs( { changeId = 1 @@ -38,7 +38,7 @@ function TestTrackerBase:TestDisabledTracker() self.baseTracker.enabled = false TLBE.Main.entity_built( { - created_entity = { + entity = { surface = game.surfaces[1], bounding_box = { left_top = { x = 1, y = 3 }, @@ -56,7 +56,7 @@ end function TestTrackerBase:TestBuildOnOtherSurface() TLBE.Main.entity_built( { - created_entity = { + entity = { surface = game.surfaces[2], bounding_box = { left_top = { x = 1, y = 3 }, @@ -74,7 +74,7 @@ end function TestTrackerBase:TestSingleEntityBuilt() TLBE.Main.entity_built( { - created_entity = { + entity = { surface = game.surfaces[1], bounding_box = { left_top = { x = 1, y = 3 }, @@ -102,7 +102,7 @@ end function TestTrackerBase:TestMultipleEntitiesBuilt() TLBE.Main.entity_built( { - created_entity = { + entity = { surface = game.surfaces[1], bounding_box = { left_top = { x = 1, y = 3 }, @@ -116,7 +116,7 @@ function TestTrackerBase:TestMultipleEntitiesBuilt() TLBE.Main.entity_built( { - created_entity = { + entity = { surface = game.surfaces[1], bounding_box = { left_top = { x = -2, y = 5 }, diff --git a/tests/tracker-cityblock.lua b/tests/tracker-cityblock.lua index 2a724b9..419892b 100644 --- a/tests/tracker-cityblock.lua +++ b/tests/tracker-cityblock.lua @@ -10,18 +10,18 @@ TestTrackerCityBlock = {} function TestTrackerCityBlock:Setup() -- mock Factorio provided globals - global = {} + storage = {} game = { surfaces = { { name = "nauvis" }, { name = "other-surface" } } } -- mock TLBE tables - global.playerSettings = { + storage.playerSettings = { TLBE.Config.newPlayerSettings({ position = { x = 0, y = 0 } }) } -- Create city block tracker - self.cityblockTracker = TLBE.Tracker.newTracker("cityblock", global.playerSettings[1].trackers) + self.cityblockTracker = TLBE.Tracker.newTracker("cityblock", storage.playerSettings[1].trackers) for k, v in pairs( { changeId = 1 @@ -37,17 +37,23 @@ function TestTrackerCityBlock:Focus() self.cityblockTracker.cityBlock.blockSize.y = 32 - TLBE.Tracker.focusCityBlock(self.cityblockTracker, {x=0,y=0} ) - lu.assertEquals(self.cityblockTracker.cityBlock.currentBlock, {x=0,y=0}, "focus on tile zero should be in the block zero") - lu.assertEquals(self.cityblockTracker.centerPos, {x=16,y=16}, "focus on tile zero should center on the zero chunk") + TLBE.Tracker.focusCityBlock(self.cityblockTracker, { x = 0, y = 0 }) + lu.assertEquals(self.cityblockTracker.cityBlock.currentBlock, { x = 0, y = 0 }, + "focus on tile zero should be in the block zero") + lu.assertEquals(self.cityblockTracker.centerPos, { x = 16, y = 16 }, + "focus on tile zero should center on the zero chunk") - TLBE.Tracker.focusCityBlock(self.cityblockTracker, {x=14,y=19} ) - lu.assertEquals(self.cityblockTracker.cityBlock.currentBlock, {x=0,y=0}, "focus on a tile within zero chunk should be in the block zero") - lu.assertEquals(self.cityblockTracker.centerPos, {x=16,y=16}, "focus on a tile within zero chunk should center on the zero chunk") + TLBE.Tracker.focusCityBlock(self.cityblockTracker, { x = 14, y = 19 }) + lu.assertEquals(self.cityblockTracker.cityBlock.currentBlock, { x = 0, y = 0 }, + "focus on a tile within zero chunk should be in the block zero") + lu.assertEquals(self.cityblockTracker.centerPos, { x = 16, y = 16 }, + "focus on a tile within zero chunk should center on the zero chunk") - TLBE.Tracker.focusCityBlock(self.cityblockTracker, {x=32,y=32} ) - lu.assertEquals(self.cityblockTracker.cityBlock.currentBlock, {x=0,y=0}, "focus on tile {32,32} should be in the block {1,1}") - lu.assertEquals(self.cityblockTracker.centerPos, {x=32+16,y=32+16}, "focus on tile {32,32} should center on the {1,1} chunk") + TLBE.Tracker.focusCityBlock(self.cityblockTracker, { x = 32, y = 32 }) + lu.assertEquals(self.cityblockTracker.cityBlock.currentBlock, { x = 0, y = 0 }, + "focus on tile {32,32} should be in the block {1,1}") + lu.assertEquals(self.cityblockTracker.centerPos, { x = 32 + 16, y = 32 + 16 }, + "focus on tile {32,32} should center on the {1,1} chunk") end function TestTrackerCityBlock:scale() @@ -58,18 +64,20 @@ function TestTrackerCityBlock:scale() self.cityblockTracker.cityBlock.currentBlock.y = 0 TLBE.Tracker.recalculateCityBlock(self.cityblockTracker) local oldCenterPos = { - x=self.cityblockTracker.centerPos.x, - y=self.cityblockTracker.centerPos.y + x = self.cityblockTracker.centerPos.x, + y = self.cityblockTracker.centerPos.y } - + self.cityblockTracker.cityBlock.blockScale = 1 TLBE.Tracker.recalculateCityBlock(self.cityblockTracker) - lu.assertEquals(self.cityblockTracker.size, {x=32,y=32}, "A blockScale of 1 should give a size matching the block size") + lu.assertEquals(self.cityblockTracker.size, { x = 32, y = 32 }, + "A blockScale of 1 should give a size matching the block size") lu.assertEquals(self.cityblockTracker.centerPos, oldCenterPos, "Rescaling doesn't recenter") self.cityblockTracker.cityBlock.blockScale = 2 TLBE.Tracker.recalculateCityBlock(self.cityblockTracker) - lu.assertEquals(self.cityblockTracker.size, {x=64,y=64}, "A blockScale of 2 should give a size twice the block size") + lu.assertEquals(self.cityblockTracker.size, { x = 64, y = 64 }, + "A blockScale of 2 should give a size twice the block size") lu.assertEquals(self.cityblockTracker.centerPos, oldCenterPos, "Rescaling doesn't recenter") -end \ No newline at end of file +end diff --git a/tests/tracker-player.lua b/tests/tracker-player.lua index 677d8d1..206f8a9 100644 --- a/tests/tracker-player.lua +++ b/tests/tracker-player.lua @@ -11,17 +11,17 @@ TestTrackerPlayer = {} function TestTrackerPlayer:SetUp() -- mock Factorio provided globals - global = {} + storage = {} game = { surfaces = { { name = "nauvis" }, { name = "other-surface" } } } -- mock TLBE tables - global.playerSettings = { + storage.playerSettings = { TLBE.Config.newPlayerSettings({ position = { x = 0, y = 0 } }) } - self.playerTracker = global.playerSettings[1].trackers[1] + self.playerTracker = storage.playerSettings[1].trackers[1] end -- luacheck: globals game diff --git a/tests/tracker-rocket.lua b/tests/tracker-rocket.lua index 35c2f35..198a2b7 100644 --- a/tests/tracker-rocket.lua +++ b/tests/tracker-rocket.lua @@ -11,18 +11,18 @@ TestTrackerRocket = {} function TestTrackerRocket:SetUp() -- mock Factorio provided globals - global = {} + storage = {} game = { surfaces = { { name = "nauvis" }, { name = "other-surface" } } } -- mock TLBE tables - global.playerSettings = { + storage.playerSettings = { TLBE.Config.newPlayerSettings({ position = { x = 0, y = 0 } }) } -- Update rocket tracker with our test settings - self.rocketTracker = global.playerSettings[1].trackers[2] + self.rocketTracker = storage.playerSettings[1].trackers[2] for k, v in pairs( { centerPos = { x = 0, y = 0 }, @@ -62,7 +62,7 @@ end function TestTrackerRocket:TestRocketLaunched() self.rocketTracker.enabled = true TLBE.Main.rocket_launched({ rocket_silo = { surface = game.surfaces[1] } }) - TLBE.Tracker.MoveToNextTrackerFinished(global.playerSettings[1].trackers) + TLBE.Tracker.MoveToNextTrackerFinished(storage.playerSettings[1].trackers) lu.assertIsFalse(self.rocketTracker.enabled, "expected be disabled after rocket launched") end @@ -70,7 +70,7 @@ end function TestTrackerRocket:TestRocketLaunchedAlreadyInactive() self.rocketTracker.enabled = false TLBE.Main.rocket_launched({ rocket_silo = { surface = game.surfaces[1] } }) - TLBE.Tracker.MoveToNextTrackerFinished(global.playerSettings[1].trackers) + TLBE.Tracker.MoveToNextTrackerFinished(storage.playerSettings[1].trackers) lu.assertIsFalse(self.rocketTracker.enabled, "expected be still disabled after rocket launched") end