I have a few scenarios that I had working nicely on 12.x and after updating to 14.x none of the commands that I had in control.lua work, understandably so. I've exhausted the search here and on google, but I can't find an entry level description on how to get some text to display when a player loads up the scenario. This would allow me to give some mission objectives and a direction of what the player should be doing.
I'm guessing something like this is close:
script.on_init(function()
game.show_message_dialog{text={"Intro Text 1"}, pointto = {type = "entity", entity = game.player.character}}
game.show_message_dialog{text={"Intro Text 2"}, pointto = {type = "entity", entity = game.player.character}}
game.show_message_dialog{text={"Intro Text 3"}, pointto = {type = "entity", entity = game.player.character}}
game.player.force.technologies["walls"].researched = true
game.player.force.technologies["military"].researched = true
game.player.force.technologies["automation"].researched = true
game.player.force.technologies["turrets"].researched = true end)
I'd also like to give the player a few items to start, but a chest next to the spawn kinda kills the story.
Thanks in advance.
Displaying Text and Giving Items - Single Player Scenario
-
- Inserter
- Posts: 22
- Joined: Tue Jul 26, 2016 1:35 am
- Contact:
Re: Displaying Text and Giving Items - Single Player Scenario
It's point_to, see here: http://lua-api.factorio.com/latest/LuaG ... age_dialogjohnmegacycle wrote:pointto = {type = "entity", entity = game.player.character}
-
- Inserter
- Posts: 22
- Joined: Tue Jul 26, 2016 1:35 am
- Contact:
Re: Displaying Text and Giving Items - Single Player Scenario
Thanks, I'll give that a try later tonight.daniel34 wrote:It's point_to, see here: http://lua-api.factorio.com/latest/LuaG ... age_dialogjohnmegacycle wrote:pointto = {type = "entity", entity = game.player.character}
I'm hoping the research is correct, but is there a list of what the lua equivalents are for research names to ensure I'm granting the right ones?
Also, would you happen to know where I can find the code to give the player items?
Re: Displaying Text and Giving Items - Single Player Scenario
You can find the actual names for technologies in your Factorio folder in data\base\prototypes\technology\technology.lua, or in data\base\locale\en\base.cfg in the [technology-name] section.johnmegacycle wrote:I'm hoping the research is correct, but is there a list of what the lua equivalents are for research names to ensure I'm granting the right ones?
Also, would you happen to know where I can find the code to give the player items?
For the code to give the player items look in data\base\scenarios\freeplay\control.lua:
Code: Select all
script.on_event(defines.events.on_player_created, function(event)
local player = game.players[event.player_index]
player.insert{name="iron-plate", count=8}
player.insert{name="pistol", count=1}
player.insert{name="firearm-magazine", count=10}
player.insert{name="burner-mining-drill", count = 1}
player.insert{name="stone-furnace", count = 1}
player.force.chart(player.surface, {{player.position.x - 200, player.position.y - 200}, {player.position.x + 200, player.position.y + 200}})
if (#game.players <= 1) then
game.show_message_dialog{text = {"msg-intro"}}
else
player.print({"msg-intro"})
end
end)
-
- Inserter
- Posts: 22
- Joined: Tue Jul 26, 2016 1:35 am
- Contact:
Re: Displaying Text and Giving Items - Single Player Scenario
Oh my gosh (blush).daniel34 wrote:You can find the actual names for technologies in your Factorio folder in data\base\prototypes\technology\technology.lua, or in data\base\locale\en\base.cfg in the [technology-name] section.johnmegacycle wrote:I'm hoping the research is correct, but is there a list of what the lua equivalents are for research names to ensure I'm granting the right ones?
Also, would you happen to know where I can find the code to give the player items?
For the code to give the player items look in data\base\scenarios\freeplay\control.lua:Code: Select all
script.on_event(defines.events.on_player_created, function(event) local player = game.players[event.player_index] player.insert{name="iron-plate", count=8} player.insert{name="pistol", count=1} player.insert{name="firearm-magazine", count=10} player.insert{name="burner-mining-drill", count = 1} player.insert{name="stone-furnace", count = 1} player.force.chart(player.surface, {{player.position.x - 200, player.position.y - 200}, {player.position.x + 200, player.position.y + 200}}) if (#game.players <= 1) then game.show_message_dialog{text = {"msg-intro"}} else player.print({"msg-intro"}) end end)
I should have thought of that, but it's early o'clock and I'm apparently as dense as the aliens at the moment...
Thanks so much again for your help.