Spawner & 'Force' Setting [Solved]

Place to get help with not working mods / modding interface.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1455
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Spawner & 'Force' Setting [Solved]

Post by TheSAguy »

Hi,

I'd like to add a spawner to the game that will produce biters that attack both the player and vanilla biters.

Is this the best/correct way to implement a new force? Control.lua:

Code: Select all

require("defines")
--
---------------------------------------------				 
function Load_Me()

	game.create_force('vampire')
	game.forces['vampire'].set_cease_fire('enemy', false)
	game.forces['vampire'].set_cease_fire('player', false)

end

---------------------------------------------
script.on_init(Load_Me)
script.on_configuration_changed(Load_Me)
---------------------------------------------


Should there be a test to see if the force already exists?

Thanks.
Last edited by TheSAguy on Mon Apr 04, 2016 6:14 pm, edited 1 time in total.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1455
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Spawner & 'Force' Setting

Post by TheSAguy »

Initial post update
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5410
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Spawner & 'Force' Setting

Post by Klonan »

You don't need a check if you only do the on_configuration changed if the mod didn't exist before,
But a check if fairly easy,

Code: Select all

if game.forces['vampire'] == nil then create_force etc
Also you should need to set the cease fire, as the way you set it is the default already
orzelek
Smart Inserter
Smart Inserter
Posts: 3928
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Spawner & 'Force' Setting

Post by orzelek »

Klonan wrote:You don't need a check if you only do the on_configuration changed if the mod didn't exist before,
But a check if fairly easy,

Code: Select all

if game.forces['vampire'] == nil then create_force etc
Also you should need to set the cease fire, as the way you set it is the default already
Do you mean that he should not need to set the cease fire? Your last sentence is kind of confusing.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1455
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Spawner & 'Force' Setting

Post by TheSAguy »

orzelek wrote:
Klonan wrote:You don't need a check if you only do the on_configuration changed if the mod didn't exist before,
But a check if fairly easy,

Code: Select all

if game.forces['vampire'] == nil then create_force etc
Also you should need to set the cease fire, as the way you set it is the default already
Do you mean that he should not need to set the cease fire? Your last sentence is kind of confusing.
That's how I understood it "not", since by default different forces oppose each other.
orzelek
Smart Inserter
Smart Inserter
Posts: 3928
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Spawner & 'Force' Setting

Post by orzelek »

TheSAguy wrote:
orzelek wrote:
Klonan wrote:You don't need a check if you only do the on_configuration changed if the mod didn't exist before,
But a check if fairly easy,

Code: Select all

if game.forces['vampire'] == nil then create_force etc
Also you should need to set the cease fire, as the way you set it is the default already
Do you mean that he should not need to set the cease fire? Your last sentence is kind of confusing.
That's how I understood it "not", since by default different forces oppose each other.
If they are not case fire by default then not is wrong and sentence would need to be changed. I understood from that one that default is case fire.
Post Reply

Return to “Modding help”