Inventory System Help

Squishy

You can change this now in User CP.
Reaction score
127
I am currently working on an Inventory system that would add items picked up into bags. So far, I've only tried with one bag, and I can't get the triggers to work. Here are the triggers:
Code:
Initialize Inventory
    Events
        Map initialization
    Conditions
    Actions
        Hero - Create Backpack and give it to Mountain King 0001 <gen>
        For each (Integer A) from 1 to 5, do (Actions)
            Loop - Actions
                Set Inventory_Spot[(Integer A)] = No Item
Code:
Acquires Item
    Events
        Unit - A unit Acquires an item
    Conditions
        (Item-type of (Item being manipulated)) Not equal to Close
        (Item-type of (Item being manipulated)) Not equal to Backpack
    Actions
        For each (Integer A) from 1 to 5, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Inventory_Spot[(Integer A)] Equal to No Item
                    Then - Actions
                        Set Inventory_Spot[(Integer A)] = (Item-type of (Item being manipulated))
                        Item - Remove (Item being manipulated)
                        Skip remaining actions
                    Else - Actions
Code:
Open Backpack
    Events
        Unit - A unit Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Backpack
    Actions
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
        Hero - Create Close and give it to (Triggering unit)
        Unit - Order (Triggering unit) to move (Last created item) to inventory slot 6
        For each (Integer A) from 1 to 5, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Inventory_Spot[(Integer A)] Not equal to No Item
                    Then - Actions
                        Hero - Create Inventory_Spot[(Integer A)] and give it to (Triggering unit)
                    Else - Actions
Code:
Close
    Events
        Unit - A unit Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Close
    Actions
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
        Hero - Create Backpack and give it to (Triggering unit)
Whenever I pick up an item, then open the backpack, there are no item inside. Can anyone see why this wouldn't be working?
 

Squishy

You can change this now in User CP.
Reaction score
127
I tried disabling it, didn't change anything. Gah, I can't figure out why this isn't working.
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Want me to give you a working backpack system?
 
Reaction score
86
change this
Code:
(Item-type of (Item being manipulated)) Not equal to Close
(Item-type of (Item being manipulated)) Not equal to Backpack

put an "and" in... I doubt this is the problem, but I'm pretty sure for all the conditions it is ors.
 

Squishy

You can change this now in User CP.
Reaction score
127
@Renendaru
If it's in GUI, ok. If it's in JASS... i guess I'll take a look anyway.
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
It's in JASS, but the cool thing is it uses some items for the spaces to look like an inventory.
 

Squishy

You can change this now in User CP.
Reaction score
127
Ok, can you upload it?

@Infinitegde
Tried it, didn't work.
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Here.

It's in that. There's some other stuff in it, feel free to look around.
 

XxShadyxX

I abused the rep system.
Reaction score
81
Code:
Then - Actions
                        Set Inventory_Spot[(Integer A)] = (Item-type of (Item being manipulated))
                        [COLOR="Red"]Item - Remove (Item being manipulated)[/COLOR]
                        Skip remaining actions
                    Else - Actions

um all this trigger is doing is removing the item. where is the part that moves it into the backpack?

also renedaru um the link don't work?
 
Reaction score
86
XxShadyxX is right. I just realized. Try disabling the trigger a unit acquires an item when you run the trigger Open backpack
 

XxShadyxX

I abused the rep system.
Reaction score
81
well then the item will just go into the inventory... You need to move the item into the backpack somehow
 

Squishy

You can change this now in User CP.
Reaction score
127
Without the trigger A Unit Acquires an Item, I cannot recieve any items at all, as items are created in the backpack via the item array.
 

XxShadyxX

I abused the rep system.
Reaction score
81
Yo here is another way for a backpack
Make it when you pick up backpack it creates a dummy unit that has a inventory. And make it when you push open it selects the dummy unit but that is the only way to get to dummy... And make it so when you pick up a item it moves the item to the dummy unit.
 

Squishy

You can change this now in User CP.
Reaction score
127
I'd rather get this way working, as it'll be much easier than using dummy units for each bag I want to give the unit.
 

XxShadyxX

I abused the rep system.
Reaction score
81
Well then all you need to do is add the item to the backpack... In that trigger that has the remove item put it in there
 

Squishy

You can change this now in User CP.
Reaction score
127
Look at the triggers. When a unit acquires an item, the item is set to a variable array. When the backpack is opened, it refers to the array and creates items for the Hero. It should already add the items.
 

XxShadyxX

I abused the rep system.
Reaction score
81
yea I know just try it? Try making it when you get a item it moves it to backpack
 

XxShadyxX

I abused the rep system.
Reaction score
81
WAIT SORRY FOR DOUBLE OST BUT I FOUND PROBLEM

Code:
Open Backpack
    Events
        Unit - A unit Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Backpack
    Actions
       [COLOR="Red"] For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Item - Remove (Item carried by (Triggering unit) in slot (Integer A))[/COLOR]
        Hero - Create Close and give it to (Triggering unit)
        Unit - Order (Triggering unit) to move (Last created item) to inventory slot 6
        For each (Integer A) from 1 to 5, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Inventory_Spot[(Integer A)] Not equal to No Item
                    Then - Actions
                        Hero - Create Inventory_Spot[(Integer A)] and give it to (Triggering unit)
                    Else - Actions
RIGHT THERE THE RED DELETE IT AND TRY IT!
 

Squishy

You can change this now in User CP.
Reaction score
127
The 'Backpack' doesn't exist when a unit aquires an item, because all it is is an item ability, that when clicked, should create the items in the variables.

EDIT: XxShady, no offence, but your missing the point of the triggers. I am removing the items because I am just simulating a backpack effect, there isn't actually a packpack.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top