Years ago, I used to use the simple player.insert(<items) which doesn't work anymore either - alot of posts still list that and the API looks like it should work but I'm not getting it to work.
Please help and thank you in advance.
First Snippet:
Code: Select all
	local player = game.players[event.player_index]
	if not (player and player.valid) then return end
	player.force.research_queue_enabled = true
	for _, inv in pairs({defines.inventory.character_main}) do
		if player.get_inventory(inv) then
			player.get_inventory(inv).clear()
			player.get_inventory(inv).insert({name="k2cp-city", count=4})
		end
	end
Second Snippet (continued from first):
Code: Select all
	local inv = player.get_main_inventory()
	if (inv) then
		inv.clear();
		inv.insert({name="iron-plate", count=50})
	else
		player.print("Main inventory not returned")	
	end

