0.12.30 LuaPlayer.can_insert vs LuaPlayer.insert
Posted: Mon Apr 18, 2016 4:06 pm
I noticed a little mismatch between LuaPlayer.can_insert and LuaPlayer.insert when dealing with a full main inventory and a full quickbar when one item of the quickbar is on the cursor.
To reproduce:
Fill main inventory and quickbar with items. Pick one stack from the quickbar onto your cursor and run:
This results in:
Guess it should either be: false 0 or true 1
Using the inventory directly is consistent:
results in true 1, placing the item in the slot of the item you have on the cursor
To reproduce:
Fill main inventory and quickbar with items. Pick one stack from the quickbar onto your cursor and run:
Code: Select all
/c local p = game.local_player; p.print(serpent.line(p.can_insert{name="iron-plate", count=1}));p.print(serpent.line(p.insert{name="iron-plate", count=1}))
Code: Select all
true
Cannot insert Iron Plate. Player's inventory full.
0
Using the inventory directly is consistent:
Code: Select all
/c local p, item = game.local_player, "medium-electric-pole"
local main, quick = p.get_inventory(1), p.get_inventory(2)
p.print("quick:"..serpent.line(quick.can_insert{name=item, count=1}))
p.print("insert quick:"..serpent.line(quick.insert{name=item, count=1}))