Code: Select all
global.items = {}
global.items.items_list =
{
defence =
{
["stone-wall"] = 1000,
["gun-turret"] = 500,
["uranium-rounds-magazine"] = 1000
}}
Code: Select all
function advanced_chest()
local chest = game.surfaces.nauvis.create_entity{name = "wooden-chest", position= {game.player.position.x, game.player.position.y+1},force = game.player.force}
for k,list in pairs(global.items.items_list.defence) do
if chest.can_insert{name=k, count=list} == false then
chest = game.surfaces.nauvis.create_entity{name = "wooden-chest", position= {chest.position.x, chest.position.y+1},force = game.player.force}
end
chest.insert{name=k, count=list}
end
end