Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 0.5.4
Date: 26. 12. 2025
Changes:
- Allow rotation.
---------------------------------------------------------------------------------------------------
Version: 0.5.3
Date: XX. 07. 2025
Changes:
Expand Down
27 changes: 26 additions & 1 deletion control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ function init_globals()
storage.objects = storage.objects or {}
end

-- Resets rotation and flip to default
local function reset_rotation(entity)
entity.direction = defines.direction.north
entity.mirroring = false
end

-- Creates a table entry for this force if necessary
local function check_state(force)
if not storage.teams[force.index] then
Expand Down Expand Up @@ -299,6 +305,21 @@ local function OnEntityCreated(event)
radio_tune(entity)
check_channels()
end

-- lock rotation after building
local name = entity.name == "entity-ghost" and entity.ghost_name or entity.name
if name == "shortwave-radio" or name == "shortwave-port" then
reset_rotation(entity)
entity.rotatable = false
end
end

local function OnEntityRotated(event)
local entity = event.entity
local name = entity.name == "entity-ghost" and entity.ghost_name or entity.name
if name == "shortwave-radio" or name == "shortwave-port" then
reset_rotation(entity)
end
end

local function OnEntityRemoved(event)
Expand Down Expand Up @@ -431,6 +452,10 @@ script.on_event(defines.events.on_entity_cloned, OnEntityCreated, built_filters)
script.on_event(defines.events.script_raised_revive, OnEntityCreated, built_filters)
script.on_event(defines.events.on_space_platform_built_entity, OnEntityCreated, built_filters)

-- When Radios (or links) are rotated, revert it to default rotation
script.on_event(defines.events.on_player_rotated_entity, OnEntityRotated)
script.on_event(defines.events.on_player_flipped_entity, OnEntityRotated)

-- When radios (or links) are destroyed and raise an event, respond immediately
local mined_filters = {{filter="name", name="shortwave-radio"}, {filter="name", name="shortwave-link"}}
script.on_event(defines.events.on_player_mined_entity, OnEntityRemoved, mined_filters)
Expand Down Expand Up @@ -488,7 +513,7 @@ commands.add_command("shortwave-dump", "Dump storage to log", function() log(ser
commands.add_command("shortwave-debug", "Dump storage to console", function() game.print(serpent.block(storage)) end)


require("__gvv__.gvv")()
if script.active_mods["gvv"] then require("__gvv__.gvv")() end

------------------------------------------------------------------------------------
-- FIND LOCAL VARIABLES THAT ARE USED GLOBALLY --
Expand Down
3 changes: 0 additions & 3 deletions data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ data:extend{
"player-creation",
"not-flammable",
"not-blueprintable",
"not-rotatable",
"not-deconstructable",
"placeable-off-grid"
},
Expand All @@ -42,7 +41,6 @@ data:extend{
flags = {
"player-creation",
"not-flammable",
"not-rotatable",
"not-deconstructable",
"hide-alt-info",
},
Expand Down Expand Up @@ -80,7 +78,6 @@ data:extend{
flags = {
"player-creation",
"not-flammable",
"not-rotatable",
},
max_health = cc.max_health,
selectable_in_game = true,
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": "shortwave_fix",
"version": "0.5.3",
"version": "0.5.4",
"factorio_version": "2.0",
"title": "Shortwave for 2.0",
"author": "robot256",
Expand Down
10 changes: 10 additions & 0 deletions migrations/0.5.4-lock-rotation.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
for _,surface in pairs(game.surfaces) do
for _,entity in pairs(surface.find_entities_filtered{name="shortwave-radio"}) do
entity.rotatable = false
end
for _,entity in pairs(surface.find_entities_filtered{name="shortwave-port"}) do
entity.rotatable = false
end
end