Adventure Game Studio | Forums

AGS Support => Modules, Plugins & Tools => Topic started by: cat on Sun 22/07/2012 07:18:00

Title: MODULE: DebugHelper - Set/get object/char/hotspot values at runtime
Post by: cat on Sun 22/07/2012 07:18:00
Use this module to read and set the values of objects, characters and hotspots while executing the game.

Press F12 and click on any object/character/hotspot to view the properties. You can even change some of them.
Or you can click a button and view a list of all characters and objects in the current room.

(http://cat.agser.me/modules/DebugHelper.png)

You need to import the script and the two GUIs to make this work. The GUIs will not import additional sprites so it's easy to delete afterwards.

This is an alpha version!

I plan to add regions too. I also consider implementing Setter methods so readonly properties can be used too (but lots of typing, please tell me if this would be really useful).
Any other suggestions?




Download latest version here  (http://duals.agser.me/Files/DebugHelperv02.rar) (AGS 3.2.1 or higher required)

ADDED:
- Gui Controls
- Guis
- Inventory Items
- Now, you can tick away and back in, all the types from the drop down list
- Added transparency to the UIs



OLDER VERSIONS


Download Version 0.1 (http://cat.agser.me/modules/DebugHelper.zip) (AGS 3.2.1 or higher required)

Title: Re: MODULE: DebugHelper - Set/get object/char/hotspot values at runtime
Post by: monkey0506 on Sun 22/07/2012 07:46:34
Quote from: cat on Sun 22/07/2012 07:18:00I also consider implementing Setter methods so readonly properties can be used too (but lots of typing, please tell me if this would be really useful).

Haven't checked it out yet, but I'm a bit confused by what you mean here... Just FYI, any readonly members of a struct cannot be modified in AGS. You'd have to make changes to the engine and/or the built-in script headers to change readonly properties (and every non-writable property of the built-in structures is readonly). If you meant instead that you wanted to provide readonly attributes or writeprotected members for your module's exposed script structure then that would make sense...

Edit: I was just looking over the code, and bloody hell cat, I have to commend you. Aside from Khris' code snippets he posts all the time, your code is one of the very few examples I can think of where I have seen another programmer's code actually maintaining consistent formatting (aside from cases of course where the IDE goes total dictator mode, like MSVC#).

One thing you might consider doing is adding a macro to your module. Something like:

Code (ags) Select
// DebugHelper.ash

#define DEBUGHELPER_ENABLED

// DebugHelper.asc

#ifdef DEBUGHELPER_ENABLED

// YOUR MODULE SCRIPT HERE

#endif


That way instead of having to delete the module and both GUIs, all I have to do is comment out one line in the module header to disable debug mode for your module. It might not seem like a lot, but the less I have to do as the end-user to disable this for release, the better (less steps to remember, etc.).

Other than that I'd say it looks like you're off to a good start with this. :)
Title: Re: MODULE: DebugHelper - Set/get object/char/hotspot values at runtime
Post by: cat on Sun 22/07/2012 08:26:38
Quote from: monkey_05_06 on Sun 22/07/2012 07:46:34
Haven't checked it out yet, but I'm a bit confused by what you mean here... Just FYI, any readonly members of a struct cannot be modified in AGS. You'd have to make changes to the engine and/or the built-in script headers to change readonly properties (and every non-writable property of the built-in structures is readonly). If you meant instead that you wanted to provide readonly attributes or writeprotected members for your module's exposed script structure then that would make sense...
Actually I meant that some properties cannot be set directly (like Character.NormalView). I could call Character.ChangeView instead to set the value. Now I just ignore such properties.

Quote
Edit: I was just looking over the code, and bloody hell cat, I have to commend you. Aside from Khris' code snippets he posts all the time, your code is one of the very few examples I can think of where I have seen another programmer's code actually maintaining consistent formatting (aside from cases of course where the IDE goes total dictator mode, like MSVC#).

We have very strict coding guidelines at work, here I've been quite lazy (not a single line of comment :P)

Quote
One thing you might consider doing is adding a macro to your module. Something like:
...

Good idea. I also thought about checking game.debug_mode.

Quote
Other than that I'd say it looks like you're off to a good start with this. :)

Thanks! I hope this module is going to be useful to someone.
Title: Re: MODULE: DebugHelper - Set/get object/char/hotspot values at runtime
Post by: monkey0506 on Sun 22/07/2012 10:01:00
Quote from: cat on Sun 22/07/2012 08:26:38
Quote from: monkey_05_06 on Sun 22/07/2012 07:46:34Haven't checked it out yet, but I'm a bit confused by what you mean here... Just FYI, any readonly members of a struct cannot be modified in AGS. You'd have to make changes to the engine and/or the built-in script headers to change readonly properties (and every non-writable property of the built-in structures is readonly). If you meant instead that you wanted to provide readonly attributes or writeprotected members for your module's exposed script structure then that would make sense...

Actually I meant that some properties cannot be set directly (like Character.NormalView). I could call Character.ChangeView instead to set the value. Now I just ignore such properties.

Ahhh, yes, that makes perfect sense then. I'd say for completeness sake, you could consider it, but I wouldn't bother unless (until) someone actually says they want or need it. ;)

Quote from: cat on Sun 22/07/2012 08:26:38I hope this module is going to be useful to someone.

Yes, that's always the dream! :) I often wonder whether anyone actually makes any use of the time I've devoted to writing the modules (and other things) that I've authored. It's nice to hear someone mention that they're using it, but if I was doing it for the (individual) recognition then I'd honestly have to say that I've been doing it for the wrong reasons. :P I myself just enjoy coding, and the rest is just gravy/icing/[name your topping here].
Title: Re: MODULE: DebugHelper - Set/get object/char/hotspot values at runtime
Post by: tzachs on Mon 23/07/2012 21:38:26
Great module, very useful!  :)

Comments:
- This is similar in concept and execution to the God Mode module, with different functionalities that complement each other.
Perhaps joining forces to bring the ultimate debug tool?
- Your module only supports 320x200. My game is at 640x480 and everything looked very odd, I had to change sizes and alter the code that hides/shows the UI. The best thing to do is have the UI dynamically change sizes and its inner control based on the game resolution. An alternative would be having multiple GUIs for import (that's how it works in the god module).
- Instead of checking game.debug_mode you can go with #ifdef DEBUG (not a big deal, but slightly better since less code actually gets compiled when it's not in debug, I think).
- Maybe add GUIs to the list of items?
- I'm thinking there should be a master list with Characters, Objects, Hotspots, GUIs, etc, and each will lead to the appropriate list of items. Maybe not needed for smaller games, but my game has a lot of items and it's hard to navigate.
- Maybe also adding a search box could help with the navigation.
- I used with your module along with the god mode module. It gave me the ability to drag your GUIs around and put them where I wanted too, so I could see both of them in the same time. It then became very annoying that every time I selected a character the list gets hidden and I have to click on it again to show it.
- Maybe adding a bit of transparency to the GUI so that you could see what lies beneath it.
Title: Re: MODULE: DebugHelper - Set/get object/char/hotspot values at runtime
Post by: Dualnames on Tue 24/07/2012 04:53:18
I hope I'm not intrusive, but I bothered working on this a bit. So, this is an unofficial version, if cat is not okay with this, i have no problem removing it.

http://duals.agser.me/Files/DebugHelperv02.rar

ADDED:
- Gui Controls
- Guis
- Inventory Items
- Now, you can tick away and back in, all the types from the drop down list
- Added transparency to the UIs
Title: Re: MODULE: DebugHelper - Set/get object/char/hotspot values at runtime
Post by: cat on Tue 24/07/2012 08:43:28
Thanks for you comments, tzachs and Dualnames!
tzachs: I'm not familiar with the God Module, can you link it for me? Dualnames already mentioned in the chat that different sizes depending on the resolution would be needed. Now that there are two people who want that I guess I should do it  ;)
I'll think about the navigational things - do you really have that many characters and objects per room?
Dualnames: Great that you worked on that! I'll take a look at it in the evening.
Title: Re: MODULE: DebugHelper - Set/get object/char/hotspot values at runtime
Post by: tzachs on Tue 24/07/2012 19:23:14
Quote from: cat on Tue 24/07/2012 08:43:28
I'm not familiar with the God Module, can you link it for me?
God Mode (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=42204.0)

Quote from: cat on Tue 24/07/2012 08:43:28
I'll think about the navigational things - do you really have that many characters and objects per room?
Oh, yes!
AGS Footballer has two teams, each with 11 footballers. Currently each footballer has 2 characters, one for himself and one for his shadow.
This already counts for 44 characters.
Now add to that the fact that I'm currently working on splitting each footballer to about ~5 characters so that I could compose more kinds of footballers, I will go berserk without a search box...

Title: Re: MODULE: DebugHelper - Set/get object/char/hotspot values at runtime
Post by: cat on Sat 28/07/2012 20:34:22
Sorry for not replying earlier. The new additions are great Dualnames, there is mayby just some cleanup on the Gui needed. Let's declare your version the new official one?
Title: Re: MODULE: DebugHelper - Set/get object/char/hotspot values at runtime
Post by: Dualnames on Sun 29/07/2012 12:54:25
Alright, edited the first post to reflect that.