diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-06 10:51:11 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-06 10:52:37 -0700 |
commit | 55479bc29dfc7148e38d8c24b072e3588739f18e (patch) | |
tree | 98fc37560c59bde6ee1b71163bae017df2f3abe5 /085scenario_console.cc | |
parent | 5af07e1c2c65e74ecacaa3077e17a492a8532ab0 (diff) | |
download | mu-55479bc29dfc7148e38d8c24b072e3588739f18e.tar.gz |
3445
Ugly that we didn't need 'screen' to provide a type in scenarios (because assume-screen expands to a definition of 'screen') but we did need a type for 'console'. Just never require types for special names in scenarios.
Diffstat (limited to '085scenario_console.cc')
-rw-r--r-- | 085scenario_console.cc | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/085scenario_console.cc b/085scenario_console.cc index 11d543fc..c0223c26 100644 --- a/085scenario_console.cc +++ b/085scenario_console.cc @@ -15,10 +15,10 @@ scenario keyboard-in-scenario [ type [abc] ] run [ - 1:char, console:&:console, 2:bool <- read-key console:&:console - 3:char, console:&:console, 4:bool <- read-key console:&:console - 5:char, console:&:console, 6:bool <- read-key console:&:console - 7:char, console:&:console, 8:bool, 9:bool <- read-key console:&:console + 1:char, console, 2:bool <- read-key console + 3:char, console, 4:bool <- read-key console + 5:char, console, 6:bool <- read-key console + 7:char, console, 8:bool, 9:bool <- read-key console ] memory-should-contain [ 1 <- 97 # 'a' @@ -187,6 +187,23 @@ void initialize_key_names() { Key["escape"] = TB_KEY_ESC; } +:(after "Begin transform_names Ingredient Special-cases(ingredient, inst, caller)") +if (is_scenario(caller)) + initialize_special_name(ingredient); +:(after "Begin transform_names Product Special-cases(product, inst, caller)") +if (is_scenario(caller)) + initialize_special_name(product); +:(code) +bool is_scenario(const recipe& caller) { + return starts_with(caller.name, "scenario_"); +} +void initialize_special_name(reagent& r) { + if (r.type) return; + // no need for screen + if (r.name == "console") r.type = new_type_tree("address:console"); + // End Initialize Type Of Special Name In Scenario(r) +} + :(scenario events_in_scenario) scenario events-in-scenario [ assume-console [ @@ -197,15 +214,15 @@ scenario events-in-scenario [ ] run [ # 3 keyboard events; each event occupies 4 locations - 1:event <- read-event console:&:console - 5:event <- read-event console:&:console - 9:event <- read-event console:&:console + 1:event <- read-event console + 5:event <- read-event console + 9:event <- read-event console # mouse click - 13:event <- read-event console:&:console + 13:event <- read-event console # non-character keycode - 17:event <- read-event console:&:console + 17:event <- read-event console # final keyboard event - 21:event <- read-event console:&:console + 21:event <- read-event console ] memory-should-contain [ 1 <- 0 # 'text' |