Page 1 of 1

quick question with control.lua

Posted: Wed Jan 18, 2017 2:43 am
by npuldon
Hello all!

I have a quick question on setting up a control.lua file. I'd like to enable several specific techs from the start of the game. What is the syntax for in a control.lua file so I do not need to use in-game /c scripts for each tech/game?

Example techs (from console commands wiki):
/c game.player.force.technologies['electric-energy-distribution-1'].researched=true
/c game.player.force.technologies['steel-processing'].researched=true

I have this example from arumba's accelerated start mod but I haven't had luck in using the above commands in the file to any success:

~~~~~~~~~~~~~~~~~~~~
script.on_event(defines.events.on_player_created, function(event)
game.players[event.player_index].color = {r = 0, g = 0, b = 1, a = .7}; -- change player color to blue
local player = game.players[event.player_index]
local inventory = player.get_inventory(defines.inventory.player_quickbar)
inventory.clear()
inventory.set_filter(1,"transport-belt")
inventory.set_filter(2,"inserter")

-- materials
player.insert{name="steel-axe", count=20}
.....
end)
~~~~~~~~~~~~~~~~~~~~~

Thank you so much for your help!

Re: quick question with control.lua

Posted: Wed Jan 18, 2017 2:59 am
by daniel34
Using the above code (local player = game.players[event.player_index]) you already have a shortcut to the player entity itself, so the code should be

Code: Select all

player.force.technologies['electric-energy-distribution-1'].researched=true
player.force.technologies['steel-processing'].researched=true

Re: quick question with control.lua

Posted: Wed Jan 18, 2017 3:11 am
by npuldon
Thank you kindly! that worked great. I was place the code one line to high up in the file.

Cheers