Skip to content

Commit

Permalink
Update to 0.11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ZwerOxotnik committed May 6, 2023
1 parent 12bec81 commit c1b32ce
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 0.11.2
Date: 06. 05. 2023
Bugfixes:
- Improved data stability at start
---------------------------------------------------------------------------------------------------
Version: 0.11.1
Date: 13. 03. 2023
Locale:
Expand Down
23 changes: 12 additions & 11 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@ require('mod-gui')
local Entity = require("stdlib/entity/entity")
local Surface = require("stdlib/surface")
local microcontroller = require('microcontroller')
local Event = require('stdlib/event/event')
require('stdlib/string')
require('constants')
require('stdlib/area/tile')


function get_player_data(player_index)
if global.player_data == nil then
global.player_data = {}
end
local player_data = global.player_data[player_index] or {}
return player_data
end

function set_player_data(player_index, data)
if global.player_data == nil then
global.player_data = {}
end
global.player_data[player_index] = data
end


-- Handle MicroController OPEN event.
script.on_event("open-gui", function(event)
local player_index = event.player_index
Expand Down Expand Up @@ -302,11 +299,6 @@ end

local update_tick_time = settings.startup["mc_update_tick_time"].value
script.on_nth_tick(update_tick_time, function()
-- Ensure we have a table to store microcontrollers in the global state.
if not global.microcontrollers then
global.microcontrollers = {}
end

local do_update_gui = true
if update_tick_time < 30 then
do_update_gui = (game.tick % 60 == 0)
Expand Down Expand Up @@ -459,7 +451,16 @@ function microcontrollerGui( player, entity )
set_player_data(player.index, player_data)
end

function update_global_data()
global.microcontrollers = global.microcontrollers or {}
global.player_data = global.player_data or {}
end

Event.register(Event.core_events.init, update_global_data)

script.on_configuration_changed(function(event)
update_global_data()

local mod_changes = event.mod_changes["m-microcontroller"]
if not (mod_changes and mod_changes.old_version) then return end

Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "m-microcontroller",
"version": "0.11.1",
"version": "0.11.2",
"factorio_version": "1.1",
"title": "MicroController",
"author": "Luke Perkin",
Expand Down

0 comments on commit c1b32ce

Please sign in to comment.