Jump to content


Photo

Advanced Console


  • Please log in to reply
70 replies to this topic

#1 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 20 August 2009 - 12:07 AM

This would be my first DLL using GMAPI (yes, Tuntis, I used VC++). It is basically just like my previous console DLL, rewritten, smaller, and with a massive new feature: events. You can take keyboard and mouse events. So this means you can make text games without needing input sent to the game window. I don't have much to say, just try it. :)


Posted Image

This DLL will most likely not work anymore. It will not be updated.

Download: UpUrLoad

For the example, I have a simple TUI interface. Three clickable buttons that execute the specified code. Press Alt + Enter in the console for "fullscreen".



Manual

System Variables:
  • global.con_x
    The mouse position in the window, from 0 to 79. Updated when con_process is called and a mouse event is in queue. Hint: The cursor position is not based on pixels, but character cells.
  • global.con_y
    The mouse position in the window, from 0 to 24. Updated when con_process is called and a mouse event is in queue. Hint: The cursor position is not based on pixels, but character cells.
Functions:
  • con_start(animation);
    Initialize the DLL for use, must be called before any other functions. If animation is true, automatic scrolling and wrapping will be disabled.
  • con_end();
    Free the DLL, please call this when done, it's best for you and the users.
  • con_stitle(title);
    Sets the console's caption to title.
  • con_write(str);
    Writes str to the console window. Scrolls and wraps automatically.
  • con_read();
    Reads a string from the console, returns what was entered. Warning: This will freeze the game until it returns.
  • con_clear();
    Clear the console window.
  • con_spos(x, y);
    Set the cursor position to x,y. Written text is entered at this position. Not to be confused with the mouse position.
  • con_gcurx();
    Get the current x value of the cursor.
  • con_gcury();
    Get the current y value of the cursor.
  • con_scol(col);
    Sets the foreground and background color for text to col. These colors are not based on RGB, they are 4-bit colors. Some values are defined in the constants of Merge.gmk.
  • con_sevents(key, mouse);
    Set the callback scripts for keyboard and mouse events, use -1 for none. For events to be used, events must be processed. These scripts are only executed if you process events.
  • con_process();
    Process events. Calls the set scripts if needed. Warning: Using this will freeze the game, it does redraw if the console window has focus.
Events:

Edited by TheMagicNumber, 04 September 2011 - 11:08 PM.

  • 3

#2 LoopStan

LoopStan

    North-See Developer

  • GMC Member
  • 1398 posts

Posted 20 August 2009 - 12:13 AM

This is awesome! This is great for anyone wanting to use consoles in their games, i mean common TUI!

Great work I can't wait to see more!
  • 0

Posted Image


#3 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 20 August 2009 - 01:57 AM

There is no TUI in this. And thanks.

Edited by TheMagicNumber, 20 August 2009 - 01:57 AM.

  • 3

#4 freaked

freaked

    freak up!

  • New Member
  • 890 posts

Posted 20 August 2009 - 09:06 AM

For some weird reason, this worked for me.
So far, anything using GMAPI, or the GMakerLib never worked for me.
Would be kind enough to share the source of the DLL ? (Through PM if you wish).
I want to see how you initialize GMAPI and see where I went wrong.
Thanks.
  • 0

#5 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 20 August 2009 - 11:44 AM

Instead of initializing in the entry point, I decided to initialize it in the con_start function.

And how is the DLL? :)
  • 3

#6 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 04 September 2009 - 01:12 PM

I would really appreciate some feedback on this, it isn't that bad.
  • 3

#7 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 04 September 2009 - 05:49 PM

I would really appreciate some feedback on this, it isn't that bad.

Unfortunately, it isn't that practical, either... especially for GM games.
  • 0

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.


#8 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 26 September 2009 - 02:43 PM

Come on everyone, if it's not that great, please suggest what you need.

I also need a suggestion for a better example.
  • 3

#9 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 04 October 2009 - 04:15 PM

Wow, what a neat DLL. Definitely downloading. Looks awesome. Blah blah blah...

There you have it, as always.

Erm, thanks.

Edited by TheMagicNumber, 04 October 2009 - 04:16 PM.

  • 3

#10 Revel

Revel

    ɹǝqɯǝɯ ɔɯƃ

  • GMC Member
  • 4935 posts
  • Version:GM8

Posted 06 October 2009 - 01:46 AM

Wow, what a neat DLL. Definitely downloading. Looks awesome. Blah blah blah...

There you have it, as always.


  • 0

#11 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 07 October 2009 - 09:53 PM

Wow, what a neat DLL. Definitely downloading. Looks awesome. Blah blah blah...

There you have it, as always.

Erm, thanks.


  • 3

#12 kake_fisk

