Page 1 of 1

0.12.30 LuaPlayer.can_insert vs LuaPlayer.insert

Posted: Mon Apr 18, 2016 4:06 pm
by Choumiko
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:

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}))
This results in:

Code: Select all

true
Cannot insert Iron Plate. Player's inventory full.
0
Guess it should either be: false 0 or true 1

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}))
results in true 1, placing the item in the slot of the item you have on the cursor

Re: 0.12.30 LuaPlayer.can_insert vs LuaPlayer.insert

Posted: Mon Apr 18, 2016 6:03 pm
by Rseding91
I've fixed this issue for 0.13 but the changes where more complex than I'd like to put into 0.12 and risk breaking something on the stable branch :)

The quickbar logic for can_insert wasn't the same as the actual insertion logic.

Re: 0.12.30 LuaPlayer.can_insert vs LuaPlayer.insert

Posted: Mon Apr 18, 2016 6:19 pm
by Choumiko
Rseding91 wrote:I've fixed this issue for 0.13 but the changes where more complex than I'd like to put into 0.12 and risk breaking something on the stable branch :)
That's interesting, i would have thought it should be fairly simple :) "Fixing" it in lua isn't a big deal though, but still: can't wait!! :lol: