#--- Debug.library ---





constant dl_version 1
integer dl_index 0
integer dl_temp 0

string dl_total
string dl_code
integer dl_count
integer dl_counter

grammar intarray $string >intarray

{+intarray
setstring dl_total : "@", string_arg[0]
set dl_count = dl_total
set dl_index = 0
while dl_index != dl_count
   setstring code : string_arg[0], "[", dl_index, "]"
   set dl_counter = code 
   write dl_index ": " dl_counter ^
   set dl_index + 1
endwhile 
set time = false
}

grammar strarray $string >strarray

{+strarray
setstring dl_total : "@", string_arg[0]
set dl_count = dl_total
set dl_index = 0
while dl_index != dl_count
   setstring code : string_arg[0], "[", dl_index, "]"
   write dl_index ": " code ^
   set dl_index + 1
endwhile 
set time = false
}

grammar valueof $string >valueof

{+valueof
set INDEX = $string
if INDEX = -1
write "That variable does not exist.^"
else
write $string " = " INDEX ^
endif
set time = false
}

grammar locationof *anywhere >locationof

{+locationof
if noun1 has LOCATION
write noun1{The} " " noun1{is} " a location.^"
return
endif
set dl_index locationof noun1
write noun1{The} " is in " dl_index{the} ".^"
set time = false
}

grammar grandof *anywhere >grandof

{+grandof
set dl_index grandof noun1
if dl_index != noun1
write noun1{The} " " noun1{is} " in " dl_index{the} ".^"
else
write noun1{The} " " noun1{is} " not in a container.^"
endif
set time = false
}

grammar fetch **anywhere >fetch

{+fetch
if noun1(parent) = here
write noun1{The} " is allready here.^"
return
endif
move noun1 to here
ensure noun1 hasnt OUT_OF_REACH
write noun1{The} " appears in a flash of light.^"
set time = false
}

grammar inspectobj $string >inspect_obj

{+inspect_obj
set noun3 = $string
proxy "inspect " noun3{names}
set time = false
}

grammar inspect **anywhere >inspect

{+inspect
inspect noun1
set time = false
}

grammar teleport to *location	>teleport
grammar teleport *location		>teleport

{+teleport
if noun1 = here
   write "You are already there!^"
   return
endif
move player to noun1
look
set time = false
}


grammar stepto *location >stepto

{+stepto
npc_to dl_index here noun1
if noun1 = here
   write "You are already there!^"
   return
endif
if dl_index = -1
   write "There is no way to get to " noun1{the} " from here.^"
   return
endif
write "To get to " noun1{the} " you need to travel " dir_command[dl_index] .^
set time = false
}

grammar dlstats >dl_stats

{+dl_stats
write "*** Game Statistics ***^"
set dl_temp = 0
set dl_index = 0
loop
if noun3 has LOCATION
set dl_index + 1
endif
endloop
write "There "
if dl_index = 1
write "is "
else
write "are "
endif
write dl_index
if dl_index <= 1
write " location in the game.^"
else
write " locations in the game.^"
endif
set dl_temp = objects
set dl_temp - dl_index
write dl_temp " objects "
if dl_index <= 1
write "is defined without the LOCATION attribute.^"
else
write "are defined without the LOCATION attribute.^"
endif
write "Total objects defined: " objects .^
set time = false
}


grammar dlhelp >dl_help

{+dl_help
print:
   *** Help for Debug.library ***^
   locationof <object> - Returns the location of an object.^
   grandof <object> - Returns the object that holds the specified object and is in the location of the specified object (I.E. an apple in a rucksack which is held by the player).^
   valueof <container> - Returns the integer value of any variable or object element.^
   intarray <array> - Show all values in an integer array.^
   strarray <array> - Show all values in a string array.^
   fetch <object> - Moves the specified object to the player's location.^
   inspect <object> - Returns the properties of the specified object.^
   stepto <location> - Returns the direction to travel to get to this location.^
   teleport <location> (teleport to <location>) - Moves the player object instantly to the specified location.^
      dlstats - Returns some statistical information about the game.^
.
set time = false
}
