Game authors and players, please read this thread!

Author Topic: Check if game is runnig under the debugger  (Read 317 times)  Share 

Calin Leafshade

  • AGS Project Admins
  • Long live King Cat!
    • I can help with AGS tutoring
    •  
    • I can help with voice acting
    •  
  • Calin Leafshade worked on a game that was nominated for an AGS Award!Calin Leafshade worked on a game that won an AGS Award!
Check if game is runnig under the debugger
« on: 17 Aug 2012, 18:42 »
Is there a way to see if AGS is running under the debugger? I know that you can check if its in debug mode but thats not the same thing.

Leon: You need the sword first before you can get the monkey.

Crimson Wizard

  • AGS Project Admins
  • not et suppotreD
    • I can help with translating
    •  
Re: Check if game is runnig under the debugger
« Reply #1 on: 17 Aug 2012, 19:32 »
It is possible for plugin to do this by calling IAGSEngine::IsRunningUnderDebugger() method.

I do not see any way to know this from game script.

Calin Leafshade

  • AGS Project Admins
  • Long live King Cat!
    • I can help with AGS tutoring
    •  
    • I can help with voice acting
    •  
  • Calin Leafshade worked on a game that was nominated for an AGS Award!Calin Leafshade worked on a game that won an AGS Award!
Re: Check if game is runnig under the debugger
« Reply #2 on: 17 Aug 2012, 19:37 »
A funny quirk of the engine is that, when running under the debugger, the working directory of the game is the root source directory, not the compiled directory.

So i've found that you can try and open the acsetup.cfg file for reading and if it fails then you must be under the debugger.

Leon: You need the sword first before you can get the monkey.

Crimson Wizard

  • AGS Project Admins
  • not et suppotreD
    • I can help with translating
    •  
Re: Check if game is runnig under the debugger
« Reply #3 on: 17 Aug 2012, 20:35 »
I am curious why do you need this.

If you think that may come handy in certain situations we may plan a script function for checking this?
On other hand, there's already RickJ's request to allow getting command line arguments from script, and engine connects to debugger when it receives --enabledebugger parameter in cmdline.
« Last Edit: 17 Aug 2012, 20:37 by Crimson Wizard »

Khris

  • Evil Dark Emperor Death-Kill
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
Re: Check if game is runnig under the debugger
« Reply #4 on: 17 Aug 2012, 20:37 »
Could this work maybe?

Code: Adventure Game Studio
  1. bool debugger;
  2.  
  3. // in game_start
  4. #ifdef DEBUG
  5.   debugger = true;
  6. #endif
http://whathaveyoutried.com/

The other day on yahoo answers:
"Can you print colored images with black ink? If so tell me how please Thanx Kimberly"

Crimson Wizard

  • AGS Project Admins
  • not et suppotreD
    • I can help with translating
    •  
Re: Check if game is runnig under the debugger
« Reply #5 on: 17 Aug 2012, 20:43 »
Could this work maybe?

Code: Adventure Game Studio
  1. bool debugger;
  2.  
  3. // in game_start
  4. #ifdef DEBUG
  5.   debugger = true;
  6. #endif

Alas, this tests if Game's Debug mode is on, it doesn't test if the game is run under debugger (from AGS Editor).

Calin Leafshade

  • AGS Project Admins
  • Long live King Cat!
    • I can help with AGS tutoring
    •  
    • I can help with voice acting
    •  
  • Calin Leafshade worked on a game that was nominated for an AGS Award!Calin Leafshade worked on a game that won an AGS Award!
Re: Check if game is runnig under the debugger
« Reply #6 on: 17 Aug 2012, 21:26 »
I am curious why do you need this.

Tis a convoluted reason but i will indulge you

I am making a game in Lua and it does quite a lot of things that could be considered "Meta Engine". For instance it iterates through all my inventory items and builds a script for me where i can easily edit properties of the items without doing a lot of typing. Also I have map files that are generated as actual lua script and automatically deposited in the lscripts folder which is only accessible when running under the debugger. Alot of this stuff is done automatically but will fail if I give someone a compiled build to test. Now instead of manually disabling those things everytime i want to give someone a build I thought it would be nice if I could detect it on the fly.

Hence my question.

If youre super curious a map file looks like this:

Code: Lua
  1. -- Generated At 05:07:39
  2. Map2 =
  3. {
  4. Name = "Map2",
  5. Width = 32,
  6. Height = 32,
  7. Tileset = 1,
  8. Layers = 1,
  9. Walkable =
  10.   {
  11.   {1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  12.   {1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  13.   {1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0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0,0,0,0,0,0,0,0,0,0,0,0,},
  43. },
  44. Data =
  45.   {
  46.     {
  47.       {3,3,18,25,3,3,3,3,3,3,3,32,30,42,3,3,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  48.       {3,3,18,25,3,3,3,3,3,3,3,29,30,42,3,3,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  49.       {3,3,18,25,3,3,3,3,3,3,32,30,30,42,3,3,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  50.       {3,3,18,25,3,3,3,3,3,3,32,30,30,42,3,3,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  51.       {3,3,18,25,3,3,3,3,3,3,29,30,30,42,3,3,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  52.       {3,3,18,25,3,3,3,3,3,29,30,30,30,42,3,29,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  53.       {3,3,18,25,28,34,34,34,29,30,30,30,30,41,29,30,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  54.       {3,3,18,25,29,30,30,30,30,30,30,30,30,30,30,30,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  55.       {3,3,19,19,19,30,30,30,30,30,30,30,30,30,30,30,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  56.       {3,3,19,19,19,30,30,30,30,30,30,30,30,30,30,30,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  57.       {3,3,18,25,31,30,30,30,30,30,30,35,39,39,39,39,39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  58.       {3,3,18,25,3,31,30,30,30,30,30,36,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  59.       {3,3,18,25,3,3,31,30,30,30,30,36,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  60.       {3,3,18,25,3,3,32,30,30,30,30,36,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  61.       {3,6,12,20,3,3,32,30,30,30,30,36,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  62.       {6,12,20,3,3,3,32,30,30,30,30,36,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  63.       {12,20,3,3,3,3,32,30,30,30,30,36,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  64.       {20,3,3,3,3,3,32,30,30,30,30,36,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  65.       {3,3,3,3,3,3,32,30,30,30,30,36,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  66.       {3,3,3,3,3,3,3,31,30,30,30,36,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  67.       {3,3,3,3,3,3,3,3,31,30,30,36,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  68.       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  69.       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  70.       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  71.       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  72.       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  73.       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  74.       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  75.       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  76.       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  77.       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  78.       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
  79.     },
  80.   }
  81. }
  82. setmetatable(Map2, { __index = Map } )
  83. Map2.__index = Map
  84. Maps["Map2"] = Map2
  85.  

This is generated by my map editor which is part of the game. Then when i next run the game it now has a new global object "Map2" which can be edited and resaved if need be.
« Last Edit: 17 Aug 2012, 21:28 by Calin Leafshade »

Leon: You need the sword first before you can get the monkey.

Crimson Wizard

  • AGS Project Admins
  • not et suppotreD
    • I can help with translating
    •  
Re: Check if game is runnig under the debugger
« Reply #7 on: 17 Aug 2012, 21:52 »
Since you are using Lua plugin, I guess you may ask Denzil Quixode to add another function callable from either AGS script or lua script, that wraps IAGSEngine::IsRunningUnderDebugger()?