container list

oblomov
07 Oct 2009, 18:29
howdy.. please dont hurt me if you think its dumb asking.. but.. how's the parameter for the content of a container? my problem is the following: if i look at my container, i dont want the standard response. so i need to make a script that sais: print "Suddenly there appears your lost #quest.???#", no? something like that, i guess..

please help..
thanx,
o.

oblomov
11 Oct 2009, 17:00
hey folks.. its hard to believe that nobody knows an answer to my little problem.. please help!

Overcat
12 Oct 2009, 10:06

its hard to believe that nobody knows an answer to my little problem..



Perhaps you could explain your problem a little more clearly. I'm not entirely sure what you're looking for.

insidethecircle
12 Oct 2009, 11:31
on the same topic,
how do you print on the screen what is in a container - or equally what is in a room but not in container.
i know quest can do it as it can display what is in the inventory and differentiate between it's objects and the current room's.
>furrowed brow<

oblomov
12 Oct 2009, 14:24
okay, sorry, i´ll try it again:

my problem is as following: lets say, in my room there is a container (which is a container-object).
the player types: look container.
the standard-response would be: it contains *whatever*.

the thing is that i dont want the standard-response but another one, so for the case, that the player types "look container" i choose "run a script" which prints something like: "Magically a *whatever* has appeared!"

my question now is: whats the proper code for my *whatever*? (which is all the objects, that my container contains)

i hope i made myself a bit better understood this time..
o.

Freak
12 Oct 2009, 14:45
Write out a sample transcript.

Overcat
12 Oct 2009, 16:18
oblomov:

The answer to your question depends on how you've constructed your game so far. While I assume you've used the built-in container functionality, it is not impossible (because it is neither difficult nor unwieldy to do so) that you've whipped together your own containers from scratch. In either case, it would be helpful if you could post your ASL file (in full, or, if it is large, as an attachment). As Freak has mentioned, a sample transcript would be nice, too.

IE:

> look in box
*poof*! Stuff magically appears.

insidethecircle:

The for-each loop construct can handle printing objects. This is it's basic form:

for each object in <#quest.currentroom#> {
msg <#quest.thing#>
}


But that won't give you pretty results (try it!), so here's a general purpose procedure which you can hack...

'parameter1 = any room
define procedure <ShowObjects>

set string <sRoomObjects; >
set string <sLocation; $parameter(1)$>
set numeric <i; 0>

if (#sLocation# <> inventory) then {

msg <In the room you can see |xn>
}
else {
msg <In your inventory you have |xn>
}

for each object in <#sLocation#> {
if not property <#quest.thing#; hidden> then inc <i>
}

if (%i% <> 0) then {

set numeric <n; 0>
for each object in <#sLocation#> {
if not property <#quest.thing#; hidden> then {
inc <n>

if (%n% = 1) then {
if ($lengthof(#(quest.thing):prefix#)$ > 0) then {
set <sRoomObjects; #(quest.thing):prefix# #@quest.thing#>
}
else {
set <sRoomObjects; #@quest.thing#>
}
}
else {
if (%i% = %n%) then {
if ($lengthof(#(quest.thing):prefix#)$ > 0) then {
set <sRoomObjects; #sRoomObjects# and #(quest.thing):prefix# #@quest.thing#>
}
else {
set <sRoomObjects; #sRoomObjects# and #@quest.thing#>
}
}
else {
if ($lengthof(#(quest.thing):prefix#)$ > 0) then {
set <sRoomObjects; #sRoomObjects#, #(quest.thing):prefix# #@quest.thing#>
}
else {
set <sRoomObjects; #sRoomObjects#, #@quest.thing#>
}
}
}
}
}

set <sRoomObjects; #sRoomObjects#.>
msg <#sRoomObjects#>
}
else {
msg <nothing.>
}

end define


To see the function in action, you can download the following ASL file, and try the commands 'look room' and 'i' (for inventory). Pick up some objects, then try the commands again.

insidethecircle
13 Oct 2009, 13:29
thanks man
that'l make everything look really cool now