Hi guys,
I'm trying to create my own basic inventory system. It uses a unit's normal inventory. He has a couple of "bags" (abilities) which swap his inventory. The items are saved into a Hashtable. There is only 1 unit with a "bag" per player.
Inventory System:
Unfortunately the test trigger returns null for every value and hence no items are restored when switching between the bags. I'm new to hashtables. Can anyone work out why?
Edit: Actually I think I just worked it out. The Inventory Update fires upon an item being removed in the "Inventory Change" trigger. Lemme test if this is the case...
Edit 2: Nope. That might have caused an issue, but still, the test trigger shouldn't be returning null. Any ideas?
I'm trying to create my own basic inventory system. It uses a unit's normal inventory. He has a couple of "bags" (abilities) which swap his inventory. The items are saved into a Hashtable. There is only 1 unit with a "bag" per player.
Inventory System:
-
Inventory Update
-
Events
-
Unit - A unit Acquires an item
-
Unit - A unit Loses an item
-
Unit - A unit Uses an item
-
-
Conditions
-
(Unit-type of (Triggering unit)) Equal to Pokemon Trainer
-
-
Actions
-
For each (Integer InvenLoop1) from 1 to 6, do (Actions)
-
Loop - Actions
-
Hashtable - Save Handle Of(Item carried by (Triggering unit) in slot InvenLoop1) as InvenLoop1 of InventoryActiveBag[(Player number of (Owner of (Triggering unit)))] in Inventory
-
-
-
-
-
Inventory Change
-
Events
-
Unit - A unit Starts the effect of an ability
-
-
Conditions
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Ability being cast) Equal to Pokemon Bag
-
-
Then - Actions
-
Game - Display to (All players) for 3.00 seconds the text: Opened Pokemon Bag
-
Set InventoryActiveBag[(Player number of (Owner of (Triggering unit)))] = 1
-
For each (Integer InvenLoop2) from 1 to 6, do (Actions)
-
Loop - Actions
-
Item - Remove (Item carried by (Triggering unit) in slot InvenLoop2)
-
Hero - Create (Item-type of (Load InvenLoop2 of InventoryActiveBag[(Player number of (Owner of (Triggering unit)))] in Inventory)) and give it to (Triggering unit)
-
-
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Ability being cast) Equal to Item Bag 1
-
-
Then - Actions
-
Game - Display to (All players) for 3.00 seconds the text: Opened Item Bag 1
-
Set InventoryActiveBag[(Player number of (Owner of (Triggering unit)))] = 2
-
For each (Integer InvenLoop2) from 1 to 6, do (Actions)
-
Loop - Actions
-
Item - Remove (Item carried by (Triggering unit) in slot InvenLoop2)
-
Hero - Create (Item-type of (Load InvenLoop2 of InventoryActiveBag[(Player number of (Owner of (Triggering unit)))] in Inventory)) and give it to (Triggering unit)
-
-
-
-
Else - Actions
-
-
-
-
-
-
Inventory Test
-
Events
-
Player - Player 1 (Red) types a chat message containing -inven as An exact match
-
-
Conditions
-
Actions
-
Game - Display to (All players) for 3.00 seconds the text: (InventoryActiveBag = + (String(InventoryActiveBag[(Player number of (Triggering player))])))
-
For each (Integer InvenLoop1) from 1 to 6, do (Actions)
-
Loop - Actions
-
Game - Display to (All players) for 3.00 seconds the text: (Load InvenLoop1 of InventoryActiveBag[(Player number of (Triggering player))] from Inventory)
-
-
-
-
Edit: Actually I think I just worked it out. The Inventory Update fires upon an item being removed in the "Inventory Change" trigger. Lemme test if this is the case...
Edit 2: Nope. That might have caused an issue, but still, the test trigger shouldn't be returning null. Any ideas?
Last edited: