Check if starting item actually exists before trying to give it to player.

This commit is contained in:
CaitSith2 2021-09-09 07:44:45 -07:00
parent 282e7b4006
commit d41fce6f91
1 changed files with 21 additions and 16 deletions

View File

@ -127,6 +127,7 @@ function update_player(index)
for name, count in pairs(samples) do
stack.name = name
stack.count = count
if game.item_prototypes[name] then
if character.can_insert(stack) then
sent = character.insert(stack)
else
@ -146,6 +147,10 @@ function update_player(index)
else
samples[name] = nil -- Remove from the list
end
else
player.print("Unable to receive " .. count .. "x [item=" .. name .. "] as this item does not exist.")
samples[name] = nil
end
end
end