Check if starting item actually exists before trying to give it to player.
This commit is contained in:
parent
282e7b4006
commit
d41fce6f91
|
@ -127,24 +127,29 @@ function update_player(index)
|
||||||
for name, count in pairs(samples) do
|
for name, count in pairs(samples) do
|
||||||
stack.name = name
|
stack.name = name
|
||||||
stack.count = count
|
stack.count = count
|
||||||
if character.can_insert(stack) then
|
if game.item_prototypes[name] then
|
||||||
sent = character.insert(stack)
|
if character.can_insert(stack) then
|
||||||
else
|
sent = character.insert(stack)
|
||||||
sent = 0
|
else
|
||||||
end
|
sent = 0
|
||||||
if sent > 0 then
|
end
|
||||||
player.print("Received " .. sent .. "x [item=" .. name .. "]")
|
if sent > 0 then
|
||||||
data.suppress_full_inventory_message = false
|
player.print("Received " .. sent .. "x [item=" .. name .. "]")
|
||||||
end
|
data.suppress_full_inventory_message = false
|
||||||
if sent ~= count then -- Couldn't full send.
|
end
|
||||||
if not data.suppress_full_inventory_message then
|
if sent ~= count then -- Couldn't full send.
|
||||||
player.print("Additional items will be sent when inventory space is available.", {r=1, g=1, b=0.25})
|
if not data.suppress_full_inventory_message then
|
||||||
|
player.print("Additional items will be sent when inventory space is available.", {r=1, g=1, b=0.25})
|
||||||
|
end
|
||||||
|
data.suppress_full_inventory_message = true -- Avoid spamming them with repeated full inventory messages.
|
||||||
|
samples[name] = count - sent -- Buffer the remaining items
|
||||||
|
break -- Stop trying to send other things
|
||||||
|
else
|
||||||
|
samples[name] = nil -- Remove from the list
|
||||||
end
|
end
|
||||||
data.suppress_full_inventory_message = true -- Avoid spamming them with repeated full inventory messages.
|
|
||||||
samples[name] = count - sent -- Buffer the remaining items
|
|
||||||
break -- Stop trying to send other things
|
|
||||||
else
|
else
|
||||||
samples[name] = nil -- Remove from the list
|
player.print("Unable to receive " .. count .. "x [item=" .. name .. "] as this item does not exist.")
|
||||||
|
samples[name] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue