Page 1 of 1
Spawner & 'Force' Setting [Solved]
Posted: Thu Mar 24, 2016 2:57 am
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.
Re: Spawner & 'Force' Setting
Posted: Fri Apr 01, 2016 2:48 pm
by TheSAguy
Initial post update
Re: Spawner & 'Force' Setting
Posted: Fri Apr 01, 2016 2:56 pm
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
Re: Spawner & 'Force' Setting
Posted: Fri Apr 01, 2016 5:01 pm
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.
Re: Spawner & 'Force' Setting
Posted: Fri Apr 01, 2016 5:18 pm
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.
Re: Spawner & 'Force' Setting
Posted: Fri Apr 01, 2016 5:29 pm
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.