Change tech to researched

Place to get help with not working mods / modding interface.
BBoaSorte
Burner Inserter
Burner Inserter
Posts: 5
Joined: Tue Aug 08, 2017 7:54 pm
Contact:

Change tech to researched

Post 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
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Change tech to researched

Post by DaveMcW »

Code: Select all

player.force.technologies['worker-robots-speed-1'].researched = true
BBoaSorte
Burner Inserter
Burner Inserter
Posts: 5
Joined: Tue Aug 08, 2017 7:54 pm
Contact:

Re: Change tech to researched

Post 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?
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Change tech to researched

Post 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)
BBoaSorte
Burner Inserter
Burner Inserter
Posts: 5
Joined: Tue Aug 08, 2017 7:54 pm
Contact:

Re: Change tech to researched

Post 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?
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Change tech to researched

Post 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
BBoaSorte
Burner Inserter
Burner Inserter
Posts: 5
Joined: Tue Aug 08, 2017 7:54 pm
Contact:

Re: Change tech to researched

Post by BBoaSorte »

remains unresearched..
Well.. Thanks for the help. I'll start a new map.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Change tech to researched

Post 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'
BBoaSorte
Burner Inserter
Burner Inserter
Posts: 5
Joined: Tue Aug 08, 2017 7:54 pm
Contact:

Re: Change tech to researched

Post 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
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Change tech to researched

Post 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)
Attachments
Easy_Mod_0.0.1.zip
For 0.16
(804 Bytes) Downloaded 57 times
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Change tech to researched

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Change tech to researched

Post 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.
Post Reply

Return to “Modding help”