How to remove enemies via console?
How to remove enemies via console?
So I accidentally put enemies on rich... like my entire starting area is just outlined in enemies. Is there any way to remove enemies via console command? Or to copy the map or edit properties or something so they are removed? I just wanted to play a map with rich minerals and wasn't paying attention to the properties before loading the map and now it's causing a problem for me. Luckily they're peaceful but still :\
Edit: And I mean remove the actual hives so they don't come back. I already know about the "kill all moving enemies" thing.
Edit: And I mean remove the actual hives so they don't come back. I already know about the "kill all moving enemies" thing.
-
- Smart Inserter
- Posts: 1847
- Joined: Sun Feb 23, 2014 3:37 pm
- Contact:
Re: How to remove enemies via console?
If you're not too far into the map, you could generate a map with the exchange string, and just turn biters off or whatever it is you want to do with them.
Re: How to remove enemies via console?
I'm really far I have fuel production going right now so yeah. I'd rather not start a new map if I didn't have to if possible.
Re: How to remove enemies via console?
Try this:
Should remove about 50% of spawners and worms. Remove the if .. end around entity.destroy to be really cruel
Code: Select all
/c local struct = {}
local c, t = 0, 0
for coord in game.getchunks() do
local X,Y = coord.x, coord.y
find = {"biter-spawner", "spitter-spawner", "small-worm-turret", "medium-worm-turret", "big-worm-turret"}
if game.ischunkgenerated{X,Y} then
struct[X.." "..Y] = {}
local area = {{X*32, Y*32}, {X*32 + 32, Y*32 + 32}}
for _,enemy in pairs(find) do
for _, entity in ipairs(game.findentitiesfiltered{area = area, name = enemy}) do
t = t+1
if math.random(1,10) > 5 then
c = c+1
entity.destroy()
end
end
end
if not struct[X.." "..Y][1] then struct[X.." "..Y] = nil end
end
end
game.player.print("Terminated "..c.." of "..t.."enemy structures")
Re: How to remove enemies via console?
There seems to be no way to change generation settings, so you'll probably have to run that script every once in a while.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
I also update mods, some of them even work.
Recently I did a mod tutorial.
Re: How to remove enemies via console?
Choumiko wrote:Try this:Should remove about 50% of spawners and worms. Remove the if .. end around entity.destroy to be really cruelCode: Select all
/c local struct = {} local c, t = 0, 0 for coord in game.getchunks() do local X,Y = coord.x, coord.y find = {"biter-spawner", "spitter-spawner", "small-worm-turret", "medium-worm-turret", "big-worm-turret"} if game.ischunkgenerated{X,Y} then struct[X.." "..Y] = {} local area = {{X*32, Y*32}, {X*32 + 32, Y*32 + 32}} for _,enemy in pairs(find) do for _, entity in ipairs(game.findentitiesfiltered{area = area, name = enemy}) do t = t+1 if math.random(1,10) > 5 then c = c+1 entity.destroy() end end end if not struct[X.." "..Y][1] then struct[X.." "..Y] = nil end end end game.player.print("Terminated "..c.." of "..t.."enemy structures")
I put this code in the console and it will eliminate the enemies?
Nice, I'll try it when I get a chance. If that's not how I do it, let me know please.
I appreciate the help guys, so much.
Re: How to remove enemies via console?
Hi All can some one please help with a new command of the above that will work on 12.8 and if it is posable i want to get rid of all spawners of the map this is a very large mapChoumiko wrote:Try this:Should remove about 50% of spawners and worms. Remove the if .. end around entity.destroy to be really cruelCode: Select all
/c local struct = {} local c, t = 0, 0 for coord in game.getchunks() do local X,Y = coord.x, coord.y find = {"biter-spawner", "spitter-spawner", "small-worm-turret", "medium-worm-turret", "big-worm-turret"} if game.ischunkgenerated{X,Y} then struct[X.." "..Y] = {} local area = {{X*32, Y*32}, {X*32 + 32, Y*32 + 32}} for _,enemy in pairs(find) do for _, entity in ipairs(game.findentitiesfiltered{area = area, name = enemy}) do t = t+1 if math.random(1,10) > 5 then c = c+1 entity.destroy() end end end if not struct[X.." "..Y][1] then struct[X.." "..Y] = nil end end end game.player.print("Terminated "..c.." of "..t.."enemy structures")
my co-op mate has finished playing factorio for the moment and i want to just use this map for refining my train skills and the wiping out the spawners is very time consuming as all enemy is at max evolution and just solid red around the base
Re: How to remove enemies via console?
Hi AllChoumiko wrote:Try this:Should remove about 50% of spawners and worms. Remove the if .. end around entity.destroy to be really cruelCode: Select all
/c local struct = {} local c, t = 0, 0 for coord in game.getchunks() do local X,Y = coord.x, coord.y find = {"biter-spawner", "spitter-spawner", "small-worm-turret", "medium-worm-turret", "big-worm-turret"} if game.ischunkgenerated{X,Y} then struct[X.." "..Y] = {} local area = {{X*32, Y*32}, {X*32 + 32, Y*32 + 32}} for _,enemy in pairs(find) do for _, entity in ipairs(game.findentitiesfiltered{area = area, name = enemy}) do t = t+1 if math.random(1,10) > 5 then c = c+1 entity.destroy() end end end if not struct[X.." "..Y][1] then struct[X.." "..Y] = nil end end end game.player.print("Terminated "..c.." of "..t.."enemy structures")
Can one of you bright coding guys help me out with a 12.8 compliant version of the above code
I am in a game that started of co-op and my mate has had all he can take of Factorio so i am going to use this map and a big sand box for refining my train skills
We started with the biters on max and evaluation is now max so the hole map is just about solid red outside my walls this isn’t a big problem as with the mods I have on I am now just about invincible it is just very time consuming to clear them out
If it is posable to have it remove all spawner like the kill all moving enemies code
I intent to do a big run around and stop them expanding back to the walls
Re: How to remove enemies via console?
grifter1 wrote:Can one of you bright coding guys help me out with a 12.8 compliant version of the above code
I am in a game that started of co-op and my mate has had all he can take of Factorio so i am going to use this map and a big sand box for refining my train skills
We started with the biters on max and evaluation is now max so the hole map is just about solid red outside my walls this isn’t a big problem as with the mods I have on I am now just about invincible it is just very time consuming to clear them out
If it is posable to have it remove all spawner like the kill all moving enemies code
I intent to do a big run around and stop them expanding back to the walls
Code: Select all
local c = 0, 0
local s = game.local_player.surface
for coord in s.get_chunks() do
local X,Y = coord.x, coord.y
find = {"biter-spawner", "spitter-spawner", "small-worm-turret", "medium-worm-turret", "big-worm-turret"}
if s.is_chunk_generated{X,Y} then
local area = {{X*32, Y*32}, {X*32 + 32, Y*32 + 32}}
for _,enemy in pairs(find) do
for _, entity in ipairs(s.find_entities_filtered{area = area, name = enemy}) do
c = c+1
entity.destroy()
end
end
end
end
game.local_player.print("Terminated "..c.." enemy structures")
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: How to remove enemies via console?
thanks for the quick replyprg wrote:grifter1 wrote:Can one of you bright coding guys help me out with a 12.8 compliant version of the above code
I am in a game that started of co-op and my mate has had all he can take of Factorio so i am going to use this map and a big sand box for refining my train skills
We started with the biters on max and evaluation is now max so the hole map is just about solid red outside my walls this isn’t a big problem as with the mods I have on I am now just about invincible it is just very time consuming to clear them out
If it is posable to have it remove all spawner like the kill all moving enemies code
I intent to do a big run around and stop them expanding back to the wallsCode: Select all
local c = 0, 0 local s = game.local_player.surface for coord in s.get_chunks() do local X,Y = coord.x, coord.y find = {"biter-spawner", "spitter-spawner", "small-worm-turret", "medium-worm-turret", "big-worm-turret"} if s.is_chunk_generated{X,Y} then local area = {{X*32, Y*32}, {X*32 + 32, Y*32 + 32}} for _,enemy in pairs(find) do for _, entity in ipairs(s.find_entities_filtered{area = area, name = enemy}) do c = c+1 entity.destroy() end end end end game.local_player.print("Terminated "..c.." enemy structures")
but it didnt work do i need to change the local area = {{X*32, Y*32}, {X*32 + 32, Y*32 + 32}} as im a long way away from the starting point
Re: How to remove enemies via console?
You don't need to change anything, that area doesn't have anything to do with your current position. Did you actually execute that code as a command, not say it as a chat message? DId you get some kind of error message?grifter1 wrote:thanks for the quick reply
but it didnt work do i need to change the local area = {{X*32, Y*32}, {X*32 + 32, Y*32 + 32}} as im a long way away from the starting point
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: How to remove enemies via console?
Moved from General to Gamplay Help.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Re: How to remove enemies via console?
Thanks for trying to help me outprg wrote:You don't need to change anything, that area doesn't have anything to do with your current position. Did you actually execute that code as a command, not say it as a chat message? DId you get some kind of error message?grifter1 wrote:thanks for the quick reply
but it didnt work do i need to change the local area = {{X*32, Y*32}, {X*32 + 32, Y*32 + 32}} as im a long way away from the starting point
Yes I am entering it as a command and I get the noise that happens when you use a command but all the bases are still there I did go to check and entered the code while standing in a very large base
No error code but nothing happened
I did the kill all command and that removed all the creeps
I did change the game to peaceful mode and have a lot of mods running
Am I able to get a log file to help you know what is happening?
And what I was trying to say is that I have a very large area cleared of enemies
Is this only trying to clear a 32x32 from the starting spot ?
Re: How to remove enemies via console?
Did you get the message "Terminated 0 enemy structures" at the end?grifter1 wrote:No error code but nothing happened
Does a mod change the name of the spawners? Point the mouse at one and run game.local_player.print(game.local_player.selected.name)grifter1 wrote:I did change the game to peaceful mode and have a lot of mods running
Next step would be to add more prints...grifter1 wrote:Am I able to get a log file to help you know what is happening?
The 32s in there get multiplied by X and Y, which are the coordinates of the chunk we're currently iterating over. And we're iterating over all the chunks, so it should be fine.grifter1 wrote:And what I was trying to say is that I have a very large area cleared of enemies
Is this only trying to clear a 32x32 from the starting spot ?
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: How to remove enemies via console?
not getting a message at all i have attached a img after the commandprg wrote:Did you get the message "Terminated 0 enemy structures" at the end?
prg wrote:Does a mod change the name of the spawners? Point the mouse at one and run game.local_player.print(game.local_player.selected.name)
Code: Select all
game.local_player.print(game.local_player.selected.name
i don't think the mods i have change spawners list of mods below
- 5dim_automatization_2.0.0.zip
5dim_core_2.0.0.zip
5dim_decoration_2.0.0.zip
5dim_energy_2.0.0.zip
5dim_logistic_2.0.0.zip
5dim_mining_2.0.0.zip
5dim_module_2.0.0.zip
5dim_resources_2.0.0.zip
5dim_trains_2.0.0.zip
5dim_transport_2.0.0.zip
5dim_vehicle_2.0.0.zip
AdvancedEquipment_0.4.0.zip
Advanced_Personal_Roboports_0.1.0.zip
Crafting_Speed_Research_0.1.0.zip
FARL_0.4.2.zip
Stainless Steel Wagon_1.0.0.zip
SupremeWarfare_1.0.5.zip
Terraforming_0.12.0.zip
UraniumPower_0.6.2.zip
Warehousing_0.0.3.zip
Yuoki_0.2.36.zip
air-filtering_0.3.2.zip
fluid-barrel_1.0.1.zip
gravestone-mod_1.0.2.zip
mod-list.json
reverse-factory_1.1.3.zip
yi_railway_0.0.3.zip
i have been playing with other commands and it looks like the game will only take commands with the multiplayer prefix and i checked i loaded it one player
- Attachments
-
- after console command.JPG (123.06 KiB) Viewed 23763 times
Re: How to remove enemies via console?
Right, you're just missing the /c there. That's needed to execute commands, without it you're posting a chat message.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: How to remove enemies via console?
that was it i just copied it from the box sorryprg wrote:Right, you're just missing the /c there. That's needed to execute commands, without it you're posting a chat message.
and i cant thank you enough
-
- Long Handed Inserter
- Posts: 59
- Joined: Sun Jul 26, 2015 5:08 pm
- Contact:
Re: How to remove enemies via console?
Sorry for necroing. I used this, and it appears to have removed all enemies from the map, instead of ~50%. Is there any way to respawn them?
Re: How to remove enemies via console?
sarcolopter wrote:Sorry for necroing. I used this, and it appears to have removed all enemies from the map, instead of ~50%. Is there any way to respawn them?
Go back one save ?
-
- Long Handed Inserter
- Posts: 59
- Joined: Sun Jul 26, 2015 5:08 pm
- Contact:
Re: How to remove enemies via console?
That would defeat the purpose, since I'd be back right where I started.mophydeen wrote:sarcolopter wrote:Sorry for necroing. I used this, and it appears to have removed all enemies from the map, instead of ~50%. Is there any way to respawn them?
Go back one save ?