by randi » Fri Feb 19, 2016 10:18 pm
Would it help you if I renamed A_Int, A_Bool, and A_State to int, bool, and state so that they look like function-style casts ala C++? Because that's pretty much what they're there for: Declaring the type of the return value.
- If a function returns a non-NULL state, it causes a jump. If a NULL state is returned, no jump happens. Either way, a CustomInventory chain is not affected.
- If a function returns an int of non-0 or a bool of true, a CustomInventory chain will succeed. If it returns 0 or false, that state will fail, possibly failing a CustomInventory chain. If not called as part of a CustomInventory chain, the return value is ignored.
- If a function returns nothing, a CustomInventory chain will succeed.
So use
return A_Bool(false); or
return A_Int(0); to mark the state as failed. If every state fails, then the chain fails. If any state succeeds, then the whole chain succeeds. (Or if I renamed those functions, that would be
return bool(false); or
return int(0);)
Nothing about CustomInventory's behavior has changed. The only "difference" is that now you can write your own functions to make it fail.
Would it help you if I renamed A_Int, A_Bool, and A_State to int, bool, and state so that they look like function-style casts ala C++? Because that's pretty much what they're there for: Declaring the type of the return value.
[list][*]If a function returns a non-NULL state, it causes a jump. If a NULL state is returned, no jump happens. Either way, a CustomInventory chain is not affected.
[*]If a function returns an int of non-0 or a bool of true, a CustomInventory chain will succeed. If it returns 0 or false, that state will fail, possibly failing a CustomInventory chain. If not called as part of a CustomInventory chain, the return value is ignored.
[*]If a function returns nothing, a CustomInventory chain will succeed.[/list]
So use [i]return A_Bool(false);[/i] or [i]return A_Int(0);[/i] to mark the state as failed. If every state fails, then the chain fails. If any state succeeds, then the whole chain succeeds. (Or if I renamed those functions, that would be [i]return bool(false);[/i] or [i]return int(0);[/i])
Nothing about CustomInventory's behavior has changed. The only "difference" is that now you can write your own functions to make it fail.