For testing mods, it would be really useful if there was a way to click on one of my own entities on the map, maybe whilst holding a specific tool (item), to turn it in to an enemy entity (creating enemy player/force in the process if required).
When the entity is clicked, the mod deletes it and replaces it with the same entity but owned by enemy player. (Or just change the player without deleting it, if that's possible).
With the same tool in hand, if I click an enemy entity it then turns it back in to my entity.
Used in conjunction with CreativeMode, this would make testing mods a load faster. And it would also be a good example mod showing how to create custom 'tools' which can be used to have effect on buildings.
Convert to enemy entity tool
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Convert to enemy entity tool
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Re: Convert to enemy entity tool
data.lua
control.lua
Just a proof of concept, would still need a technology and recipe to become a proper mod. Also could use a GUI to select which force to convert into which other force, currently enemy <-> player is just hardcoded.
Code: Select all
data:extend({
{
type = "selection-tool",
name = "forcechanger",
icon = "__base__/graphics/icons/grass.png",
stack_size = 1,
flags = {"goes-to-quickbar"},
selection_color = { r = 0, g = 1, b = 1 },
alt_selection_color = { r = 0, g = 1, b = 1 },
selection_mode = {"buildable-type"},
alt_selection_mode = {"buildable-type"},
selection_cursor_box_type = "copy",
alt_selection_cursor_box_type = "copy",
},
})
Code: Select all
script.on_event(defines.events.on_player_selected_area, function(event)
if event.item ~= "forcechanger" then return end
for _, entity in pairs(event.entities) do
if entity.force == game.forces.enemy then entity.force = "player"
elseif entity.force == game.forces.player then entity.force = "enemy"
end
end
end)
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: Convert to enemy entity tool
Sorry I only just saw your reply - I'll give it a try, many thanks!!
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Re: Convert to enemy entity tool
I am also working on a mod that will have this ability, Among many other things 

-
- Filter Inserter
- Posts: 841
- Joined: Mon Sep 14, 2015 7:40 am
- Contact:
Re: Convert to enemy entity tool
Why not just hover over the entity with the cursor and execute the command:
?
Code: Select all
/c game.player.selected.force = "enemy"
Re: Convert to enemy entity tool
Less wear and tear on the keyboard if you want to change the owner of a whole base as you can just drag a rectangle around it.Supercheese wrote:Why not just hover over the entity with the cursor and execute the command:?Code: Select all
/c game.player.selected.force = "enemy"
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!