From 6f40d7f8f5a42c52d2052379e983fc6882c0a0a5 Mon Sep 17 00:00:00 2001 From: Sun Serega Date: Thu, 6 Jun 2024 22:23:41 +0200 Subject: [PATCH 1/4] Add support for `compaktcircuit` --- .gitignore | 1 + control.lua | 55 ++++++++++++++++++++++++++++++++++++++++- prototypes/entities.lua | 17 +++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c4c4ffc..b02c72e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.zip +/.vscode/** diff --git a/control.lua b/control.lua index 4db7890..c850cc6 100644 --- a/control.lua +++ b/control.lua @@ -60,4 +60,57 @@ script.on_event(defines.events.on_built_entity, function(event) onBuilt(event.cr script.on_event(defines.events.on_robot_built_entity, function(event) onBuilt(event.created_entity) end, filters) script.on_event(defines.events.script_raised_built, function(event) onBuilt(event.entity) end) script.on_event(defines.events.script_raised_revive, function(event) onBuilt(event.entity) end) -script.on_event(defines.events.on_entity_cloned, function(event) onBuilt(event.destination) end) \ No newline at end of file +script.on_event(defines.events.on_entity_cloned, function(event) onBuilt(event.destination) end) + + + +if script.active_mods["compaktcircuit"] then + + local function defineCompakt() + + remote.add_interface("pushbutton+compaktcircuit", { + + get_info = function(entity) + --game.print("getting info") + return nil -- pushbutton has no savable state + end, + + create_packed_entity = function(info, surface, position, force) + --game.print("creating packed") + local entity = surface.create_entity { + name = "pushbutton-packed", + force = force, + position = position, + direction = info and info.direction, + } + local control = entity.get_or_create_control_behavior() + control.enabled = false + return entity + end, + + create_entity = function(info, surface, force) + --game.print("creating normal") + local entity = surface.create_entity { + name = "pushbutton", + force = force, + position = info and info.position, + direction = info and info.direction, + } + local control = entity.get_or_create_control_behavior() + control.enabled = false + return entity + end + + }) + + remote.call("compaktcircuit", "add_combinator", { + name = "pushbutton", + packed_names = { "pushbutton-packed" }, + interface_name = "pushbutton+compaktcircuit" + }) + + end + script.on_load(defineCompakt) + script.on_init(defineCompakt) + +end \ No newline at end of file diff --git a/prototypes/entities.lua b/prototypes/entities.lua index 5cccf5a..ac10e4e 100644 --- a/prototypes/entities.lua +++ b/prototypes/entities.lua @@ -74,3 +74,20 @@ p.circuit_wire_connection_points = } data:extend{p} + + + +if mods["compaktcircuit"] then + + local compakt_entity = table.deepcopy(p) + compakt_entity.name = "pushbutton-packed" + compakt_entity.flags = { 'placeable-off-grid' , "hidden", "hide-alt-info", "not-on-map", "not-upgradable", "not-deconstructable", "not-blueprintable" } + compakt_entity.collision_mask = {} + compakt_entity.minable = nil + compakt_entity.selectable_in_game = false + compakt_entity.collision_box = nil + compakt_entity.sprites = nil + compakt_entity.activity_led_sprites = nil + data:extend { compakt_entity } + +end \ No newline at end of file From 3ed30895889c0cded4c09577a37812265f1938e8 Mon Sep 17 00:00:00 2001 From: Sun Serega Date: Fri, 7 Jun 2024 12:33:17 +0200 Subject: [PATCH 2/4] Remove the packed version --- control.lua | 15 ++------------- prototypes/entities.lua | 19 +------------------ 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/control.lua b/control.lua index c850cc6..515d95f 100644 --- a/control.lua +++ b/control.lua @@ -71,25 +71,14 @@ if script.active_mods["compaktcircuit"] then remote.add_interface("pushbutton+compaktcircuit", { get_info = function(entity) - --game.print("getting info") return nil -- pushbutton has no savable state end, create_packed_entity = function(info, surface, position, force) - --game.print("creating packed") - local entity = surface.create_entity { - name = "pushbutton-packed", - force = force, - position = position, - direction = info and info.direction, - } - local control = entity.get_or_create_control_behavior() - control.enabled = false - return entity + return nil end, create_entity = function(info, surface, force) - --game.print("creating normal") local entity = surface.create_entity { name = "pushbutton", force = force, @@ -105,7 +94,7 @@ if script.active_mods["compaktcircuit"] then remote.call("compaktcircuit", "add_combinator", { name = "pushbutton", - packed_names = { "pushbutton-packed" }, + packed_names = nil, interface_name = "pushbutton+compaktcircuit" }) diff --git a/prototypes/entities.lua b/prototypes/entities.lua index ac10e4e..d981acb 100644 --- a/prototypes/entities.lua +++ b/prototypes/entities.lua @@ -73,21 +73,4 @@ p.circuit_wire_connection_points = circuit_wire_connection_points, } -data:extend{p} - - - -if mods["compaktcircuit"] then - - local compakt_entity = table.deepcopy(p) - compakt_entity.name = "pushbutton-packed" - compakt_entity.flags = { 'placeable-off-grid' , "hidden", "hide-alt-info", "not-on-map", "not-upgradable", "not-deconstructable", "not-blueprintable" } - compakt_entity.collision_mask = {} - compakt_entity.minable = nil - compakt_entity.selectable_in_game = false - compakt_entity.collision_box = nil - compakt_entity.sprites = nil - compakt_entity.activity_led_sprites = nil - data:extend { compakt_entity } - -end \ No newline at end of file +data:extend{p} \ No newline at end of file From 5bd94cacafbe36e8b5984899e67909114977185f Mon Sep 17 00:00:00 2001 From: Sun Serega Date: Fri, 7 Jun 2024 12:39:37 +0200 Subject: [PATCH 3/4] cleanup --- prototypes/entities.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prototypes/entities.lua b/prototypes/entities.lua index d981acb..5cccf5a 100644 --- a/prototypes/entities.lua +++ b/prototypes/entities.lua @@ -73,4 +73,4 @@ p.circuit_wire_connection_points = circuit_wire_connection_points, } -data:extend{p} \ No newline at end of file +data:extend{p} From 826d60ee1cf0c539faf57e2cce0843733f5c253c Mon Sep 17 00:00:00 2001 From: Sun Serega Date: Fri, 7 Jun 2024 13:38:24 +0200 Subject: [PATCH 4/4] cleanup gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index b02c72e..c4c4ffc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ *.zip -/.vscode/**