--- 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
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
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
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
--------------------------------------------------------------------------------------
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
{
"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"]
}