Load an item into player's cursor_stack ?

Place to get help with not working mods / modding interface.
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

Load an item into player's cursor_stack ?

Post by binbinhfr »

Hi,

I know how to load an item in to player's cursor :

Code: Select all

		player.cursor_stack.set_stack({name = "test", count = 1})
		player.remove_item({name = "test", count = 1})
And I can put it back the same way.

But it does not put it back at the same place, as the game does.
When you manually pick up an item in your bag, the game draws a little black hand in place of the picked item.
And when you clear the cursor, the item comes back at this memorised location.

Is there a way to do this with the API ?
My mods on the Factorio Mod Portal :geek:
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

Re: Load an item into player's cursor_stack ?

Post by binbinhfr »

Choumiko wrote:This: http://lua-api.factorio.com/latest/LuaP ... ean_cursor ? added in 0.13.10
That is what I use for the moment, but it does not do the trick.

When you do

Code: Select all

      player.cursor_stack.set_stack({name = "test", count = 1})
      player.remove_item({name = "test", count = 1})
If you do not remove the item from inventory, then when calling clean_cursor(), anotehr item is added in inventory...
And if you do remove, when calling clean_cursor(), the item is put back in inventory, but anywhere.

Not the same way te game does with this "black hand" memorised location.
My mods on the Factorio Mod Portal :geek:
Post Reply

Return to “Modding help”