kake_fisk

    GMC Member

  • GMC Member
  • 2392 posts
  • Version:GM7

Posted 09 October 2009 - 08:54 PM

Lol. ^_^
  • 0

#13 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 11 October 2009 - 02:36 AM

I removed the two parameters for the mouse position in the mouse event, they can now be used by using the value from global.con_x/y. They are updated before a mouse event is called.
  • 3

#14 Aragon1029

Aragon1029

    GMC Member

  • New Member
  • 940 posts

Posted 11 October 2009 - 06:37 AM

Awesome,
I didn't expect the mouse support in this, it's a really interesting command prompt DLL.

Great work. :)
  • 0


Rave Breakout! A new game for iOS devices!
Ever wondered how many lines of code your game has?
Guys, I have a great idea, let's protect the public through censorship.


#15 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 11 October 2009 - 06:46 AM

Thanks, nobody seems to want to come here. I should probably improve the example and put up a screenshot.
  • 3

#16 Aragon1029

Aragon1029

    GMC Member

  • New Member
  • 940 posts

Posted 25 October 2009 - 09:34 PM

I r use 4 mockups.
I have the intellect of a 4 year old. :)
  • 0


Rave Breakout! A new game for iOS devices!
Ever wondered how many lines of code your game has?
Guys, I have a great idea, let's protect the public through censorship.


#17 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 26 October 2009 - 07:24 PM

I r use 4 mockups.
I have the intellect of a 4 year old. :)

Mmk?

So yeah, if anybody has any requests for this DLL (or maybe for a new DLL), please tell me (PM for new one, don't be off-topic).
  • 2

#18 Recreate

Recreate

    Furry

  • GMC Member
  • 2992 posts
  • Version:GM:Studio

Posted 09 November 2009 - 12:13 AM

Meh, Its OK, Not any use to anyone really, Just another DLL.
  • 0

If the post that you are reading was created prior to 2011. For the safety of the general public, It is not to be regarded under any circumstances.
Please don't ask me to join your group at anything.


#19 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 09 November 2009 - 12:26 AM

Yeah, I'm sure it can't be used, right? You can make a game with it.
  • 1

#20 Recreate

Recreate

    Furry

  • GMC Member
  • 2992 posts
  • Version:GM:Studio

Posted 23 November 2009 - 12:48 AM

Ok got a few suggestions, window_set_visible(false); appears to hide the console window too... You may want to fix that...
  • 0

If the post that you are reading was created prior to 2011. For the safety of the general public, It is not to be regarded under any circumstances.
Please don't ask me to join your group at anything.


#21 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 23 November 2009 - 01:27 PM

I just tried it, it didn't hide the console window.
  • 1

#22 Recreate

Recreate

    Furry

  • GMC Member
  • 2992 posts
  • Version:GM:Studio

Posted 23 November 2009 - 05:38 PM

Oh...Hmmm nevermind...
On the other hand, How can one print a newline with the console? without using something along the lines of
newline = "
"

  • 0

If the post that you are reading was created prior to 2011. For the safety of the general public, It is not to be regarded under any circumstances.
Please don't ask me to join your group at anything.


#23 spicydeath82

spicydeath82

    Awesomesauce

  • New Member
  • 138 posts
  • Version:GM8

Posted 24 November 2009 - 12:48 AM

looks interesting, i tried it out but the window i saw looked nothing like the one in the screen shot. also the keyboard did nothing in the included example, and how come when i exit the console it exits the game?
  • 0
Life is incapable of of springing from nothing. Science has proven that. So if life here didn't spring up outta the primordial muck then who's responsible? Life has to come from life.

Posted Image

#24 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 24 November 2009 - 02:00 AM

Oh...Hmmm nevermind...
On the other hand, How can one print a newline with the console? without using something along the lines of

newline = "
"

newline = chr(10);
If you even think about escape codes, remember those are translated by the compiler to their ASCII at build time, so no I can't really do that.

looks interesting, i tried it out but the window i saw looked nothing like the one in the screen shot. also the keyboard did nothing in the included example, and how come when i exit the console it exits the game?

Yeah, I used my own example for that screenshot, the one included uses the keyboard, hit escape. :) I don't know why it exits, but it doesn't only happen with this DLL, it happens with other applications.

I'll upload my newer example.

By the way, how is the "help" in the first post?

Edited by TheMagicNumber, 25 November 2009 - 12:25 AM.

  • 1

#25 Recreate

Recreate

    Furry

  • GMC Member
  • 2992 posts
  • Version:GM:Studio

Posted 27 November 2009 - 02:26 AM

I have one last suggestion, Color, This DLL sucks compared to that other one that can use coloured text.
  • 0

