command <inventory; inv; i> {
set numeric <CurrentObject; 1>
for each object in <inventory> {
' Go through the inventory and add object names in bold
' to an ObjectName array
set string <ObjectName[CurrentObject]; |b#@quest.thing#|xb>
' Add prefix and suffix if they exist
if ( #(quest.thing):prefix# <> ) then set <ObjectName[CurrentObject]; #(quest.thing):prefix# #ObjectName[CurrentObject]#>
if ( #(quest.thing):suffix# <> ) then set <ObjectName[CurrentObject]; #ObjectName[CurrentObject]# #(quest.thing):suffix#>
' Increment the CurrentObject counter
set numeric <CurrentObject; %CurrentObject% + 1>
}
if ( %CurrentObject% = 1 ) then {
' The player isn't carrying anything
msg <Bob is not carrying anything.>
}
else {
' decrement CurrentObject as we will have added an extra 1
' to it after adding the last object
set <CurrentObject; %CurrentObject% - 1>
msg <Bob is carrying:|n>
for <i; 1; %CurrentObject%> {
msg <#ObjectName[i]#>
' Add a comma after all but the last object printed
if ( %i% <> %CurrentObject% ) then msg <, >
}
}
}
Bob is carrying:
an object one !, an object two !, an object 3 !
description {
set string <indescription; $gettag(#quest.currentroom#;indescription)$>
if is <#indescription#;> then set string <indescription; You are in>
else {
set numeric <len; $lengthof(#indescription#)$>
set numeric <len; %len%-1>
set string <indescription; $left(#indescription#;%len%)$>
}
msg <#indescription# |b|cl#quest.formatroom#|xb|cb.>
if not is <#quest.doorways.out#;> then msg <You can go out to #quest.doorways.out#.>
if not is <#quest.doorways.dirs#;> then msg <You can go #quest.doorways.dirs#.>
if not is <#quest.doorways.places#;> then msg <You can go to #quest.doorways.places#.>
if not is <#quest.objects#;> then msg <You can see #quest.formatobjects#.>
msg <#quest.lookdesc#>
}
if ( #(quest.thing):prefix# <> ) then set <ObjectName[CurrentObject]; #(quest.thing):prefix# #ObjectName[CurrentObject]#>
if ( #(quest.thing):suffix# <> ) then set <ObjectName[CurrentObject]; #ObjectName[CurrentObject]# #(quest.thing):suffix#>
if ( #(quest.thing):prefix# <> ! ) then set <ObjectName[CurrentObject]; #(quest.thing):prefix# #ObjectName[CurrentObject]#>
if ( #(quest.thing):suffix# <> ! ) then set <ObjectName[CurrentObject]; #ObjectName[CurrentObject]# #(quest.thing):suffix#>
for <i; 1; %CurrentObject%> {
if ( %i% = 1 ) then msg <$capfirst(#ObjectName[i]#)$> else msg <#ObjectName[i]#>
' Add a comma after all but the last object printed
if ( %i% <> %CurrentObject% ) then msg <, >
}
description {
set string <indescription; $gettag(#quest.currentroom#;indescription)$>
if is <#indescription#;> then set string <indescription; You are in>
else {
set numeric <len; $lengthof(#indescription#)$>
set numeric <len; %len%-1>
set string <indescription; $left(#indescription#;%len%)$>
}
msg <#indescription# |b|cl#quest.formatroom#|xb|cb.>
if ( #quest.doorways.out# <> ) then msg <Bob can go out to #quest.doorways.out#.>
if ( #quest.doorways.dirs# <> ) then msg <Bob can go #quest.doorways.dirs#.>
if ( #quest.doorways.places# <> ) then msg <Bob can go to #quest.doorways.places#.>
if ( #quest.objects# <> ) then msg <Bob can see #quest.formatobjects#.>
msg <#quest.lookdesc#>
}
command <inventory; inv; i> {
set numeric <inv-count; 0>
set numeric <inv-total; 0>
for each object in <inventory> set numeric <inv-total; %inv-total% + 1>
if ( %inv-total% = 0 ) then set string <inv-list; nothing.|n> else {
for each object in <inventory> {
set numeric <inv-count; %inv-count% + 1>
if property <#quest.thing#; prefix> then set string <inv-item; $objectproperty(#quest.thing#; prefix)$ $displayname(#quest.thing#)$> else set string <inv-item; $displayname(#quest.thing#)$>
if property <#quest.thing#; suffix> then set string <inv-item; #inv-item# $objectproperty(#quest.thing#; suffix)$>
property <temp; %inv-count%=#inv-item#>
set string <inv-item; >
}
for <inv-create; 1; %inv-total%> if ( %inv-create% <> 1 ) and ( %inv-create% <> %inv-total% ) then set string <inv-list; #inv-list#, $objectproperty(temp; %inv-create%)$> else {
if ( %inv-create% = 1 ) and ( %inv-create% <> %inv-total% ) then set string <inv-list; $objectproperty(temp; %inv-create%)$>
if ( %inv-create% = %inv-total% ) and ( %inv-create% <> 1 ) then set string <inv-list; #inv-list# and $objectproperty(temp; %inv-create%)$.|n>
if ( %inv-create% = 1 ) and ( %inv-create% = %inv-total% ) then set string <inv-list; $objectproperty(temp; %inv-create%)$.|n>
}
}
msg <Bob is carrying #inv-list#>
}
define room <temp>
end define