A simpler inventory system?

M

MikeTheGuy

Guest
I'm sure I'm not the first one to think of this.

I was looking at the inventory systems and it seems that most require either finding substrings or making a ton of triggers. Mine, if the trigger works, would only need 1 trigger. Basically, my idea is to assign an item type (ie. sword, shield, helm, etc.) to each item class. So, for example: Artifact: Helmet, Purchasable: Armor, Permanent: Weapon, Charged: Shield (or weapon 2), Campaign: Leggings, Miscellaneous: Boots. And then Powerup (obviously remove the "use automatically when acquired" if you need to) for your general items, like quest items, potions, etc. Then, this trigger would be used to restrict the items:

PHP:
inventory
    Events
        Unit - A unit Acquires an item
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Item-class of (Item being manipulated)) Equal to Artifact
                (Item-class of (Item being manipulated)) Equal to Purchasable
                (Item-class of (Item being manipulated)) Equal to Permanent
                (Item-class of (Item being manipulated)) Equal to Charged
                (Item-class of (Item being manipulated)) Equal to Campaign
                (Item-class of (Item being manipulated)) Equal to Miscellaneous
    Actions
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-class of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (Item-class of (Item being manipulated))
                    Then - Actions
                        Hero - Drop the item from slot (Integer A) of (Hero manipulating item)
                        Game - Display to (All players) the text: Sorry, you can only...
                    Else - Actions
                        Do nothing

However, the trigger does not work. It will not allow you to pick up any item of those classes, even if there is no other item of that class in your inventory.
 
It might be that since the trigger fires after the unit has already picked up the item, it counts that item in its evaluation, so it will always drop it, due to the fact that it is comparing the item to itself at some point. Add a comparison in the loop that the item in the Integer A slot is NOT the item being manipulated and see if that works.
 
That's what I got to thinking as well. So I did what you said and added that comparison, but now the trigger doesn't display the message or drop the item when two items of the same class are picked up. This is the new trigger, all I added was that comparison.

PHP:
inventory
    Events
        Unit - A unit Acquires an item
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Item-class of (Item being manipulated)) Equal to Artifact
                (Item-class of (Item being manipulated)) Equal to Purchasable
                (Item-class of (Item being manipulated)) Equal to Permanent
                (Item-class of (Item being manipulated)) Equal to Charged
                (Item-class of (Item being manipulated)) Equal to Campaign
                (Item-class of (Item being manipulated)) Equal to Miscellaneous
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Item-class of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (Item-class of (Item being manipulated))
                (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Not equal to (Item-type of (Item being manipulated))
            Then - Actions
                Hero - Drop the item from slot (Integer A) of (Hero manipulating item)
                Game - Display to (All players) the text: Sorry, you can only...
            Else - Actions
                Do nothing

I think the problem might have something to do with that comparison. I think that the program is thinking that, yes, the item is of the same class but it is not the same item type as the one that was found, so therefore it is allowed to be picked up.
 
Try a straight item comparison like this:

Code:
(Item carried by <Unit> in slot (Integer A)) Not equal to (Item being manipulated)
 
Hmm...I just tried that and it doesn't work either. This is really confusing. I've looked over the trigger many times but I can't tell why it's doing this.
 
Alright, the way it's set up is there's a hero surrounded by items. The items are sorted so that they're all in pairs of the same class. For example, the two in front of the hero are Artifacts, etc. I did this so I could see if the system worked.
 

Attachments

  • MTG Inventory.w3x
    17.5 KB · Views: 71
Oh, I could kick myself, but I won't. :p You don't have a loop. You need to add a For Each Integer A loop like this:

Code:
For each (Integer A) from 1 to 6, do (Actions)
    Loop - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Item-class of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (Item-class of (Item being manipulated))
                (Item carried by (Hero manipulating item) in slot (Integer A)) Not equal to (Item being manipulated)
            Then - Actions
                [COLOR="Red"]Hero - Drop (Item being manipulated) from (Hero manipulating item)[/COLOR]
                Game - Display to (All players) the text: Sorry, you can only...
            Else - Actions
                Do nothing

I also changed the thing in red because otherwise it would switch items.
 
lol I JUST realized that when I looked at the trigger after I posted. And when I tested after adding the loop back in it worked, but yeah I noticed the bug where it switches items, I'll change that. Thanks for your help, it should work now. +rep
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      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