Author Topic: Adding Troflip's Easy alt Debugging  (Read 5110 times)

0 Members and 2 Guests are viewing this topic.

Offline Cloudee1

Adding Troflip's Easy alt Debugging
« on: March 08, 2007, 10:48:05 AM »
Alright, this was originally posted by Troflip at Mega-Tokyo. 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 to 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, if you are using scicompanion, which Troflip made, he has already included this in the companions template game, you will only need this if you are working on a game created with scistudio.

In the Main scripts Handle event method, add between the
Code: [Select]
(method (handleEvent pEvent)and the
Code: [Select]
(super:handleEvent(pEvent))all of this
Code: [Select]
  // 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 $1f00 (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 - *the only one I really use 


   
« Last Edit: March 08, 2010, 07:16:45 PM by Cloudee1 »


Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline gumby

Re: Adding Troflip's Easy alt Debugging
« Reply #1 on: January 24, 2013, 10:55:17 PM »
I've added additional code to ensure that a valid number is input before utilizing the alt-t or alt-i (teleport or inventory). I did this because I found myself hitting the wrong debug code, and didn't want to enter anything; but pressing just 'enter' caused the game to crash.

Code: [Select]
  (method (handleEvent pEvent)
           (var num)

           ...

  (case $1400 // alt-t
        // teleport to room
                 = num GetNumber("Which Room Number?")
                 (if (> num 0)
                (send gRoom:newRoom(num))
                 )
  )      
  (case $1700 // alt-i
        // get inventory
        = num GetNumber("Which inventory#?")
        (if (> num 0)
              (send gEgo:get(num))
        )
   )

See the fullly modified Main.sc script here: http://sciprogramming.com/community/index.php/topic,698.msg3759.html#msg3759
« Last Edit: January 24, 2013, 10:57:00 PM by gumby »
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.045 seconds with 22 queries.