Jesus4Lyf
Good Idea™
- Reaction score
- 397
Got tired of changing the thread topic for the other one, and it's was originally about LUA, and the practicalities of it.
I'm wondering now, what sort of JASS features need to be available to an inventory system? The structure is this:
Every unit with an inventory has pockets in the normal items area. There can be any number of pockets, which are declared in the script. In each pocket, a unit may hold up to 10 different itemtypes, and any number of each item type. So they can hold 10 items unless they stack. Demo. And to clarify, each ItemType has a fixed pocket it goes to.
So then. What JASS functions are required? Inevitably, the user will want to know if the unit has an item of a certain type. Since this system allows attaching to individual items and stacking of items, there is a slight issue - if one item is "enchanted" or has certain stats, and the user then picks up one which is not, the order of the items becomes important. Dropping an item will always drop the latest one picked up. The real issue is, the user will wish to retrieve all items of type x from a unit. So to get an actual item, syntax is something like:
Seems to make sense to me. Anyone have other ideas?
What about getting all items for a pocket? Will people need that? Or the number of items in a pocket?
Hm. It kind of makes sense to me. What will the list object be like? Will it be an iterator? Does it need to destroy itself automatically? Should I just add a .forAllItemsInList(some method) kinda thing? Hm!
Need interface ideas...
I'm wondering now, what sort of JASS features need to be available to an inventory system? The structure is this:
Every unit with an inventory has pockets in the normal items area. There can be any number of pockets, which are declared in the script. In each pocket, a unit may hold up to 10 different itemtypes, and any number of each item type. So they can hold 10 items unless they stack. Demo. And to clarify, each ItemType has a fixed pocket it goes to.
So then. What JASS functions are required? Inevitably, the user will want to know if the unit has an item of a certain type. Since this system allows attaching to individual items and stacking of items, there is a slight issue - if one item is "enchanted" or has certain stats, and the user then picks up one which is not, the order of the items becomes important. Dropping an item will always drop the latest one picked up. The real issue is, the user will wish to retrieve all items of type x from a unit. So to get an actual item, syntax is something like:
JASS:
Inventory[unit].getItemList(MyItemType)[1] // the last is the item number, in order of pick up.
Seems to make sense to me. Anyone have other ideas?
What about getting all items for a pocket? Will people need that? Or the number of items in a pocket?
JASS:
Inventory[unit].getPocket(MyPocket) // returns a list of ItemTypes that the unit has.
Hm. It kind of makes sense to me. What will the list object be like? Will it be an iterator? Does it need to destroy itself automatically? Should I just add a .forAllItemsInList(some method) kinda thing? Hm!
Need interface ideas...