Add some functions for use with DECORATE return

- Since DECORATE's return statement can only return the results of
  function calls (I do not want to spend the time necessary to make it
  return arbitrary expressions), here are three functions to get around
  this limitation:
  * A_State - Returns the state passed to it. You can simulate A_Jump
    functions with this.
  * A_Int - Returns the int passed to it.
  * A_Bool - Returns the bool passed to it.
- e.g. If you want to return the number 3, you use this:

    return A_Int(3);

  If you want to jump to a different state, you use this:

    return A_State("SomeState");
This commit is contained in:
Randy Heit 2016-02-18 22:11:05 -06:00
parent fbbaae781b
commit eace79ccad
3 changed files with 53 additions and 0 deletions

View file

@ -6757,3 +6757,48 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMovementDirection)
} }
ACTION_RETURN_BOOL(true); ACTION_RETURN_BOOL(true);
} }
//===========================================================================
//
// A_State
//
// Returns the state passed in.
//
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_State)
{
PARAM_ACTION_PROLOGUE;
PARAM_STATE(returnme);
ACTION_RETURN_STATE(returnme);
}
//===========================================================================
//
// A_Int
//
// Returns the int passed in.
//
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Int)
{
PARAM_ACTION_PROLOGUE;
PARAM_INT(returnme);
ACTION_RETURN_INT(returnme);
}
//===========================================================================
//
// A_Bool
//
// Returns the bool passed in.
//
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Bool)
{
PARAM_ACTION_PROLOGUE;
PARAM_BOOL(returnme);
ACTION_RETURN_BOOL(returnme);
}

View file

@ -494,6 +494,10 @@ static void ParseNativeFunction(FScanner &sc, PClassActor *cls)
rets.Push(TypeFixed); rets.Push(TypeFixed);
break; break;
case TK_State:
rets.Push(TypeState);
break;
case TK_Identifier: case TK_Identifier:
rets.Push(NewPointer(RUNTIME_CLASS(DObject))); rets.Push(NewPointer(RUNTIME_CLASS(DObject)));
// Todo: Object type // Todo: Object type

View file

@ -332,6 +332,10 @@ ACTOR Actor native //: Thinker
action native int ACS_NamedExecuteWithResult(name script, int arg1=0, int arg2=0, int arg3=0, int arg4=0); action native int ACS_NamedExecuteWithResult(name script, int arg1=0, int arg2=0, int arg3=0, int arg4=0);
action native ACS_NamedExecuteAlways(name script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0); action native ACS_NamedExecuteAlways(name script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0);
native state A_State(state returnme);
native int A_Int(int returnme);
native bool A_Bool(bool returnme);
States States
{ {
Spawn: Spawn: