HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: Item system / spec system error (or misunderstanding)  (Read 1859 times)

cseibert

  • Developers
  • *
  • Posts: 15
    • View Profile
Item system / spec system error (or misunderstanding)
« on: Dec 15, 12, 06:37:27 PM »

I am trying to implement a GUI for my item system, but I ran across an issue which I can't figure out.  On the client, I have an "InventoryGUI" which contains multiple "ItemGUI".  An ItemGUI is an extension of a GUIPanel with an additional field to store the item id it represents.  When the inventory loads, it requests the spec for each item in order to determine the icon to display in the inventory:

Code: [Select]
//Inside the InventoryGUI class's onControlBuild method


//for each item in the itemcontainer named "inventory"
   slot as NodeRef of Class ItemGUI = createNodeFromPrototype("ItemGUI")
   itemSpecOracle as NodeRef of Class _ItemSpecOracle = item.getMySpecOracle()
   itemSpecOracle.requestSpecByKey(item.SpecKey, itemSpecOracle.createNodeListener(slot, false))
   //add to children list of inventoryGUI

This calls the ItemGUI's EventRaised method when the spec is loaded and updates the ItemGUI's icon (or texture position in my case).

All of this works perfectly.

The user can also double click on an ItemGUI to equip the item.  Double clicking results in an item.requestItemEquip call to the server, in which the server will remove the item from the "inventory" container and place it in a different container based on the item type.  The InventoryGUI will then update soon after this equip request.

This also works perfectly.

What doesn't work is when I have two of the same items (same spec id) in the inventory and try to equip the second one.  By second one, I mean the one that comes later in the inventory due to its position in the item container.  When I do this, I get this error on the client side: "Node 0 not found to call method _ITEMDECORATORONSPECLOADED."  This points to line 55 in _itemClassMethods which means that _specRef is most likely set to None.

The _itemClassMethods script:
Code: [Select]
method EventRaised( obs as NodeRef of Class ObsSubject, data as NodeRef )
  where data is kindof _ItemSpec
    if data.SpecKey = me.GetSpecKey()  //<--------------- I DON'T GET THIS LINE -------------------------
      me._specRef = data
      me._specRef._RequestDecoratorSpecs(me)
      return
    .
  .
  me._specRef._ItemDecoratorOnSpecLoaded(data, me)  //<------------  LINE 55 ---------------------
.

After trying to figure out this error for a couple hours, I decided to just put if me._specRef != None check around line 55 in the class I have extending _item.

This fixed the issue, but I feel like what I did was a hack.  Any explanation on the source of my error would be much appreciated.
« Last Edit: Jan 05, 13, 08:35:05 PM by cseibert »
Logged

katoomm0m0

  • General Accounts
  • *
  • Posts: 44
    • View Profile
Re: Item system / spec system error (or misunderstanding)
« Reply #1 on: Dec 16, 12, 04:27:29 PM »

I have the exact same problem, if i have 2 items with the same specKey in the same container, i get the same error .

Logged
- Claus

Jrome90

  • General Accounts
  • *
  • Posts: 330
    • View Profile
Re: Item system / spec system error (or misunderstanding)
« Reply #2 on: Dec 20, 12, 03:17:55 AM »

I have the exact same problem, if i have 2 items with the same specKey in the same container, i get the same error .

What I have noticed (After hours trying to figure out why) is that if I have more than one "Red Jewel" items in the same container, I get the same error as well.

However, I can have more than one of my item "Gold Ring". The difference between the two items is that the "Red Jewel" has spec decorators (Added by default). While the "Gold Ring" doesn't have any.
Logged

cseibert

  • Developers
  • *
  • Posts: 15
    • View Profile
Re: Item system / spec system error (or misunderstanding)
« Reply #3 on: Jan 02, 13, 08:42:51 PM »

So is this a bug or what?
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1149
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Item system / spec system error (or misunderstanding)
« Reply #4 on: Jan 04, 13, 07:46:32 PM »

I am thinking, that instead of trying to add the actual item to the item bag, to increase a value that represents the amount you have of that item. This would keep the item bag from seeing 2 of the same item, and maybe not give the error.
Logged

cseibert

  • Developers
  • *
  • Posts: 15
    • View Profile
Re: Item system / spec system error (or misunderstanding)
« Reply #5 on: Jan 05, 13, 11:19:00 AM »

That will probably prevent the error, but that is more of a hack to fix it.  If there is no good explanation to why this is occurring, shouldn't we  only assume it is a bug? 

I think the item system is supposed to handle "stackable items," which means it should auto increment your items if you have multiple instances of the same type.  Even so, stackable items have a "max stack" parameter which would split your item into two separate items once that max stack is reached, thus creating the same issue.
Logged

Jrome90

  • General Accounts
  • *
  • Posts: 330
    • View Profile

cseibert,
does it happen with every item?
Logged

Tarra2012

  • General Accounts
  • *
  • Posts: 113
    • View Profile
Re: Item system / spec system error (or misunderstanding)
« Reply #7 on: Jan 18, 13, 03:43:47 AM »

Just reporting a similar error happening here.

When i have two items of same spec, they only render correctly when they are initially created.
After logging out and in again. Some Decorators are not working (same code part that was mentioned above).

Its only happening with 2 or more items of same spec ID. All other visualizations work.
Logged