Exposed FindStateByString() to ZScript.
This allows for using ZScript code to jump to different versions of states without using If/Else blocks or Switch cases.
This commit is contained in:
parent
c8a7507e8e
commit
e1f585f6fd
2 changed files with 12 additions and 2 deletions
|
|
@ -387,7 +387,7 @@ FState *FStateLabelStorage::GetState(int pos, PClassActor *cls, bool exact)
|
|||
|
||||
//==========================================================================
|
||||
//
|
||||
// State label conversion function for scripts
|
||||
// State label conversion functions for scripts
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
|
|
@ -395,7 +395,7 @@ DEFINE_ACTION_FUNCTION(AActor, FindState)
|
|||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_INT(newstate);
|
||||
PARAM_BOOL(exact)
|
||||
PARAM_BOOL(exact);
|
||||
ACTION_RETURN_STATE(StateLabels.GetState(newstate, self->GetClass(), exact));
|
||||
}
|
||||
|
||||
|
|
@ -407,6 +407,15 @@ DEFINE_ACTION_FUNCTION(AActor, ResolveState)
|
|||
ACTION_RETURN_STATE(newstate);
|
||||
}
|
||||
|
||||
// find state by string instead of label
|
||||
DEFINE_ACTION_FUNCTION(AActor, FindStateByString)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_STRING(newstate);
|
||||
PARAM_BOOL(exact);
|
||||
ACTION_RETURN_STATE(self->GetClass()->FindStateByString(newstate.GetChars(), exact));
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Search one list of state definitions for the given name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue