Problem with bag system.

ROBBYDOBBY

New Member
Reaction score
3
Hey,
I've tried making a simple bag system in which you swap between two inventories. I've made it so at the start of the game you get the item 'Swap to Bag 2'. When you use that it saves all the items from slot's 2-6 and removes the Swap to Bag 2 item. This is replaced by Swap to Bag 1. When you use swap to bag 1 the items do not appear ><. any ideas?
and i haven't made it load the items on bag 2 yet.

Code:
Extension1
    Events
        Unit - A unit Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Switch to Bag 2
    Actions
        Set Bag_Inv_1[1] = (Item carried by (Triggering unit) in slot 6)
        Set Bag_Inv_1[2] = (Item carried by (Triggering unit) in slot 2)
        Set Bag_Inv_1[3] = (Item carried by (Triggering unit) in slot 3)
        Set Bag_Inv_1[4] = (Item carried by (Triggering unit) in slot 4)
        Set Bag_Inv_1[5] = (Item carried by (Triggering unit) in slot 5)
        Item - Remove Bag_Inv_1[1]
        Item - Remove Bag_Inv_1[2]
        Item - Remove Bag_Inv_1[3]
        Item - Remove Bag_Inv_1[4]
        Item - Remove Bag_Inv_1[5]
        Item - Remove (Item being manipulated)
        Hero - Create Switch to Bag 1 and give it to (Triggering unit)
Code:
Extension2
    Events
        Unit - A unit Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Switch to Bag 1
    Actions
        Set Bag_Inv_2[1] = (Item carried by (Triggering unit) in slot 6)
        Set Bag_Inv_2[2] = (Item carried by (Triggering unit) in slot 2)
        Set Bag_Inv_2[3] = (Item carried by (Triggering unit) in slot 3)
        Set Bag_Inv_2[4] = (Item carried by (Triggering unit) in slot 4)
        Set Bag_Inv_2[5] = (Item carried by (Triggering unit) in slot 5)
        Item - Remove Bag_Inv_2[1]
        Item - Remove Bag_Inv_2[2]
        Item - Remove Bag_Inv_2[3]
        Item - Remove Bag_Inv_2[4]
        Item - Remove Bag_Inv_2[5]
        Hero - Create (Item-type of Bag_Inv_1[1]) and give it to (Hero manipulating item)
        Hero - Create (Item-type of Bag_Inv_1[2]) and give it to (Hero manipulating item)
        Hero - Create (Item-type of Bag_Inv_1[3]) and give it to (Hero manipulating item)
        Hero - Create (Item-type of Bag_Inv_1[4]) and give it to (Hero manipulating item)
        Hero - Create (Item-type of Bag_Inv_1[5]) and give it to (Hero manipulating item)
        Item - Remove (Item being manipulated)
        Hero - Create Switch to Bag 2 and give it to (Triggering unit)
Bag_Inv_1 is an item variable with an array the size of 5
Bag_inv_2 Is the same.
 

Tom Jones

N/A
Reaction score
437
I've got a good idea on what's wrong. You remove variable assigned items from the game, thus when trying to get the type from a item assigned to a variable it'll return nothing, because there is no item to get the type from. Store the type of the items instead.
 

Tom Jones

N/A
Reaction score
437
Code:
Bag 1
    Events
        Unit - A unit Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to *Switch To Bag 2*
    Actions
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Set Item_Types_1[(Integer A)] = (Item-type of (Item carried by (Triggering unit) in slot (Integer A)))
                Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
                Hero - Create Item_Types_2[(Integer A)] and give it to (Triggering unit)
Code:
Bag 2
    Events
        Unit - A unit Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to *Switch To Bag 1*
    Actions
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Set Item_Types_2[(Integer A)] = (Item-type of (Item carried by (Triggering unit) in slot (Integer A)))
                Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
                Hero - Create Item_Types_1[(Integer A)] and give it to (Triggering unit)
 

