From: Someone Date: Tue, 22 Oct 2024 13:18:39 +0000 (+0200) Subject: RELEASE 2.0.0 - Initial compatibility with Factorio 2.0 X-Git-Url: https://git.somenet.org/factorio/some-zoom.git/commitdiff_plain?ds=inline RELEASE 2.0.0 - Initial compatibility with Factorio 2.0 --- diff --git a/changelog.txt b/changelog.txt index a0b1e75..1ee4d58 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,10 @@ +--------------------------------------------------------------------------------------------------- +Version: 2.0.0 +Date: 2024-10-21 + + Changed: + - Initial compatibility with Factorio 2.0 + --------------------------------------------------------------------------------------------------- Version: 1.1.2 Date: 2024-01-02 diff --git a/control.lua b/control.lua index e0f4b9e..bc933ff 100644 --- a/control.lua +++ b/control.lua @@ -1,33 +1,22 @@ --- debug_status = 1 debug_mod_name = "Zoom" -debug_file = debug_mod_name .. "-debug.txt" require("utils") local zoom_factor = 1.5 local zoom_wide_max = 0.01 local zoom_wide_hotkey = 1 / (zoom_factor^7) local zoom_close_max = 16.00 - --------------------------------------------------------------------------------------- -local function init_globals() - -- initialize or update general globals of the mod - debug_print( "init_globals " ) - - global.ticks = global.ticks or 0 - global.force_mem = global.force_mem or {} - global.player_mem = global.player_mem or {} -end +local player_mem = {} -------------------------------------------------------------------------------------- local function init_player(player) - if global.player_mem == nil then return end + if player_mem == nil then return end -- initialize or update per player globals of the mod, and reset the gui debug_print( "init_player ", player.name, " connected=", player.connected ) - global.player_mem[player.index] = global.player_mem[player.index] or {} + player_mem[player.index] = player_mem[player.index] or {} - local player_mem = global.player_mem[player.index] + local player_mem = player_mem[player.index] player_mem.player = player_mem.player or player player_mem.zoom = player_mem.zoom or 1 @@ -47,7 +36,6 @@ end local function on_init() -- called once, the first time the mod is loaded on a game (new or existing game) debug_print( "on_init" ) - init_globals() init_players() end @@ -60,14 +48,7 @@ local function on_configuration_changed(data) local changes = data.mod_changes[debug_mod_name] if changes ~= nil then debug_print( "update mod: ", debug_mod_name, " ", tostring(changes.old_version), " to ", tostring(changes.new_version) ) - - init_globals() init_players() - - if changes.old_version and older_version(changes.old_version, "1.0.4") then - message_all("Zoom: you can now use ALT-Z to directly zoom out wide !") - end - end end end @@ -106,14 +87,14 @@ local function on_gui_click(event) debug_print( "on_gui_click ", player.name, " ", event_name ) if event_name == "but_zoom_zin" then - local player_mem = global.player_mem[player.index] + local player_mem = player_mem[player.index] if player_mem.zoom < zoom_close_max then player_mem.zoom = player_mem.zoom * zoom_factor player.zoom = player_mem.zoom end elseif event_name == "but_zoom_zout" then - local player_mem = global.player_mem[player.index] + local player_mem = player_mem[player.index] if player_mem.zoom > zoom_wide_max then player_mem.zoom = player_mem.zoom / zoom_factor player.zoom = player_mem.zoom @@ -126,7 +107,7 @@ script.on_event(defines.events.on_gui_click, on_gui_click) -------------------------------------------------------------------------------------- local function on_zoom_hotkey(event) local player = game.players[event.player_index] - local player_mem = global.player_mem[player.index] + local player_mem = player_mem[player.index] player_mem.zoom = zoom_wide_hotkey player.zoom = player_mem.zoom end diff --git a/info.json b/info.json index eea2a8d..8acec37 100644 --- a/info.json +++ b/info.json @@ -1,10 +1,10 @@ { "name": "some-zoom", - "version": "1.1.2", + "version": "2.0.0", "title": "Zoom (fixed+re-published abandoned mod)", "author": "Someone (originally BinbinHfr)", "homepage": "https://git.somenet.org/factorio/some-zoom.git", "description": "Just 2 buttons to zoom extra wide or close, further than actual gui limits! And a ALT-Y hotkey to direct zoom out.", - "dependencies": ["base>=1.1.0"], - "factorio_version":"1.1" + "factorio_version": "2.0", + "dependencies": ["base>=2.0.0"] }