-
Notifications
You must be signed in to change notification settings - Fork 77
Description
For more easier inventory handle, We have to change the inventory structure like this
[ITEM SQL Table]
itemID (auto Increcement), owningInv, data, x, y
[INVENTORY SQL Table]
invID (auto Increcement), invUID
[Loading Inventory]
When storage is created, Create another inventory with SQL.
get invID(auto Increcement) from the query callback, set storage invID to callback InvID.
When you save the storage, all you have to do is make sure storage invID is not corrupted.
When character is created, Create another inventory with SQL.
get invID(auto Increcement) from the query callback, set character invID to callback InvID.
When you save the character, all you have to do is make sure character invID is not corrupted.
[Managing Inventory]
Every Inventory has Inv Type ID (InvUID).
This Inv Type ID helps you to make various stuffs like Bag, Container, etc.
If invUID is not assgined, automatically assigns 'default' inv type.
'default' Inv Type must be present to make this Inventory structure real.
Inventory type can be registered in anywhere.
Inventory registeration goes like this
nut.inv.types['default] = {
name = "Default Chracter Inventory"
--desc = "Optional."
w = nut.config.get("InvW")
h = nut.config.get("InvH")
}
[How you can use this]
You can assign an inventory on any kind of thing.
Creating perosnal storage:
Create an Inventory.
Assign 'stash' type on the created Inventory.
newInvID is the id of the created Inventory.
set playerCharacter:setData("stash", newInvID)
there you go, you get personal storage.
Nah... this text is kinda mess..