By RCON spawned Biter won´t attack

Place to get help with not working mods / modding interface.
Post Reply
DrMohn
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed Dec 07, 2022 8:56 am
Contact:

By RCON spawned Biter won´t attack

Post by DrMohn »

Hey Guys!

I must admid that i have pretty much no idea about programming LUA. What i do is a little Python and I have a little Python-based Bot which interacts with my Factorio-Server by RCON.
I tried google for some hours now but just can´t find any solution. You guys probably will be able to help me.

I spawn some biters using this command:

Code: Select all

/sc local player = game.players['player'] 
local surface = player.surface for i = 1,10 do 
local position = surface.find_non_colliding_position('small-biter', player.position, 100, 1) 
if not position then rcon.print('') end 
surface.create_entity{name = 'small-biter', position = {position.x+20, position.y+40}, force = game.forces.enemy} end
The spawning does work fine. The biters do attack any military unit (including the player), but if they happen to spawn in an area with production units only the just idle. And i just don´t understand why. I tried to force them into attackmode with
entity.set_command
but after they killed me they started idle again instead of destroying my factory. How can i spawn them so that they go berserk and just destroy everthing?

Sry for my bad english! Hope you get my point anyway

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: By RCON spawned Biter won´t attack

Post by Klonan »

You can use `entity.set_command` and set an Idle command, with the distraction type of 'by_anything':
https://lua-api.factorio.com/latest/Con ... ml#Command

DrMohn
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed Dec 07, 2022 8:56 am
Contact:

Re: By RCON spawned Biter won´t attack

Post by DrMohn »

thx!

i just tried it out and i really don´t get what i did wrong..

Code: Select all

/sc local player = game.players['player'] 
local surface = player.surface for i = 1,10 do 
local position = surface.find_non_colliding_position('small-biter', player.position, 100, 1) 
if not position then rcon.print('') end 
local bite = surface.create_entity{name = 'small-biter', position = {position.x+20, position.y+40}, force = game.forces.enemy} 
bite.set_command({type=defines.command.wander, distraction=defines.distraction.by_anything, radius=50})
end
Output:
Cannot execute command. Error: LuaEntity doesn't contain key set_distraction_comand.
I don´t get why the variable "bite" is no LuaEntity. 1 Biter got spawned and then the code got interrupted. A Biter is a LuaEntity isn´t it?

I am really sure i am making rookie mistakes here, sry :-(

Edit: found this mistake.. Typo.. second "m" in command missing.. still not working but need time to get my head around the new error

Edit 2: Just a whole lot of typos.. sry for my post above :-( fixed the code-sample which works now. Not ideal because the biter attack anything, idle, attack the next building, etc. will try to improve it. if anyone is interessted i can post the final code here?!

Thx so much for helping me through this

Post Reply

Return to “Modding help”