Skip to content

Commit f50c34f

Browse files
committed
Update to 0.10.7
1 parent 6915cc2 commit f50c34f

6 files changed

Lines changed: 82 additions & 61 deletions

File tree

changelog.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
---------------------------------------------------------------------------------------------------
2+
Version: 0.10.7
3+
Date: 19. 08. 2021
4+
Changes:
5+
- Refactored slightly
6+
- Improved stability slightly
7+
Bugfixes:
8+
- Fixed "bno"
9+
---------------------------------------------------------------------------------------------------
210
Version: 0.10.6
311
Date: 19. 08. 2021
412
Changes:

compiler.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ local gsub = string.gsub
1111
-- Split a string in to tokens using whitespace as a seperator.
1212
local function split( str )
1313
local result = {}
14-
for sub in string.gmatch( str, "%S+" ) do
15-
table.insert( result, sub )
14+
for _sub in string.gmatch( str, "%S+" ) do
15+
table.insert( result, _sub )
1616
end
1717
return result
1818
end
@@ -518,7 +518,7 @@ local function eval( ast, control, memory, modules, program_counter, clock )
518518
local _in = _[1]
519519
assert_in_mem_or_val(_in)
520520
local result = bit32.bnot(memcount_or_val(_in))
521-
setmem_count(const_num(_out.val), result)
521+
setmem_count(const_num(_in.val), result)
522522
end,
523523
slp = function(_) -- SLP M/I -- Sleep
524524
assert_in(_)

control.lua

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@ function set_player_data(player_index, data)
2222
end
2323

2424
-- Handle MicroController OPEN event.
25-
script.on_event("microcontroller-open", function(event)
26-
local player = game.players[event.player_index]
25+
script.on_event("open-gui", function(event)
26+
local player_index = event.player_index
27+
local player = game.get_player(player_index)
28+
if not (player and player.valid) then return end
2729
local entity = player.selected
28-
if entity and entity.name == "microcontroller" then
30+
if not (entity and entity.valid) then return end
31+
32+
if entity.name == "microcontroller" then
2933
entity.operable = false
30-
local player_data = get_player_data(event.player_index)
34+
local player_data = get_player_data(player_index)
3135
player_data.open_microcontroller = entity
32-
set_player_data(event.player_index, player_data)
36+
set_player_data(player_index, player_data)
3337
microcontrollerGui(player, entity)
3438
end
3539
end)
@@ -111,17 +115,21 @@ end)
111115

112116
-- Handle MicroController GUI Close event.
113117
script.on_event("microcontroller-close", function(event)
114-
local player = game.players[event.player_index]
115-
local player_data = get_player_data(event.player_index)
118+
local player_index = event.player_index
119+
local player = game.get_player(player_index)
120+
if not (player and player.valid) then return end
121+
122+
local player_data = get_player_data(player_index)
116123
if player_data.open_microcontroller_gui then
117124
microcontroller.update_program_text(player_data.open_microcontroller, player_data.open_microcontroller_gui.outer.scroll_pane.inner['program-input'].text)
118125
player_data.open_microcontroller_gui.destroy()
119126
player_data.open_microcontroller_gui = nil
120127
end
121-
if player.gui.center['mc-docs'] then
122-
player.gui.center['mc-docs'].destroy()
128+
local docs = player.gui.center['mc-docs']
129+
if docs then
130+
docs.destroy()
123131
end
124-
set_player_data(event.player_index, player_data)
132+
set_player_data(player_index, player_data)
125133
end)
126134

127135
-- Handle GUI text changed event.
@@ -160,12 +168,13 @@ local function update_topics_gui(gui)
160168
gui.add{type = "label", caption = {"", {"microcontroller.example"}, {"colon"}}}
161169
local textbox = gui.add{type = "text-box", text = topic.example}
162170
textbox.read_only = true
163-
textbox.style.maximal_width = 0
164-
textbox.style.minimal_height = 60
165-
textbox.style.maximal_height = 140
166-
textbox.style.horizontally_stretchable = true
167-
textbox.style.vertically_stretchable = true
168-
textbox.style.height = 130
171+
local style = textbox.style
172+
style.maximal_width = 0
173+
style.minimal_height = 60
174+
style.maximal_height = 140
175+
style.horizontally_stretchable = true
176+
style.vertically_stretchable = true
177+
style.height = 130
169178
end
170179
end
171180
end
@@ -174,7 +183,7 @@ end
174183

175184
-- Handle selection in GUI.
176185
script.on_event(defines.events.on_gui_selection_state_changed, function(event)
177-
local player = game.players[event.player_index]
186+
local player = game.get_player(event.player_index)
178187
if not (player and player.valid) then return end
179188
local element = event.element
180189
if not (element and element.valid and element.name) then return end
@@ -186,10 +195,10 @@ end)
186195

