I am using two Inventories. The ORK party inventory and an IShortcut list for the player inventories. How can I save the second list to the save game file?
Depends on where you keep your player inventories - e.g. if it's in the regular Inventory class, you can just add them to the save data there, otherwise you'll have to add it somewhere, e.g. in the GameHandler class.
Generally, saving things requires you to implement the ISaveData interface - examples on how to save/load a list of IShortcut can be found in the Inventory class (save functions are at the bottom of the class).
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
"Depends on where you keep your player inventories - e.g. if it's in the regular Inventory class, you can just add them to the save data there, otherwise you'll have to add it somewhere, e.g. in the GameHandler class.
Generally, saving things requires you to implement the ISaveData interface - examples on how to save/load a list of IShortcut can be found in the Inventory class (save functions are at the bottom of the class). "
You seem to confuse me with someone who is super great at programming. I have my own inventory and everything necessary to display the inventory in my own script and all I want is to make it work with the ORK Framework.
The player inventories follow the first 9 videos of this playlist:
and the party inventory is just a list of GUI.Drawtextures showing the icons of the "IShortcut"s. Clicking on that icon adds the "IShortcut" into the player inventory list and removes it from the party inventory.
which copies the inventory into my "IShortcut" list inside my own inventory script. It does that EVERYTIME I open the inventory. So if I move an item out of the "_inventoryORKParty" it will add it in again. So I have to clear the inventory by uncommenting the "c1.inventory.Clear()" line but then I get a problem if I open a second item collector box and add new items to the then empty inventory because "GetContent" then overwrites the items that already are in "_inventoryORKParty" when I open the inventory window. So I should use "Add" but then we are back at the "for loop" problem from another thread of mine.
So now if I save the game it should save the contents of those lists. But when I load them it only fills the lists in the ORK Framework "Inventory.cs" script. So where and how do I copy the content of those lists over to my own inventory lists? But that doesn't matter because right now while saving causes no errors loading actually doesn't work at all:
"NullReferenceException: Object reference not set to an instance of an object ORKFramework.Inventory.LoadGame (ORKFramework.DataObject data) ORKFramework.Group.LoadGame (ORKFramework.DataObject data) ORKFramework.Group..ctor (ORKFramework.DataObject data) ORKFramework.PlayerHandler.LoadGame (ORKFramework.DataObject data) ORKFramework.SaveGameHandler.Loaded (ORKFramework.DataObject data) ORKFramework.Behaviours.SceneChanger+d__2.MoveNext () " And ten similar to each other errors:
"KeyNotFoundException: The given key was not present in the dictionary. System.Collections.Generic.Dictionary`2[System.Int32,ORKFramework.Group].get_Item (Int32 key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150) ORKFramework.PlayerHandler.get_ActiveGroup () ORKFramework.GameHandler.get_ActiveGroup () ORKFramework.GameHandler.SceneLoaded () ORKFramework.ORKCore.FireSceneLoaded () ORKFramework.ORKHandler.OnLevelWasLoaded (Int32 level) "
So I spent money so that I have to fight ORK Framework instead of it helping me or I have to completely change how I do the inventory to comply with your idea of an inventory because there is NO easy way to make my own inventory work with ORK Framework.
If you could tell me why you need to create your own inventory system to keep the items instead of using ORK's inventory to store the items (which btw can also be switched to individual inventories for each combatant in the Inventory Settings).
Displaying the inventory can still be handled by your own classes, since you can get all the data from the inventory class (e.g. the GetContent function you're already using). Saves you the trouble of dealing with custom save/load game.
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I don't need to, I want to. I want to have the standard gridbased inventory with drag and drop that games like "Guild Wars", "Diablo" and even "Deus Ex Human Revolution" uses.
Firstly that means the inventory is NOT split up into "Items", "Weapons" and "Armors" all goes into ONE inventory list, not three.
Secondly it means I need empty entries in the list that are necessary to make sorting the inventory with drag and drop possible and which get filled up/replaced when I pick up new items. But when I click on the items in the "item collector" list it just adds them to the inventory. So even removing the party inventory and using only player inventory would not work because I don't have control over what happens when I click on the "item collector" list.
And that is why displaying the inventory how I want to do it does not work. There is no way to fill up the inventory with empty items and then replace them with the non empty items by picking them up or by sorting via drag and drop.
The only way to display the inventory is how it is done in "Final Fantasy" or "The Witcher 2", a list of icons and names, no grid. That works but it's not what I want and it's not what is pretty much standard in western RPGs. But it'll do because I don't want to try to make my inventory work with ORK anymore.
This is the code that moves an item from the party inventory, a list of icons and names, to my player inventory, which is grid based with drag and drop:
if(inventoryRect.Contains(e.mousePosition)) { //first two lines check if you click on icon if(e.type == EventType.mouseDown && e.button == 0) { // in the party inventory for (int a = 0; a < 30; a++) { if(InventPlayer[a].GetName() == "Empty" ) {// looks for the first empty entry in the grid neededIndex = a; break; }} InventPlayer[neededIndex]=_inventoryORKParty[cnt]; // put item from party inventory to player // inventory at index a _inventoryORKParty.RemoveAt(cnt); }}
I am actually wondering why the inventory system does not work like the item system. You can add new item types and new items.
So why no "Add inventory" which then let's you choose which item types the inventory can contain and what combatant or NPC owns the inventory. Then an option to initialize the inventory with x empty items which also sets the limit of it and which get automatically replaced when you pick up new items.
That way you could create one inventory for each item type for example. But I think that might be horrible to program and make work without bugs. Or it might be relatively easy to do. Hell, what do I know.
Grid inventory menus are already on my to-do list, just didn't come to that yet. The Inventory class only holds the items and got nothing to do with displaying them.
There are already limit settings for inventories available in the Inventory Settings - e.g. setting a space limit and using the Inventory Space settings of items/equipment.
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Generally, saving things requires you to implement the ISaveData interface - examples on how to save/load a list of IShortcut can be found in the Inventory class (save functions are at the bottom of the class).
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Generally, saving things requires you to implement the ISaveData interface - examples on how to save/load a list of IShortcut can be found in the Inventory class (save functions are at the bottom of the class). "
You seem to confuse me with someone who is super great at programming. I have my own inventory and everything necessary to display the inventory in my own script and all I want is to make it work with the ORK Framework.
The player inventories follow the first 9 videos of this playlist:
and the party inventory is just a list of GUI.Drawtextures showing the icons of the "IShortcut"s. Clicking on that icon adds the "IShortcut" into the player inventory list and removes it from the party inventory.
//////////////////////////////////////////////////////////////////////
So after your post I added three IShortcut lists to the ORF Framework "Inventory.cs" and two function for each list:
public List<IShortcut> GetFEContent(Combatant c) {
FEallitemList = this.GetContent(c,true,true,true,true);
return this.FEallitemList;
}
public void SetFEPartyContent(List<IShortcut> invent){
FEPartyallitemList = invent;
}
Then I added three versions of this to the "SaveGame()" function:
if(true)
{
DataObject[] tmp = new DataObject[FEallitemList.Count];
for(int i=0; i < tmp.Length; i++)
{
tmp[i] = this.FEallitemList[i].SaveGame();
}
data.Set("allItemList", tmp);
}
and three versions of this to the "LoadGame()" function, one for each list:
if(true)
{
DataObject[] tmp = data.GetFileArray("allItemList");
if(tmp != null)
{
for(int i=0; i<tmp.Length; i++)
{
IShortcut item = null;
item.LoadGame(tmp[i]);
this.FEallitemList.Add(item);
}
}
}
BTW: "Inventory.cs" only shows how to save and load "ItemShortcut" and "EquipShortcut", not once is a "IShortcut" saved.
Now when I open my inventory window I call this:
if(_displayInventoryWindow == true) {
_inventoryORKParty = c1.Inventory.GetContent(c1,false,true,true,true);
//c1.Inventory.Clear();
}
which copies the inventory into my "IShortcut" list inside my own inventory script. It does that EVERYTIME I open the inventory. So if I move an item out of the "_inventoryORKParty" it will add it in again. So I have to clear the inventory by uncommenting the "c1.inventory.Clear()" line but then I get a problem if I open a second item collector box and add new items to the then empty inventory because "GetContent" then overwrites the items that already are in "_inventoryORKParty" when I open the inventory window. So I should use "Add" but then we are back at the "for loop" problem from another thread of mine.
When I close the inventory window I do this:
c1.Inventory.SetFEContent(_inventPlayer);
c1.Inventory.SetFEPartyContent(_inventoryORKParty);
c1.Inventory.SetFESlotContent(_slots);
So now if I save the game it should save the contents of those lists. But when I load them it only fills the lists in the ORK Framework "Inventory.cs" script. So where and how do I copy the content of those lists over to my own inventory lists? But that doesn't matter because right now while saving causes no errors loading actually doesn't work at all:
"NullReferenceException: Object reference not set to an instance of an object
ORKFramework.Inventory.LoadGame (ORKFramework.DataObject data)
ORKFramework.Group.LoadGame (ORKFramework.DataObject data)
ORKFramework.Group..ctor (ORKFramework.DataObject data)
ORKFramework.PlayerHandler.LoadGame (ORKFramework.DataObject data)
ORKFramework.SaveGameHandler.Loaded (ORKFramework.DataObject data)
ORKFramework.Behaviours.SceneChanger+d__2.MoveNext ()
"
And ten similar to each other errors:
"KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[System.Int32,ORKFramework.Group].get_Item (Int32 key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
ORKFramework.PlayerHandler.get_ActiveGroup ()
ORKFramework.GameHandler.get_ActiveGroup ()
ORKFramework.GameHandler.SceneLoaded ()
ORKFramework.ORKCore.FireSceneLoaded ()
ORKFramework.ORKHandler.OnLevelWasLoaded (Int32 level)
"
So I spent money so that I have to fight ORK Framework instead of it helping me or I have to completely change how I do the inventory to comply with your idea of an inventory because there is NO easy way to make my own inventory work with ORK Framework.
Displaying the inventory can still be handled by your own classes, since you can get all the data from the inventory class (e.g. the GetContent function you're already using). Saves you the trouble of dealing with custom save/load game.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Firstly that means the inventory is NOT split up into "Items", "Weapons" and "Armors" all goes into ONE inventory list, not three.
Secondly it means I need empty entries in the list that are necessary to make sorting the inventory with drag and drop possible and which get filled up/replaced when I pick up new items. But when I click on the items in the "item collector" list it just adds them to the inventory. So even removing the party inventory and using only player inventory would not work because I don't have control over what happens when I click on the "item collector" list.
And that is why displaying the inventory how I want to do it does not work. There is no way to fill up the inventory with empty items and then replace them with the non empty items by picking them up or by sorting via drag and drop.
The only way to display the inventory is how it is done in "Final Fantasy" or "The Witcher 2", a list of icons and names, no grid. That works but it's not what I want and it's not what is pretty much standard in western RPGs. But it'll do because I don't want to try to make my inventory work with ORK anymore.
This is the code that moves an item from the party inventory, a list of icons and names, to my player inventory, which is grid based with drag and drop:
if(inventoryRect.Contains(e.mousePosition)) { //first two lines check if you click on icon
if(e.type == EventType.mouseDown && e.button == 0) { // in the party inventory
for (int a = 0; a < 30; a++) {
if(InventPlayer[a].GetName() == "Empty" ) {// looks for the first empty entry in the grid
neededIndex = a;
break;
}}
InventPlayer[neededIndex]=_inventoryORKParty[cnt]; // put item from party inventory to player
// inventory at index a
_inventoryORKParty.RemoveAt(cnt);
}}
So why no "Add inventory" which then let's you choose which item types the inventory can contain and what combatant or NPC owns the inventory. Then an option to initialize the inventory with x empty items which also sets the limit of it and which get automatically replaced when you pick up new items.
That way you could create one inventory for each item type for example. But I think that might be horrible to program and make work without bugs. Or it might be relatively easy to do. Hell, what do I know.
The Inventory class only holds the items and got nothing to do with displaying them.
There are already limit settings for inventories available in the Inventory Settings - e.g. setting a space limit and using the Inventory Space settings of items/equipment.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!