BEGIN { longname["n"] = "north"; longname["s"] = "south"; longname["e"] = "east"; longname["w"] = "west"; longname["u"] = "up"; longname["d"] = "down"; } $1=="room" { rooms[$2] = $3; next; } $1=="test" { locktest[$2] = $3; next; } $1=="set" { lockset[$2] = $3; lockn[$2] = 0; next; } $1=="link" { if (NF == 4) { printf("@set #%s=_%s:%s\n",rooms[$2],$3,rooms[$4]); } else if (NF == 5) { printf("@set #%s=_%s:%s/%s\n",rooms[$2],$3,rooms[$4],locktest[$5]); switch = substr($5,1,1); if ($2 ~ /[A-Z]/) { onverb = "rises into the ceiling"; offverb = "drops from the ceiling"; onstate = "open"; offstate = "blocked"; } else { onverb = "rises from the floor"; offverb = "drops into the floor"; onstate = "blocked"; offstate = "open"; } key = switch "on"; lockn[key] ++; i = lockn[key]; printf("@set #%s=_loc_%d:%s\n",lockset[key],i,rooms[$2]); printf("@set #%s=_line_%d_1:With a barely-audible whir, the barrier to the %s %s.\n", lockset[key], i, longname[$3], onverb); printf("@set #%s=_line_%d_2:The passage to the %s is now %s.\n", lockset[key], i, longname[$3], onstate); key = switch "off"; lockn[key] ++; i = lockn[key]; printf("@set #%s=_loc_%d:%s\n",lockset[key],i,rooms[$2]); printf("@set #%s=_line_%d_1:With a barely-audible whir, the barrier to the %s %s.\n", lockset[key], i, longname[$3], offverb); printf("@set #%s=_line_%d_2:The passage to the %s is now %s.\n", lockset[key], i, longname[$3], offstate); } else { printf("ERROR: %s\n",$0); } next; } { printf("UNRECOGNIZED: %s\n",$0); }