If the post that you are reading was created prior to 2011. For the safety of the general public, It is not to be regarded under any circumstances.
Please don't ask me to join your group at anything.


#26 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 27 November 2009 - 09:57 PM

Updated to the latest version of GMAPI, which fixed a bug in calling script_execute (from a DLL).

Edited by TheMagicNumber, 27 November 2009 - 09:57 PM.

  • 1

#27 emanuel87

emanuel87

    GMC Member

  • New Member
  • 176 posts

Posted 03 January 2010 - 07:10 PM

ive got this ccode in enter-pressed event:

con_write(keyboard_string);
keyboard_string="";


it should add the keyboard string everytime i hit enter.

but it doesn't.

why?
  • 0

#28 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 04 January 2010 - 12:28 AM

If focus is on the console window, no input will be sent to Game Maker.

I highly suggest you do not use this in GM8 yet.
  • 1

#29 emanuel87

emanuel87

    GMC Member

  • New Member
  • 176 posts

Posted 04 January 2010 - 12:40 AM

i'm interested on this. this is great i tell you. :)

okay. how do i overcome making it focus onto the main window?
  • 0

#30 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 04 January 2010 - 01:04 PM

You can get single key input (just like on your keyboard, including keys like Escape and the arrow keys) from the console window. You can use this to create your own "keyboard_string" variable. This will not work in GM8 yet.
  • 1

#31 CardiacVoid

CardiacVoid

    GMC Member

  • New Member
  • 31 posts

Posted 08 January 2010 - 10:02 PM

Well...yeah its a cool DLL and that mouse functions/events etc are good....but to what extent is anyone really going to want/use/need this? I mean its cool, but its not going to make your games any better than they were with using plain old game maker, however, its a good dll
  • 0

#32 emanuel87

emanuel87

    GMC Member

  • New Member
  • 176 posts

Posted 08 January 2010 - 10:23 PM

please, could you make an example of having keyboard strings being entered into the console? and it has to be readable from the main window.

that'd cover the main point of having a console.

thanks.
  • 0

#33 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 09 January 2010 - 05:51 PM

con_read() will get a line of input from the user, it will return the string of text.

GMAPI will support GM8 in a few months maybe.
  • 1

#34 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 01 February 2010 - 10:00 PM

GMAPI was updated early, and I've updated the DLL with GM8 support.
  • 1

#35 iWizard

iWizard

    GMC Member

  • New Member
  • 47 posts

Posted 02 February 2010 - 01:14 AM

I can see some potential for this. But, one large issue is the support for the <enter> key and the <backspace> keys. If I want to hit enter, the application finishes the con_read command, but also adds a "[]" like character to the end of the line. Is there any way to remove this? And also, when hitting backspace, another one of those "[]" appears. Not only that, if the string is too long, the last character on the line is replaced with a new character. Could you make it wrap the text like your previous DLL (Text-mode Window Dll) could?
  • 0
~ iWizardPro
Simplicity. Creativity. Knowledge.

#36 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 02 February 2010 - 10:52 PM

In my demo, it uses a specific mode which disables formatting, thus displaying control characters. If you want it to be like the previous DLL, call con_start(false);, this will use the default mode.
  • 1

#37 iWizard

iWizard

    GMC Member

  • New Member
  • 47 posts

Posted 03 February 2010 - 04:50 AM

Thank you. I also have another question. How about the scroll-bar? I want to be able to scroll like your previous DLL.
  • 0
~ iWizardPro
Simplicity. Creativity. Knowledge.

#38 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 03 February 2010 - 06:19 AM

I'll recompile it so if you call con_start(false) it will have the previous size. I will do that tomorrow (too late right now).
  • 1

#39 Recreate

Recreate

    Furry

  • GMC Member
  • 2992 posts
  • Version:GM:Studio

Posted 03 February 2010 - 06:29 AM

Finally this is updated for GM8. I may use this for a project of mine.
  • 0

If the post that you are reading was created prior to 2011. For the safety of the general public, It is not to be regarded under any circumstances.
Please don't ask me to join your group at anything.


#40 coolist

coolist

    The Coolist

  • New Member
  • 913 posts

Posted 03 February 2010 - 12:54 PM

Yay you got it ported to GM8! Nice work. It looks pretty good. B-)
  • 0

#41 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 03 February 2010 - 04:24 PM

Finally this is updated for GM8. I may use this for a project of mine.

You act like it could have been done sooner, I was waiting on GMAPI.

Yay you got it ported to GM8! Nice work. It looks pretty good. B-)

Now use it like you said you would.

Working on iWizard's request. Done.

Edited by TheMagicNumber, 03 February 2010 - 04:49 PM.

  • 1

#42 iWizard

