'if ( a_check<x> )' functionality detection

Moderator: GZDoom Developers

User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: 'if ( a_check<x> )' functionality detection

Post by randi »

FishyClockwork wrote:This on its own doesn't declare 'success' (because it's a jumping function)

Code: Select all

TNT1 A 0 A_Jump(111, "bleh")
To clarify, the above should be thought of as a compact way to write:

Code: Select all

TNT1 A 0 { return A_Jump(111, "bleh"); }
Because that's exactly how it gets processed. The two produce exactly the same code for the VM because they are the same.

It has no effect on the success of a CustomInventory state chain not because you called a jumping function but because the jumping function, which returns a state, is called with return to propagate the result out to the caller of your little function.

If it helps, what you are creating with this single line is an anonymous function ("anonymous" because it has no name) with an inferred return type, and the state calls that function. If it was written out as an explicit function (supposing DECORATE could express this), it would look something like this:

Code: Select all

actor MyActor
{
    action state A_MyJumper()
    {
        return A_Jump(111, "bleh");
    }

    states
    {
        TNT1 A 0 A_MyJumper
    }
}
FishyClockwork wrote:while this does declare 'success' because it doesn't return anything, nevermind its contents, correct?
Correct. This function returns nothing, so it gets counted as success.
User avatar
Fishytza
Posts: 793
Joined: Wed Feb 23, 2011 11:04 am
Preferred Pronouns: They/Them
Contact:

Re: 'if ( a_check<x> )' functionality detection

Post by Fishytza »

Right. Everything's clear now. Thank you for being patient with me, Randi. :)
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”