I saw in someone else's game sourcecode they used a null synonym. In other words, changing words like "of, to, the" to a blank string via synonyms.
i.e.
define synonyms
on; the; of =
end define
... I have found this doesn't really work too well though, and if you try it in the QDK editor itself vs. a text editor you'll find that QDK doesn't like that empty string, so here is my workaround for this. Setup a synonym for an actual word named "null" :
define synonyms
on; the; of = null
end define
...and then write up a "beforeturn" script like this:
beforeturn {
if ( $instr(#quest.command#;null_)$ >= 1 ) then {
' REM see synonym NULL where on = NULL. this is for things like "put hook on rope" which changes to "put hook rope"
set string <substring; null_>
set numeric <p1; $instr(#quest.command#;#substring#)$>
dec <p1>
set string <s1; $left(#quest.command#;%p1%)$>
inc <p1; $lengthof(#substring#)$>
set string <s2; $mid(#quest.command#;%p1%)$>
set string <quest.command; #s1# #s2#>
set string <quest.originalcommand; #s1# #s2#>
' REM stop quest.command and then re-run it. otherwise the above work is no good
dontprocess
exec <#quest.command#>
}
}
What happens is the script will loop through the quest.command every time it encounters the word "null" in the command, and wipes it out and re-runs the command until there are no "null" words. So this way you can really eliminate out some synonyms or parts of object aliases that used words like "of, the, to, on" etc. and simplify things.
Now, where this really comes in useful is in your custom commands because now you can make a custom command that has:
put #@mything# #@myotherthing#
instead of...
put #@mything# on #@myotherthing#
It wouldn't be a command syntax the player would necessarily be aware of, or even make much sense. What it does, though is simplify your code a little (internally and behind the scenes).
In the above example, I wrote a routine to put a rope over a wall, and aliased out everything so the command is really shortened to "put rope wall." Now for putting objects IN things, I probably will have a different command for that or allow the word "IN" to stay vs. nulling it out.
Anyhow just something I thought I'd share. Not sure if this is the best way to null out words you don't want, but it seems to work better than putting in an empty string synonym (at least since QDK doesn't seem to like those).
One thing to be careful of though. If you null out the word "on" then later want to have a "wear" command (i.e. put on clothes), the player's command of "put on jacket" changes to "put jacket" (which in some games means "drop jacket"). To avoid this you should probably add a synonym above the "null" synonym to change "put on" to "wear" :
define synonyms
put on = wear
on; the; of = null
end define
If you do it in that order, it catches the "on" before it can nullify "on" and the player command for "put on jacket" is processed correctly.
The downside is if you wanted to allow the player to "put jacket on" then you're back to the old "put jacket" (i.e. "drop jacket" interpretation). However you could write up your own "put #@mything#" routine and query the player "Where do you wish to put #mything#?"
Of course in my code above I used the substring "null_" where the underscore means the code is looking for the word null with a space after it. So it would not nullify out the last null by itself at the end of a command. So you could have a custom command for "put #@mything# null" and have it execute the "wear @#mything#" command, and allow just "put #@mything#" to still act as a drop object command.