Adding Troflip's alt Debugging

From SCI Wiki
Jump to navigationJump to search

Adding Troflip's alt Debugging

By Cloudee1

This was originally posted by Troflip on the Mega-Tokyo forums. I kept waiting for him to post this here himself, but with all these new games I keep starting up, I got tired of waiting and up until now I was too lazy to actually go and find it. Until it struck me I've already got it in an older game project. So this is that code, allowing you to press the [alt] plus another key to view some pretty important debugging information.

* Note, this is already included in SCI Companion's template game. It is only needed for SCI Studio.

In the Main scripts Handle event method, add between the

Code:
      (method (handleEvent pEvent)

and the

Code:
        (super:handleEvent(pEvent))

all of this

Code:
// troflip debugging addition, For use in combination with the ALT key
  (if (== evKEYBOARD (send pEvent:type))
    (switch (send pEvent:message)
      (case $2f00 Show(1)) // alt-v -> Show visual screen
      (case $2e00 Show(4)) // alt-c -> Show control screen
      (case $1900 Show(2)) // alt-p -> Show priority screen
      (case $1400 (send gRoom:newRoom(GetNumber("Room Number?")))) // alt-t -> teleport to room
      (case $1700 (send gEgo:get(GetNumber("Which Item?")))) // alt-i -> get inventory
      (case $1e00 (send gCast:eachElementDo(#showSelf))) // alt-s -> Show cast
      (case $3200 ShowFree() // alt-m -> Show memory usage
          FormatPrint(
            "Free Heap: %u Bytes\nLargest ptr: %u Bytes\nFreeHunk: %u KBytes\nLargest hunk: %u Bytes"
            MemoryInfo(miFREEHEAP)
            MemoryInfo(miLARGESTPTR)
            (>> MemoryInfo(miFREEHUNK) 6)
            MemoryInfo(miLARGESTHUNK)
          ) // end formatprint
      ) // end case $3200
    ) // end switch
  ) // end if keyboard event
// and now back to the normal script, You may want to delete all this bit upon release!

And there it is, pressing:

alt-t     -  opens a dialog box to transport to any room
alt-c    -  draws the rooms control colors to the screen.
alt-p    -  draws the rooms priority colors to the screen.
alt-v    -  draws the normal visual room
alt-i     -  opens a dialog box allowing you to get any item
alt-s    -  show self, displays cast list ??
alt-m   -  displays heap and hunk memory usage