iWizard

    GMC Member

  • New Member
  • 47 posts

Posted 04 February 2010 - 12:34 AM

Finally this is updated for GM8. I may use this for a project of mine.

You act like it could have been done sooner, I was waiting on GMAPI.

Yay you got it ported to GM8! Nice work. It looks pretty good. B-)

Now use it like you said you would.

Working on iWizard's request. Done.


Thank you!

And another question. If I use a thread to process the console window, will the game still freeze? I want to make a command console type object. The object would take in input and also would spit out data. But, I must know if this DLL has the capabilities, if the window does not freeze, for text to be loaded into the window while the con_read() function is still waiting for an entry.

So basically, I will have a line at the bottom that will have a ">" and allow me to input data. And at the same time, if something happens, the console would be able to write out what happened.

Edited by iWizard, 04 February 2010 - 12:42 AM.

  • 0
~ iWizardPro
Simplicity. Creativity. Knowledge.

#43 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 04 February 2010 - 03:13 AM

I don't exactly know why it freezes right now, the only function I expected to freeze the game was the input.
  • 1

#44 emanuel87

emanuel87

    GMC Member

  • New Member
  • 176 posts

Posted 05 February 2010 - 10:43 AM

if you compress the game executable with the compression tool that comes with anti-decompiler by score_under, it gives an unexpected error - what's this? and when the dll is disassociated, the error won't occur.

wtf.
  • 0

#45 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 05 February 2010 - 11:42 PM

if you compress the game executable with the compression tool that comes with anti-decompiler by score_under, it gives an unexpected error - what's this? and when the dll is disassociated, the error won't occur.

wtf.

It's a "bug" in (what appears to be) the GMApi implementation. It assumes that the PE header+0x800 is initialized to 0, while under UPX this is not the case. It also assumes that the EXE is loaded in the same place every time, though that doesn't affect most cases.

Here's a patched version of the DLL that works fine: http://dl.dropbox.co...733/console.dll

Edited by score_under, 06 February 2010 - 01:01 AM.

  • 0

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.


#46 Snake_PL

Snake_PL

    GMC Member

  • New Member
  • 57 posts

Posted 06 February 2010 - 07:50 AM

I knew about this "bug" (I wrote an app that compresses GM exes also using upx, where that appeared), but normally PE header is initialized with 0's and you can't compress the runner with some executable packers, so I didn't add support for such things. You can ask score_under to add some code to his protector that will fill the PE header with zeroes at start :)

It also assumes that the EXE is loaded in the same place every time, though that doesn't affect most cases.

Main executable image is loaded first into virtual space, so you will always get it loaded at the same base address. The only way to get the PE .exe rebased by system loader is to use LoadLibrary API to run the application (I think), and it's not a good idea to use it in that way.

Edited by Snake_PL, 06 February 2010 - 07:55 AM.

  • 0

http://sgames.ovh.org/ - my blog (Polish)

Game Maker projects:
- GMAPI - C++ library for DLL developers that directly accesses various game resources
- GMThreads - Library for Game Maker that allows you to execute GML code in a thread
- Game Protector [PL] - Protects games made in GM5/6.1/7.0 from decompiler
- GM Extractor [PL] - Dumps resources embedded in Game Maker project file to a selected directory
Other projects:
- MemExtractor [PL] - Extracts various resources from the process memory
- OllyDataInterpret [PL] - A plugin for OllyDbg 1.10 that shows different interpretations of selected data in a seperate window.


#47 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 06 February 2010 - 02:55 PM

It also assumes that the EXE is loaded in the same place every time, though that doesn't affect most cases.

Main executable image is loaded first into virtual space, so you will always get it loaded at the same base address.

Yup, though the EXE does have a relocation section - best to be safe IMO, and use GetModuleHandle(NULL) instead of 0x400000.

The modification I made to the DLL simply made it call VirtualProtect and then STOSD the relevant portions of the PE header to set them to 0. The only problem is that it might mess up some other GMAPI implementations.

Edited by score_under, 06 February 2010 - 02:58 PM.

  • 0

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.


#48 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 08 February 2010 - 12:14 AM

if you compress the game executable with the compression tool that comes with anti-decompiler by score_under, it gives an unexpected error - what's this? and when the dll is disassociated, the error won't occur.

wtf.

You can use score_under's patch (few posts up).
  • 1

#49 LoopStan

LoopStan

    North-See Developer

  • GMC Member
  • 1398 posts

Posted 29 June 2010 - 08:52 PM

How would one go about seeing if the mouse is held down, and as it is held down, do something. I have it when a user clicks, but I am confused otherwise.
  • 0

Posted Image


#50 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 29 June 2010 - 10:15 PM

After a click, wait for a release. This is all you have.
  • 2