Convert to enemy entity tool

This is the place to request new mods or give ideas about what could be done.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Convert to enemy entity tool

Post by aubergine18 »

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.
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.
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Convert to enemy entity tool

Post by prg »

data.lua

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",
    },
})
control.lua

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)
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.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Convert to enemy entity tool

Post by aubergine18 »

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.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Convert to enemy entity tool

Post by Nexela »

I am also working on a mod that will have this ability, Among many other things :)
Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: Convert to enemy entity tool

Post by Supercheese »

Why not just hover over the entity with the cursor and execute the command:

Code: Select all

/c game.player.selected.force = "enemy"
?
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Convert to enemy entity tool

Post by prg »

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"
?
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.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Post Reply

Return to “Ideas and Requests For Mods”