You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently you can't get a sorted list of item names + amounts from either a cargo container, refinery, assembler, etc. You have to know the items up front.
There are a couple challenges to overcome, which I think are doable:
First, there's no good way to access "friendly names" for the inventory items. This is especially true for modded items. So if I were to present the "item name" it would likely be in the form "SubTypeId.TypeId", similar to the Types property. You could then, of course, map those back to whatever names you like using a map of your own creation inside the script.
Second, how to best represent "itemName, quantity" pairs. My instinct says we should use Keyed Values ("itemName" -> amount), and return an ordered collection of them.
The challenge with this, is that currently the "list" construct is supposed to only have 1 key mapped to 1 value, though this is technically not true (it's an artificial constraint). The intention was to create a dictionary like structure that you can look up from. This also can be gotten around though. I propose changing the way lists work such that adding keyed items to a list adds them as entries vs doing a replacement. Only doing an index update directly will do an override of the first keyed entry found (or remove all other entries?). Similarly, retrieving by key would return a list of values if there are more than one entry for the given key, vs just a single entry.
Third, how do you access the "itemName" vs the "amount" for a list of items you are iterating over? If we represent them as keyed values, then we need a way to grab a variable "key" and "value" independently. We could also represent as a list with the first entry being the itemName and the second being the amount. Used keyed variables that would yield:
set myItems to "My Inventory" items
for each item in myItems
print "Name: " item["name"]
print "Amount: " + item["amount"]
This change is definitely backwards incompatible, though not in functionality just in structure. I'd be OK making it provided strong call outs during the update that "if you update your script, you may have to adjust it".
Describe the solution you'd like
set myItems to "My Inventory" items
for each item in myItems
print "Name: " item["name"]
print "Amount: " + item["amount"]
The text was updated successfully, but these errors were encountered:
It nearly sounds like you want to use the "list" structure similar to arrays in PHP, which is a flexible combination of a list and dict structure. EC probably doesn't require the same level of flexibility as that structure exactly, but more having a single structure that could be 0-indexed or string-indexed? (PHP arrays can mix the two in the same array, which I don't think is necessary here.)
Alternatively you could use two different structures, though that may be the "nice" thing to do that's impractical due to the optimization/character limitations.
Perhaps such a structure could simplify other things though.
A (perhaps unrelated) additional concern is that when getting a list of items from an inventory of some kind, it may occasionally be useful to return a property describing it's ordering/positioning within the inventory. That's the main concern in my use case that spawned this issue... I wanted the position 0 item name from the first inventory of a refinery.
That would give use three properties available when you get a list of items from an inventory:
name: The display/friendly name of the item.
amount: The quantity of that item in the inventory.
position/order/slot: The inventory position of that item in the given inventory.
An additional consideration may be that position is probably a writable property (strictly speaking from a game perspective), while name and amount are not. Though providing writable access to this property is probably unnecessary, it could enable things like sorts within the inventory via script, or a script that always keeps a particular item at the beginning of a given inventory.
instead of using index notation to refer to a property, what about using dot notation, '.'? a number of other languages do this (though many, such as Lua, do also allow access through index notation as well), and it fits well with its current use of accessing vectors' and colors' components
Is your feature request related to a problem? Please describe.
Currently you can't get a sorted list of item names + amounts from either a cargo container, refinery, assembler, etc. You have to know the items up front.
There are a couple challenges to overcome, which I think are doable:
First, there's no good way to access "friendly names" for the inventory items. This is especially true for modded items. So if I were to present the "item name" it would likely be in the form "SubTypeId.TypeId", similar to the Types property. You could then, of course, map those back to whatever names you like using a map of your own creation inside the script.
Second, how to best represent "itemName, quantity" pairs. My instinct says we should use Keyed Values ("itemName" -> amount), and return an ordered collection of them.
The challenge with this, is that currently the "list" construct is supposed to only have 1 key mapped to 1 value, though this is technically not true (it's an artificial constraint). The intention was to create a dictionary like structure that you can look up from. This also can be gotten around though. I propose changing the way lists work such that adding keyed items to a list adds them as entries vs doing a replacement. Only doing an index update directly will do an override of the first keyed entry found (or remove all other entries?). Similarly, retrieving by key would return a list of values if there are more than one entry for the given key, vs just a single entry.
Third, how do you access the "itemName" vs the "amount" for a list of items you are iterating over? If we represent them as keyed values, then we need a way to grab a variable "key" and "value" independently. We could also represent as a list with the first entry being the itemName and the second being the amount. Used keyed variables that would yield:
This change is definitely backwards incompatible, though not in functionality just in structure. I'd be OK making it provided strong call outs during the update that "if you update your script, you may have to adjust it".
Describe the solution you'd like
The text was updated successfully, but these errors were encountered: