Console Style Debugging

BlitzMax Forums/BlitzMax Programming/Console Style Debugging

ponyboy(Posted 2007) [#1]
Hello all, I just started with BlitzMax and I'm looking to port a game I wrote in VB6 over to BlitzMax. I'm starting out by trying to build a small framework and expand upon it as need be. My first task I've drawn up for myself is creating a workable console window that will popup in-game which I would essentially be able to use to test/debug the game.

I have it displaying and accepting input and everything which is great, but I'm at a hurdle now where I'm not sure how to implement the important features I'm looking for in such an interface. I'm not sure if they are possible, or the best way to go out about doing such things. Theres really only two important features I'm looking, the first being extremely important and the reason I'm building the console interface, and the second I actually could probably get by without, but would be nice to have.

1.) The game will be heavily scripted. What I want to be able to do in the console window is issue commands to the game which will manipulate the game objects. Things such as give players health, teleport players, give them items, issue scripts, etc. without having to restart the game, change the scripts or objects and then restart the game. I could issue script changes without breaking from the game.

I'm thinking what I would basically need to do is hook the debug console into whatever scripting language I decide to use and just send all console commands through the script interpreter. Is this the best option for what I want to do? Is there even another option, like directly manipulating the BlitzMax variables? After having worked on this game extensively in VB and not having a console interface like this, I realized how much it hurt my development time and bug fixing. Something like this would be a lifesaver.

2.) Would it be possible to output the values of BlitzMax variables to the in-game console through user input? I looked around and didn't find any function equivalent to an Eval function which might work, is there anything like this? I can get by without this feature, but it would be nice to be able to just see what a variable or object property is at any given time and have it pop up in the console window.

Thanks in advance for any help or ideas anyone can provide!


Scaremonger(Posted 2007) [#2]
Sounds like you need to look at LUA scripting.

If you create a textArea, and a button in the GUI of your choice, and parse the text you enter through the LUA scripting engine, you should be able to produce the functionality you need.


Gabriel(Posted 2007) [#3]
I concur with Scaremonger. I have a console which works very much the way you describe in my game, and it is indeed done with a textarea, an inputbox and Rozek's reworked Lua module. It's very easy to do once you've picked up the Lua module.


ponyboy(Posted 2007) [#4]
This is what I thought. Since I'm rather new to BlitzMax, where do I find Rozek's Lua Module and can you recommend any Lua tutorials for BlitzMax? I tried searching, but almost all the results pointed towards a wiki page that is currently down.


Scaremonger(Posted 2007) [#5]
Try these links to start you off:

AXE.LUA
LUA Tutorial request
LUA
Tutorial
Programming in LUA


Perturbatio(Posted 2007) [#6]
I wrote a simple bmax console thingy which never really took off, it might help you out, search for OpenConsole on this forum


ponyboy(Posted 2007) [#7]
Thanks for the links! I'll definitely have to read up on Lua.


altitudems(Posted 2007) [#8]
I have a console mod you can use which supports variable changing.

Unfortunately I'm away from my PC right now.


ponyboy(Posted 2007) [#9]
Thanks altitudems, but I actually saw Perturbatio's OpenConsole, and which is where I got the idea to do this in the first place. I think I'd like to create it from scratch myself though to help me learn BlitzMax. Thanks for the offer though, I appreciate it.

However, if you'd like to pass it along I'd definitely be interested in checking out the code and how you do things, if for nothing else to provide some insight.


altitudems(Posted 2007) [#10]
If you don't mind the time spent writing your, I would defiantly recommend doing that, you'll learn from doing it, plus end up with code that fits your needs specifically.


ponyboy(Posted 2008) [#11]
Just wanted to say I implemented LUA into the console and am now able to use any lua command in the console (haven't written any custom script functions yet) and also re-routed the LUA print command to my console. It works just the way I wanted. Thanks for all the help guys!