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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Get amount of armor in inventory

Post by Apeirogon »

I try make armor repairing inventory item.

Code: Select all

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?
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Get amount of armor in inventory

Post by Blue Shadow »

Apeirogon wrote:it dont know what means 'actual save amount' and 'save amount' too.
See [wiki]GetArmorInfo[/wiki].
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 all

int asa = BasicArmor(arm).ActualSaveAmount; 
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Get amount of armor in inventory

Post by Apeirogon »

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...
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Get amount of armor in inventory

Post by Blue Shadow »

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.
Post Reply

Return to “Scripting”