Snippetage
version 2 by Dave Robinson
Version 2 of Snippetage by Dave Robinson begins here.
"Some functions for setting and use of snippets (parts of the player's command)."
To decide which snippet is the word at (N - a number): decide on the snippet at N of 1.
[ This is alternative phrasing. ]
To decide which snippet is the snippet of length (L - a number) at (N - a number): decide on the snippet at N of L.
[ This is alternative phrasing. ]
To decide which snippet is the snippet at word (N - a number) of length (L - a number): decide on the snippet at N of L.
[ This is alternative phrasing. ]
To decide which snippet is the snippet at (N - a number) of length (L - a number): decide on the snippet at N of L.
To decide which snippet is the snippet at (N - a number) of (L - a number):
(- (100*{N} + {L}) -).
To decide what number is the command length:
decide on the length of the player's command.
To decide what number is the length of (S - a snippet): (- {S}%100 -).
To decide what number is the start of (S - a snippet): (- {S}/100 -).
To decide what number is the end of (S - a snippet):
let N be the start of S plus the length of S minus 1;
decide on N.
To decide whether (S - a snippet) is valid:
if the start of S is less than 1, decide no;
if the length of S is less than 1, decide no;
if the end of S is greater than the command length, decide no;
decide yes.
To decide whether (S - a snippet) is invalid:
if S is valid, decide no; otherwise decide yes.
To decide what number is the verb position: (- verb_wordnum -).
To decide what snippet is the command from (N - a number) onwards:
let L be the command length plus 1 minus N;
decide on the snippet at N of L.
To decide what snippet is the verb word:
decide on the word at the verb position.
Snippetage ends here.