Page 1 of 1

Change tech to researched

Posted: Tue Jan 09, 2018 4:07 pm
by BBoaSorte
Hello..
there's some way to set a technology to be researched without use /c ?

i tried some codes, but didn't work..

i tried to make the worker robot speed researched, but still remain unresearched..

Code: Select all

script.on_event(defines.events.on_player_joined_game, function(event)

local player = game.players[event.player_index]
data.raw['technology']['worker-robots-speed-1'].researched = true

end)
i'm trying to load this when i load a saved game

thanks for the help

Re: Change tech to researched

Posted: Tue Jan 09, 2018 4:46 pm
by DaveMcW

Code: Select all

player.force.technologies['worker-robots-speed-1'].researched = true

Re: Change tech to researched

Posted: Tue Jan 09, 2018 4:58 pm
by BBoaSorte
DaveMcW wrote:

Code: Select all

player.force.technologies['worker-robots-speed-1'].researched = true

thanks.. This works on a new game. Any sugestion to make it work on a loaded save?

Re: Change tech to researched

Posted: Tue Jan 09, 2018 11:48 pm
by darkfrei
BBoaSorte wrote:
DaveMcW wrote:

Code: Select all

player.force.technologies['worker-robots-speed-1'].researched = true

thanks.. This works on a new game. Any sugestion to make it work on a loaded save?

Code: Select all

script.on_configuration_changed(function(data)
  -- here forces iterator, except neutral and enemy; or just only one force
  game.forces['player'].technologies['worker-robots-speed-1'].researched = true
end)

Re: Change tech to researched

Posted: Wed Jan 10, 2018 3:34 pm
by BBoaSorte
darkfrei wrote:

Code: Select all

script.on_configuration_changed(function(data)
  -- here forces iterator, except neutral and enemy; or just only one force
  game.forces['player'].technologies['worker-robots-speed-1'].researched = true
end)
There's something to trigger this?

Re: Change tech to researched

Posted: Wed Jan 10, 2018 4:01 pm
by darkfrei
BBoaSorte wrote:
darkfrei wrote:

Code: Select all

script.on_configuration_changed(function(data)
  -- here forces iterator, except neutral and enemy; or just only one force
  game.forces['player'].technologies['worker-robots-speed-1'].researched = true
end)
There's something to trigger this?
http://lua-api.factorio.com/latest/LuaB ... on_changed

Re: Change tech to researched

Posted: Wed Jan 10, 2018 4:18 pm
by BBoaSorte
remains unresearched..
Well.. Thanks for the help. I'll start a new map.

Re: Change tech to researched

Posted: Wed Jan 10, 2018 4:59 pm
by darkfrei
BBoaSorte wrote:remains unresearched..
Well.. Thanks for the help. I'll start a new map.
It means that you cave custom force, not the 'player'

Re: Change tech to researched

Posted: Wed Jan 10, 2018 5:52 pm
by BBoaSorte
darkfrei wrote:
BBoaSorte wrote:remains unresearched..
Well.. Thanks for the help. I'll start a new map.
It means that you cave custom force, not the 'player'
i dont know what this means, but i tried to install a new mod to force the change

Re: Change tech to researched

Posted: Wed Jan 10, 2018 7:37 pm
by darkfrei
BBoaSorte wrote:i dont know what this means, but i tried to install a new mod to force the change
This mod writes a text on every on_configuration_changed. If it works, then your force name isn't 'player'

Type this to console:

Code: Select all

/c game.player.print(game.player.force.name)

Re: Change tech to researched

Posted: Thu Jan 11, 2018 9:38 am
by bobingabout
If you add it to a mod that was already used when you saved the game, then the configuration hasn't changed, so the on_configuration_changed script isn't triggered.

I usually do these sorts of things in migration scripts, not control scripts... however, if you just add 1 to your mod version number, this script should then work.

Re: Change tech to researched

Posted: Thu Jan 11, 2018 11:21 am
by darkfrei
bobingabout wrote:If you add it to a mod that was already used when you saved the game, then the configuration hasn't changed, so the on_configuration_changed script isn't triggered.
on_configuration_changed(f)
Register a function to be run when mod configuration changes. This is called any time the game version changes, prototypes change, startup mod settings change, and any time mod versions change including adding or removing mods.