[SOLVED]Modify items in player's starting inventory
[SOLVED]Modify items in player's starting inventory
When you spawn in a new world, you already have a furnace, 8 iron and a burner miner. I'd like to add some of my own items to that starting inventory. How can I do that?
Last edited by Villfuk02 on Tue May 01, 2018 2:02 pm, edited 1 time in total.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Modify items in player's starting inventory
Adding is fairly easy. there is a script in the control.lua of the scenario that defines what items it gives you, so you'd need to do the same thing in your mod.Villfuk02 wrote:When you spawn in a new world, you already have a furnace, 8 iron and a burner miner. I'd like to add some of my own items to that starting inventory. How can I do that?
As an example... If you create a control.lua in your mod and include the following...
Code: Select all
script.on_event(defines.events.on_player_created, function(event)
local player = game.players[player_index]
player.insert({name="iron-plate", count=8})
end)
script.on_event(defines.events.on_player_respawned, function(event)
local player = game.players[player_index]
player.insert({name="copper-plate", count=8})
end)
Re: Modify items in player's starting inventory
OK, thanks, but where do I get the player_index?
The game doesn't want to accept it just like that.
The game doesn't want to accept it just like that.
Re: Modify items in player's starting inventory
I just figured it out. It is event.player_index.
Thanks for your help
Thanks for your help