process-input no longer falls through to other objects
parent
23f3a04ef7
commit
10e2ff438c
|
@ -48,6 +48,13 @@ OBJECT door
|
|||
ACTION multi
|
||||
$multiactions
|
||||
|
||||
OBJECT foo
|
||||
ACTION bar
|
||||
MSG Foo bar
|
||||
OBJECT cow
|
||||
ACTION moo
|
||||
MSG MOOOOOOOOOOOOOOOOOO!
|
||||
|
||||
STORY
|
||||
This is a test scene.
|
||||
"
|
||||
|
@ -69,7 +76,7 @@ assert-equal "$( tryinput "open door" )" "GO $scene_opendoor" || {
|
|||
|
||||
# actions on unknown objects should simply output an empty string
|
||||
assert-equal "$( tryinput "open idkwhat" )" "" || {
|
||||
simplefail "Should not be able to perform actions on unknown objects"
|
||||
fail "Should not be able to perform actions on unknown objects"
|
||||
}
|
||||
|
||||
# unknown actions on known objects should simply output an empty string
|
||||
|
@ -83,3 +90,14 @@ assert-equal "$( tryinput "multi door" )" "$expected" || {
|
|||
fail "All commands for a multi-line action should be returned"
|
||||
}
|
||||
|
||||
# should not fall through to another object (action exists in object below the
|
||||
# first)
|
||||
assert-equal "$( tryinput "bar door" )" "" || {
|
||||
fail "Actions should not fall through to other objects"
|
||||
}
|
||||
|
||||
# fallthrough shouldn't occur if no newline separates objects
|
||||
assert-equal "$( tryinput "moo foo" )" "" || {
|
||||
fail "Actions should not fall through to other objects (missing nl)"
|
||||
}
|
||||
|
||||
|
|
|
@ -45,9 +45,14 @@ object=$( cut -d' ' -f2 <<< "$words" )
|
|||
# check for am action on a known object and output the associated commands, left
|
||||
# trimmed
|
||||
awk "
|
||||
/OBJECT $object/,/^$/ {
|
||||
/OBJECT $object/ {
|
||||
found = 1
|
||||
getline
|
||||
}
|
||||
found && /^[ \\t]*$|^[A-Z]/ {
|
||||
found = 0
|
||||
}
|
||||
|
||||
/^( |\\t)ACTION $action$/ {
|
||||
if ( found ) {
|
||||
getline
|
||||
|
|
Loading…
Reference in New Issue