Chaosforge Forum

  • March 28, 2024, 12:55
  • Welcome, Guest
Please login or register.



Login with username, password and session length
Pages: [1]

Author Topic: How to check for a weapon's group?  (Read 3513 times)

SPTX

  • Sergeant
  • *
  • Offline Offline
  • Posts: 77
  • Lost Soul
    • View Profile
How to check for a weapon's group?
« on: April 28, 2013, 06:38 »

I tried using
Code: [Select]
if player.eq.weapon.group == "weapon-melee"But does the following error
Code: [Select]
Unknown property "group" requested on object of type TItem!
Why is that so? the property works when creating a new weapon, it's also there using the table logger from there, so it definitely exists. I am really confused.
Logged

yaflhdztioxo

  • Programmer
  • Local Inquisitor
  • Captain
  • *
  • *
  • Offline Offline
  • Posts: 298
  • Lost Sole
    • View Profile
Re: How to check for a weapon's group?
« Reply #1 on: April 28, 2013, 07:39 »

That's on prototypes, not items themselves.  The way to access it is items[item_id].group

I don't know why it isn't be exposed as a read-only item property but it's not. I just mod here.
Logged

SPTX

  • Sergeant
  • *
  • Offline Offline
  • Posts: 77
  • Lost Soul
    • View Profile
Re: How to check for a weapon's group?
« Reply #2 on: April 28, 2013, 15:58 »

I don't understand what you mean by "items[item_id].group".
Not to mention that I need to compare my equipped item to a particular group. ie : if the player has a shotgun or a melee weapon equipped, function doesn't happen.
I really need to do it from the equipped weapon.
Logged

yaflhdztioxo

  • Programmer
  • Local Inquisitor
  • Captain
  • *
  • *
  • Offline Offline
  • Posts: 298
  • Lost Sole
    • View Profile
Re: How to check for a weapon's group?
« Reply #3 on: April 28, 2013, 16:42 »

The weapon will have an item ID.

items[ self.eq.weapon.id ].group
Logged

SPTX

  • Sergeant
  • *
  • Offline Offline
  • Posts: 77
  • Lost Soul
    • View Profile
Re: How to check for a weapon's group?
« Reply #4 on: April 29, 2013, 13:30 »

And and I was going to use variables... stupid me.
Logged
Pages: [1]