Skip to content

Commit c1b32ce

Browse files
committed
Update to 0.11.2
1 parent 12bec81 commit c1b32ce

3 files changed

Lines changed: 18 additions & 12 deletions

File tree

changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
---------------------------------------------------------------------------------------------------
2+
Version: 0.11.2
3+
Date: 06. 05. 2023
4+
Bugfixes:
5+
- Improved data stability at start
6+
---------------------------------------------------------------------------------------------------
27
Version: 0.11.1
38
Date: 13. 03. 2023
49
Locale:

control.lua

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,22 @@ require('mod-gui')
22
local Entity = require("stdlib/entity/entity")
33
local Surface = require("stdlib/surface")
44
local microcontroller = require('microcontroller')
5+
local Event = require('stdlib/event/event')
56
require('stdlib/string')
67
require('constants')
78
require('stdlib/area/tile')
89

10+
911
function get_player_data(player_index)
10-
if global.player_data == nil then
11-
global.player_data = {}
12-
end
1312
local player_data = global.player_data[player_index] or {}
1413
return player_data
1514
end
1615

1716
function set_player_data(player_index, data)
18-
if global.player_data == nil then
19-
global.player_data = {}
20-
end
2117
global.player_data[player_index] = data
2218
end
2319

20+
2421
-- Handle MicroController OPEN event.
2522
script.on_event("open-gui", function(event)
2623
local player_index = event.player_index
@@ -302,11 +299,6 @@ end
302299

303300
local update_tick_time = settings.startup["mc_update_tick_time"].value
304301
script.on_nth_tick(update_tick_time, function()
305-
-- Ensure we have a table to store microcontrollers in the global state.
306-
if not global.microcontrollers then
307-
global.microcontrollers = {}
308-
end
309-
310302
local do_update_gui = true
311303
if update_tick_time < 30 then
312304
do_update_gui = (game.tick % 60 == 0)
@@ -459,7 +451,16 @@ function microcontrollerGui( player, entity )
459451
set_player_data(player.index, player_data)
460452
end
461453

454+
function update_global_data()
455+
global.microcontrollers = global.microcontrollers or {}
456+
global.player_data = global.player_data or {}
457+
end
458+
459+
Event.register(Event.core_events.init, update_global_data)
460+
462461
script.on_configuration_changed(function(event)
462+
update_global_data()
463+
463464
local mod_changes = event.mod_changes["m-microcontroller"]
464465
if not (mod_changes and mod_changes.old_version) then return end
465466

info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "m-microcontroller",
3-
"version": "0.11.1",
3+
"version": "0.11.2",
44
"factorio_version": "1.1",
55
"title": "MicroController",
66
"author": "Luke Perkin",

0 commit comments

Comments
 (0)