ROBBYDOBBY

New Member
Reaction score
3
My items don't come back, here is what it looks like ATM:
Code:
Extension1
    Events
        Unit - A unit Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Switch to Bag 2
    Actions
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Set Bag_Inv_1[(Integer A)] = (Item carried by (Triggering unit) in slot (Integer A))
                Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
                Hero - Create (Item-type of Bag_Inv_2[(Integer A)]) and give it to (Triggering unit)
        If (((Triggering unit) has an item of type Switch to Bag 3) Equal to True) then do (Do nothing) else do (Hero - Create Switch to Bag 3 and give it to (Triggering unit))
Code:
Extension2
    Events
        Unit - A unit Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Switch to Bag 3
    Actions
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Set Bag_Inv_2[(Integer A)] = (Item carried by (Triggering unit) in slot (Integer A))
                Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
                Hero - Create (Item-type of Bag_Inv_3[(Integer A)]) and give it to (Triggering unit)
        If (((Triggering unit) has an item of type Switch to Bag 1) Equal to True) then do (Do nothing) else do (Hero - Create Switch to Bag 1 and give it to (Triggering unit))
Code:
Extension3
    Events
        Unit - A unit Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Switch to Bag 1
    Actions
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Set Bag_Inv_3[(Integer A)] = (Item carried by (Triggering unit) in slot (Integer A))
                Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
                Hero - Create (Item-type of Bag_Inv_1[(Integer A)]) and give it to (Triggering unit)
        If (((Triggering unit) has an item of type Switch to Bag 2) Equal to True) then do (Do nothing) else do (Hero - Create Switch to Bag 2 and give it to (Triggering unit))
At the start of the game everyone gets 'switch to bag1':banghead:
 

Choppa

www.warcraft-gamers.po.gs
Reaction score
59
Your trigger is kind of confusing, are you removing all items then giving the switch item back to the unit? You don't have to do that, you can do this...

Code:
Extension1
    Events
        Unit - A unit Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Switch to Bag 2
    Actions
        For each (Integer A) [B]from 2 to 6, do[/B] (Actions)
            Loop - Actions
                [B]Set Bag_Inv_1[(Integer A) - 1][/B] = (Item carried by (Triggering unit) in slot (Integer A))
                Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
        If (((Triggering unit) has an item of type Switch to Bag 3) Equal to True) then do (Do nothing) else do (Hero - Create Switch to Bag 3 and give it to (Triggering unit))

And uhh... Removing an item will remove it from the game, drop it insted.
 

N2o)

Retired.
Reaction score
51
Don't use an item array, use an item-type array like tom said. You store your variables as the actual items and then remove those items, so nothing will appear when clicking back onto bag 1. Just a note: Any aura and stats enhancing items won't work when on the alternate inventory.
 
M

Mr.Banankaka

Guest
Shouldn´t you change this part:

Code:
Set Bag_Inv_1/2/3 (w/e)[(Integer A)] = (Item carried by (Triggering unit) in slot (Integer A))

To this(?):

Code:
Set Bag_Inv_1/2/3 (w/e)[(Integer A)] = (Item-type of (Item carried by (Triggering unit) in slot (Integer A)))

Or does it not matter? My thaughts are that when you remove the item you set the variable to null. I might be terribly wrong as it´s just a thaught thoe...

PS: With 1/2/3 (w/e) I mean like: 1, 2 or 3 what ever. (Not all people understand that it´s not a part of the trigger)
 

Choppa

www.warcraft-gamers.po.gs
Reaction score
59
Shouldn´t you change this part:

Code:
Set Bag_Inv_1/2/3 (w/e)[(Integer A)] = (Item carried by (Triggering unit) in slot (Integer A))

To this(?):

Code:
Set Bag_Inv_1/2/3 (w/e)[(Integer A)] = (Item-type of (Item carried by (Triggering unit) in slot (Integer A)))

Just like Tom and N2o) said :rolleyes:
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top