ID:2095548
 
(See the best response by Kaiochao.)
Code:
N/A


Problem description:


I would like to create a tab of objects not in the user's inventory, where clicking them would start an action - such as spawning one in and then removing different items from the player's inventory (such as the method Dragon Universe or Phoenix: Sundered Earth uses).



How would I go about doing so?



GitHub Project here.
BYOND Hub here.
Best response
In Stat():
statpanel("Stuff and things", list_of_stuff)

where list_of_stuff is a /list containing whatever objects you want.
Sounds to me like you're looking to do a crafting system.

Let's assume you have a master list of craftable items that looks like this:

var/list/crafting_recipes = list(\
/obj/item/potion/health = list(/obj/item/herb/fireflower=2, /obj/item/powder/lifesalt),
...
)

Now whenever a mob's inventory updates, you'll want to update the list of what they can and can't craft.

mob/var/tmp/list/craftable

// call on get, drop, buy, sell, craft, and load
// this lists only items you can make now, not ones you need to collect items for
mob/proc/UpdateCraftable()
if(!craftable) craftable = new
var/obj/item/O
var/typedst, typesrc
var/list/counts = new
var/n, idx=1
var/recipe
for(O in src) ++counts[O.type]
for(typedst in crafting_recipes)
// items will always be listed in the same order
O = (idx <= craftable.len) ? craftable[idx] : null
if(O && O.type != typedst) O = null
recipe = crafting_recipes[typedst]
n = 1000
for(typesrc in recipe)
n = min(n, (counts[typesrc] || 0) / (recipe[typesrc]||1))
if(n >= 1)
if(!O)
O = new typedst
craftable.Insert(idx, O)
++idx
O.suffix = "(craft up to [n]x)"
else if(O)
craftable.Cut(idx,idx+1)

In your statpanel, you'd list the craftable items. Then you'd want to modify obj/Click() so that if the item was clicked in the crafting statpanel (you'd check the arguments to Click() for that), it would do the crafting.
In response to Lummox JR
Very nice and seems useful, but I was looking for a static (unless an item is removed by an admin) menu rather than a crafting system.

Thanks for all that, though, helps me understand things a bit more.