Can CustomInventory use args?

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
Ravick
Posts: 2047
Joined: Sun Aug 22, 2010 10:59 pm
Location: Tubarão, Brasil
Contact:

Can CustomInventory use args?

Post by Ravick »

Hi there.

I'm trying the following:

Code: Select all

Actor PDA2 : CustomInventory 10226
{
    //$Category Itens
    Height 16
    Radius 11
    Inventory.PickupMessage "You got someone's PDA..."
	Inventory.PickupSound "Beep1"
    States
    {
        Spawn:
            RPDA B -1
            Stop
        Pickup:
            TNT1 A 0 ACS_Execute (982, 0, args[0])
            //TNT1 A 0 ACS_Execute (args[0], 0, 0)
            Stop
    }
}
This is a CustonInventory that should allow me to trigger the script 982 and pass its args[0] when picked up. But seems to always execute the script with args[0]=0. If I swap the command for that commented line, it'll try to execute "Script 0". It is impossible to make it this way? If so, how'd you make this?

Thaks in advanced!
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: Can CustomInventory use args?

Post by Arctangent »

CustomInventory's Pickup and Use states, like a Weapon's Ready, Fire, etc. states, aren't ran by the item itself, but whatever's picking up / using it. So, args[0] will always return 0 unless you set the player's args[0] to something else, because they're the one running the state.

Your best bet is to use ZScript, so you can actually reference the invoker ( aka, the CustomInventory actor ) or so you can just run the script via one of item's virtual functions, which will let you get away with just Inventory. Alternatively, you could give it the INVENTORY.TRANSFER flag and have it give itself a number of dummy inventory items equal to its args[0] in its Spawn state, which will then be given to the player and then you can count 'em with [wiki]CountInv[/wiki] in place of args[0]. Though, if ZScript isn't an option, then it's likely that INVENTORY.TRANSFER isn't one, either, in which case your only real option is to have a unique PDA actor for every possible ACS_Execute call.
User avatar
phantombeta
Posts: 2175
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Can CustomInventory use args?

Post by phantombeta »

Based on that, I'm guessing you're setting the args in a map-placed thing. If so, there's no need to even use a CustomInventory actor. Just make it inherit from Inventory directly, and set ACS_Execute as the thing's special in GZDoom Builder - inventory items execute their specials when picked up.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49230
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Can CustomInventory use args?

Post by Graf Zahl »

Actually, if the whole point of an item is to run a script and then disappear, [wiki=Classes:FakeInventory]FakeInventory[/wiki] is the best option, it has been designed for precisely this purpose. (This is the class being used by old-style DECORATE pickups
User avatar
Ravick
Posts: 2047
Joined: Sun Aug 22, 2010 10:59 pm
Location: Tubarão, Brasil
Contact:

Re: Can CustomInventory use args?

Post by Ravick »

Thank you for all the ideas, pals. :)

It is working fine now thanks to you. :D
Post Reply

Return to “Scripting”