Tie a sprite-button to a LuaItemStack

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 452
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Tie a sprite-button to a LuaItemStack

Post by raiguard »

I would like to request a way to tie a LuaItemStack to a sprite-button, so we can show the contents of that ItemStack in the same way that the base game does. Currently, sprite-buttons can only display SpritePaths, which are static and unchanging. This means that you can't display things such as a blueprint item's icon or a spidertron's tint.

I think the best solution would be to add an item property to sprite-buttons, and set the contents of that value to a LuaItemStack. The sprite-button would then take on the properties of that LuaItemStack, and update its sprite, number, and tooltip when the LuaItemStack changes. This would make it a lot easier to emulate an inventory in a fully custom GUI as well.

Edit: justarandomgeek pointed out that having this behavior on a sprite-button might be confusing, so it might make more sense to create a new type, like item-stack-button.
Last edited by raiguard on Tue Dec 22, 2020 7:21 pm, edited 2 times in total.
Don't forget, you're here forever.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Tie a sprite-button to a LuaItemStack

Post by eradicator »

Raiguard wrote:
Tue Dec 22, 2020 6:56 pm
This means that you can't display things such as a blueprint item's icon or a spidertron's tint.
+1
+2
+3
+4
+∞

I'll take any method. I don't care how it's implemented. I'd also like a proper blueprint-preview tooltip on that slot-button please. Trying to create vanilla-like guis and hitting walls like this is quite frustrating.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Re: Tie a sprite-button to a LuaItemStack

Post by PFQNiet »

I agree. Bonus points if we get the native item tooltip as well, because currently I can either have a sprite-button with number but no tooltip, or a locked choose-elem-button with tooltip but no number.

An item-button would solve my problem perfectly.

curiosity
Filter Inserter
Filter Inserter
Posts: 325
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Tie a sprite-button to a LuaItemStack

Post by curiosity »

An item stack button would be helpful. Doesn't have to be sprite-button specifically.

KingIonTrueLove
Inserter
Inserter
Posts: 23
Joined: Sun Jun 04, 2017 1:38 am
Contact:

Re: Tie a sprite-button to a LuaItemStack

Post by KingIonTrueLove »

I like the idea of an item stack button as well. It would solve the issue I listed on 102201 because as it being related only to items, it should fire on mouse_down.

Plus I had been wanting to pull Factorio's item tooltips onto my buttons as well.

There is many things a 'item-button' could to to help bring the user experience of mods closer to that of base Factorio.

Kraskaska
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed Jul 28, 2021 2:08 pm
Contact:

Re: Tie a sprite-button to a LuaItemStack

Post by Kraskaska »

any news on this?

Post Reply

Return to “Modding interface requests”