Axe Software Forums
  Quest Developer Forum
  "TAKE ALL" command


Author Topic:   "TAKE ALL" command
Luca Brazzi posted 21-10-2000 15:48 GMT     
this works when there are up to 10 objects to be picked up in the room, but can work for more. Don't forget that when you add a prefix to an object ("a cat", instead of "cat"), you must define it in a synony, aswell. Otherwise it won't be able to recognise the word "a cat" as just one word.

Basics are:

in the global user defined commands add:

command <take all> do <takeallproc>

in the global start commands add:

do <objectsstartuproc>

in the after turn commands add:

do <objectsstartupproc>
do <object1proc>

the objectsstartupproc:

setstring <object1;0>
setstring <object2;0>
setstring <object3;0>
setstring <object4;0>
setstring <object5;0>

...and so on, up to object10 (or more).

the takeallproc:

basicall a conditional withinconditional kind of thing:

if <#object1#;0> then msg <You have nothing to take here>
else
if <#object2#;0> then exec <take #object1#>
else
if <#object3#;0> then exec <take #object#1> exec <take #object2#>
else
if <#object4#;0> then exec <take #object1#> exec <take <#object2#> exec <take #object3#>

and so forth... (I probably omitted some brackets or something... I wrote it all on the QDK, so I'm not that kind of a professional. Sorry. I'll be glad if you'd amend this and write it up as pure ASL)
when the last one (10, in my case - which is more than enough I think) is:

if <#object10#;0> then {exec <take #object1#> exec <take #object2#> exec <take #object3#> exec <take #object4#> exec <take #object5#>
exec <take #object6#> exec <take #object7#> exec <take #object8#> exec <take #object9#>}
else
{exec <take #object1#> exec <take #object2#> exec <take #object3#> exec <take #object4#> exec <take #object5#>
exec <take #object6#> exec <take #object7#> exec <take #object8#> exec <take #object9#> exec <take #object10#>}

the object1proc:

setvar <object1count;$instr(1;#quest.objects#;,)$>

if <%object1count%;0> then setvar <object1truecount;$lengthof(#quest.objects#)$>
else
{setvar <object1truecount;%object1count% -1>
do <object2proc>}

setstring <object1;$mid(#quest.objects#;1;%object1truecount%)$>

the object2proc is the same as all the next objectprocs (object3proc, and up to object9proc), and goes like this:

setvar <object2startcount;%object1count% +2>
setvar <object2count;$instr(%object2startcount%;#quest.objects#;,)$>

if <%object2count%;0>
then setvar<object2truecount;$lengthof(#quest.objects#)$ -%object1count%>
else
{setvar <object2falsecount;%object2count% -%object2startcount%>
setvar <object2truecount;%object2falsecount% -1>
do <object3proc>}

setstring <object2;$mid(#quest.objects#;%object2startcount%;%object2truecount%)$>

the last objectproc (object10proc, in my case), will be the same, just without the "do <object11proc>" line, ofcourse.

All this will enable you to take all the objects that are in the room, up to ten of them, if, ofcourse, you enabled them to be taken in each of the objects description. If they are not, the program will just print that you can't take this object, and go on to the next.