Skip to content

Commit

Permalink
add .state conditional (#1024)
Browse files Browse the repository at this point in the history
This is useful for telling the user the current state (or last executed
action) of the player for apl sims.
  • Loading branch information
skippi authored Nov 4, 2022
1 parent c5a593d commit cc7c2be
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/conditional/conditional.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import (

func fieldsCheck(fields []string, expecting int, category string) error {
if len(fields) < expecting {
return fmt.Errorf("bad %v condition; invalid num of fields; expecting at least %v; got %v", category, expecting, len(fields))
return fmt.Errorf(
"bad %v condition; invalid num of fields; expecting at least %v; got %v",
category,
expecting,
len(fields),
)
}
return nil
}
Expand All @@ -33,8 +38,10 @@ func Eval(c *core.Core, fields []string) (any, error) {
return evalGadgets(c, fields)
case "keys":
return evalKeys(c, fields)
case "state":
return int(c.Player.CurrentState()), nil
default:
//check if it's a char name; if so check char custom eval func
// check if it's a char name; if so check char custom eval func
name := fields[0]
if key, ok := shortcut.CharNameToKey[name]; ok {
return evalCharacter(c, key, fields)
Expand Down

0 comments on commit cc7c2be

Please sign in to comment.