187196
-- Handle GUI button presses.
188197
script.on_event(defines.events.on_gui_click, function(event)
189-
local player = game.players[event.player_index]
198+
local player = game.get_player(event.player_index)
190199
if not (player and player.valid) then return end
191-
local player_data = get_player_data(event.player_index)
192200
local element = event.element
201+
local player_data = get_player_data(event.player_index)
193202
if element and element.valid and element.name then
194203
-- RUN button pressed:
195204
if element.name == "run-program" then
@@ -282,7 +291,7 @@ script.on_event(microcontroller.event_halt, function(event)
282291
end
283292
end)
284293

285-
function signalToSpritePath(signal)
294+
local function signalToSpritePath(signal)
286295
if signal.type == "virtual" then
287296
return "virtual-signal/" .. signal.name
288297
else

data.lua

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ require('stdlib/table')
22
require('constants')
33
require('prototypes/style')
44

5+
if data.raw["custom-input"]["open-gui"] == nil then
6+
data.raw["custom-input"]["open-gui"] = {
7+
type = "custom-input",
8+
name = "open-gui",
9+
key_sequence = "",
10+
linked_game_control = "open-gui"
11+
}
12+
end
13+
514
data:extend{
615
table.merge(table.deepcopy(data.raw['arithmetic-combinator']['arithmetic-combinator']), {
716
name = "microcontroller",
@@ -34,54 +43,49 @@ data:extend{
3443
subgroup = "circuit-network",
3544
order = 'zz'
3645
},
37-
{
38-
type = "technology",
39-
name = "microcontroller",
40-
icon_size = 128,
41-
icon = "__m-microcontroller__/graphics/microchip_large.png",
42-
effects = {
43-
{
44-
type = "unlock-recipe",
45-
recipe = "microcontroller",
46-
},
47-
{
48-
type = "unlock-recipe",
49-
recipe = "microcontroller-ram",
50-
},
51-
},
52-
prerequisites = { "circuit-network", "advanced-electronics" },
53-
unit = {
54-
count = 250,
55-
ingredients = {
56-
{"automation-science-pack", 1},
57-
{"logistic-science-pack", 1},
58-
},
59-
time = 30,
46+
{
47+
type = "technology",
48+
name = "microcontroller",
49+
icon_size = 128,
50+
icon = "__m-microcontroller__/graphics/microchip_large.png",
51+
effects = {
52+
{
53+
type = "unlock-recipe",
54+
recipe = "microcontroller",
55+
},
56+
{
57+
type = "unlock-recipe",
58+
recipe = "microcontroller-ram",
59+
},
60+
},
61+
prerequisites = { "circuit-network", "advanced-electronics" },
62+
unit = {
63+
count = 250,
64+
ingredients = {
65+
{"automation-science-pack", 1},
66+
{"logistic-science-pack", 1},
67+
},
68+
time = 30,
6069
},
6170
localised_description = {"microcontroller.doc.overview_description"},
62-
order = "c-g-b",
63-
},
71+
order = "c-g-b",
72+
},
6473
{
6574
type = "recipe",
6675
name = "microcontroller",
67-
enabled = false,
76+
enabled = false,
6877
ingredients = {{"arithmetic-combinator", 3}, {"decider-combinator", 3}},
6978
energy_required = 1,
7079
results = {{"microcontroller", 1}}
7180
},
7281
{
7382
type = "recipe",
7483
name = "microcontroller-ram",
75-
enabled = false,
84+
enabled = false,
7685
ingredients = {{"arithmetic-combinator", 3}, {"advanced-circuit", 2}},
7786
energy_required = 1,
7887
results = {{"microcontroller-ram", 1}}
7988
},
80-
{
81-
type = "custom-input",
82-
name = "microcontroller-open",
83-
key_sequence = "mouse-button-1",
84-
},
8589
{
8690
type = "custom-input",
8791
name = "microcontroller-close",
@@ -217,7 +221,7 @@ for i = 1, MC_LINES do
217221
width = 42,
218222
height = h,
219223
x = 84,
220-
y = y
224+
y = y
221225
}
222226
}
223-
end
227+
end

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.10.6",
3+
"version": "0.10.7",
44
"factorio_version": "1.1",
55
"title": "MicroController",
66
"author": "Luke Perkin",

prototypes/style.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ default_gui["mc_notice_textbox"] = {
1111
padding = 0,
1212
active_background = {
1313
filename = "__m-microcontroller__/graphics/black.png",
14-
width = 1,
15-
height = 1
14+
width = 1,
15+
height = 1
1616
},
1717
default_background = {
1818
filename = "__m-microcontroller__/graphics/grey.png",
@@ -32,7 +32,7 @@ default_gui["mc_program_input"] = {
3232
minimal_width = 280,
3333
natural_width = 0,
3434
maximal_width = 0,
35-
word_wrap = false,
35+
word_wrap = false,
3636
padding = 0,
3737
horizontally_stretchable = "on",
3838
vertically_stretchable = "on",

0 commit comments

Comments
 (0)