HUD Console

captaincomic

  • *
  • Posts: 6108
HUD Console Extension
If you miss the good ol' Flixel console, or just want a quick way to view your game logs, this extension is for you.



This extension also includes blocks to set up data fields, measure execution time, and the console can be extended with custom commands.

Download this Extension (v1.3). Requires Stencyl 3.3+.
For instructions see How to Install and Update an Extension.

Credits
The Console class was written by Fernando Medina. See his blog post for the original version. For this extension, I just updated the class to haxe 3 and added the blocks.


Usage Notes
Please note that when you use this console, all output will be redirected to it and won't show up in the regular log viewer anymore.

create console
Use the "create console" block in "when created" in the first scene of your game. Then, when testing the game, you can hit Ctrl+1 to toggle the console.  Alternatively, you can use the "show console" and "hide console" blocks. To write the the console use the "print" block as usual.

set data field ( name: ___ value: ___ )
You can use this block to create and update a data field to monitor a value in your game. The data fields are printed on top of the console. (Note that the field is not automatically updated if the value of an attribute changes. It is only updated when you use this block.)
 
measure time ( name: ___ )
You can measure the execution time of your code with this block. Use the block once before the code you want to measure and once after, with the same name. The results are displayed in milliseconds in a data field with the given name on the top of the console.

add command ___ — arguments
If you feel like experimenting, you can extend the functionality of the console by adding your own commands. In version 1.1+ of this extension, this is an wrapper block. Just specify the name of the command, and when you enter it on the console it will execute the blocks in the wrapper. If you enter the command followed by some text, this text will be accessible through the "arguments" block.

show console
hide console
Show/hide the console.

Version History
1.0: Initial version
1.1: Make "add command" block a wrapper block. Version 1.1 requires Stencyl 3.2.
1.2: Update nme -> openfl
1.3: Add show and hide blocks. Version 1.3 requires Stencyl 3.3.

« Last Edit: May 14, 2017, 11:37:53 am by captaincomic »

Justin

  • *
  • Posts: 4716
This is really nice. Good work.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

xTage

  • Posts: 47
wow! awsome! thanks


Justin

  • *
  • Posts: 4716
Yeah, I started using this yesterday, the custom commands thing especially is awesome. I know you just updated and packaged somebody else's code as an extension, but super cool anyway. Thanks. :)
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

captaincomic

  • *
  • Posts: 6108
Glad you find some use for it :)

I updated it to make the "add command" block easier to use - it's a wrapper block now with an attached "arguments" block (and needs the latest build to work).


Jon

  • *
  • Posts: 17524
This contains some references to nme that will need to be updated to openfl for this extension to function in 3.3 and above. Please update. Thanks!

captaincomic

  • *
  • Posts: 6108

hodragon

  • Posts: 81
Hello.

Nice Extension.
There are questions.
What are the methods to be used in a mobile?
Indie Game Developer.
(I do not speak English well.)

captaincomic

  • *
  • Posts: 6108
I haven't tried it on mobile.

To get it to show, you could set up a different key to toggle the console. With the following code in a code block (instead of using the "create" block) you can choose the key code to toggle the console:

e.g. to use Enter use key code 13 and the third parameter "false" means that you don't need to press the Control key at the same time.
Code: [Select]
com.nmefermmmtools.debug.Console.create(true, 13, false, true);

Reference: create(catchTrace:Bool = true, toggleKeyCode:Int = 49, withControlKeyPressed:Bool = true, showWelcomeMessege:Bool = true)

Alternatively you can try
Code: [Select]
com.nmefermmmtools.debug.Console.show();
and
Code: [Select]
com.nmefermmmtools.debug.Console.hide();
after creating the console.

If any of this works, I can add blocks for that.

« Last Edit: March 08, 2015, 10:57:43 am by captaincomic »

hodragon

  • Posts: 81
Does not work all.
 :'(

thanks.
Indie Game Developer.
(I do not speak English well.)

captaincomic

  • *
  • Posts: 6108
Ah, I forgot about the package name. You need to use "com.nmefermmmtools.debug.Console" instead of just "Console". (I also edited the above post.)

captaincomic

  • *
  • Posts: 6108
I added show and hide blocks, those could be useful anyway.

hodragon

  • Posts: 81
Good job!
Thank you.
Indie Game Developer.
(I do not speak English well.)

Nick69

  • Posts: 4
Hello,
I want first to congrats the developer for that superb idea! Now I have few questions.

Is there any way to resize the hud and position it in any direction of the scene I want. I want it to be static, don't allow the user to move it with mouse be always shown. I checked the .hx file but I coudn't find how to enable that option. I program in C and C++ so if someone has any idea to change the code file don't miss to inform me. :)

Another idea I came up and wanted to ask you guys is if  it's possible to add arguments in the console.
So when I type eg  "command --help" to show me a multicoment box about the options I have. Just like linux terminal commands.
Another example "comand -p <somevalue> -o <anothervalue>" where some value then I want to test it for correctness with my default value.
Eg if I type "command  -p 1234" and "1234" isn't "665" I'll get an error message in the console.
Excuse my low sklills but I want to know if it's possible, even if I need to write the .hx file.

Thanks for your time,
Nick