Get amount of armor in inventory

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Get amount of armor in inventory

Postby Apeirogon » Sat Mar 03, 2018 4:59 am

I try make armor repairing inventory item.

Code: Select allExpand view
class repa : inventory
{
    override void DoEffect()
   {
        let arm = Owner.FindInventory("BasicArmor", true);
        if (arm!= null)
      {
        arm.ActualSaveAmount += 1;//error here
      }
    }

   states
   {
   spawn:
      arm1 a 1;
      loop;
   }
}

Script error Unknown identifier 'ActualSaveAmount'


But it dont know what means 'actual save amount' and 'save amount' too.
So, how check how much armor have armor item in actor inventory?

And can it be checked how much original ARMOR itself and armor bonus have this armor item?
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Get amount of armor in inventory

Postby Blue Shadow » Sat Mar 03, 2018 5:15 am

Apeirogon wrote:it dont know what means 'actual save amount' and 'save amount' too.

See GetArmorInfo.

So, how check how much armor have armor item in actor inventory?

Check for Amount, instead.

Edit: The reason you get the error in your code is that arm is returned as Inventory, and Inventory doesn't have a variable that's called ActualSaveAmount. This variable is declared in BasicArmor. However, if you cast arm to BasicArmor then you can access said variable:

Code: Select allExpand view
int asa = BasicArmor(arm).ActualSaveAmount
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Get amount of armor in inventory

Postby Apeirogon » Sat Mar 03, 2018 5:32 am

But GetArmorInfo ACS function, or zscript know about it?

And again problem with proper casting... I start think cast "type" of actor in every single point of where I use find inventory...
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Get amount of armor in inventory

Postby Blue Shadow » Sat Mar 03, 2018 6:17 am

Apeirogon wrote:But GetArmorInfo ACS function, or zscript know about it?

That page explains what SaveAmont and ActualSaveAmount are, and the difference between them. That's why I put a link to it.
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest