|
Goombert
|
|
Reply #1 Posted on: September 07, 2013, 09:20:08 pm |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
....
Ok, so that explains why it isn't working on Linux after I thought I fixed it. Remove string() from around it. Also get_string requires you set Build->Settings and set the widget system under "API"
If removing string() don't fix your problem I will make an attempt at fixing it from Windows. Also Linux is not called "Linux" under SHELL/platforms it is called "Xlib"
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
TheExDeus
|
|
Reply #2 Posted on: September 08, 2013, 07:16:08 am |
|
|
Joined: Apr 2008
Posts: 1860
|
I don't think keyboard_string is even implemented. Some while ago I added keyboard_lastchar so that works (and can be used to create a textbox you want), but I don't think we have keyboard_string. At least on Windows it doesn't work.
Even if it did work, why would that code stop inputing text when enter is pressed? You call an alarm event, you don't stop keyboard_string from populating. If you want that, then do something like this:
if (input_done == false){ draw_text(10,20,"Enter your name here: "+string(keyboard_string)); } else { draw_text(10,20,"Enter your name here: "+string(name)); } if (keyboard_check_pressed(vk_enter)) { name = keyboard_string; input_done = true; alarm[0]; } edit: Unless you meant that "Enter" should automatically clear the keyboard_string. That shouldn't be true in GM either. It just shows the last 1024 chars pressed. Enter will probably add a newline character, but it will not delete the previous ones. If you want keyboard_string to clear, then set it to an empty string.
|
|
« Last Edit: September 08, 2013, 07:19:02 am by TheExDeus »
|
Logged
|
|
|
|
intygamer
|
|
Reply #3 Posted on: September 08, 2013, 08:55:02 am |
|
|
Joined: Mar 2013
Posts: 77
|
....
Ok, so that explains why it isn't working on Linux after I thought I fixed it. Remove string() from around it. Also get_string requires you set Build->Settings and set the widget system under "API"
If removing string() don't fix your problem I will make an attempt at fixing it from Windows. Also Linux is not called "Linux" under SHELL/platforms it is called "Xlib"
I removed string() it still did work. draw_text(10,20,"Enter your name here: "+keyboard_string); if (keyboard_check_pressed(vk_enter)) { alarm[0]; } Also tried TheEXDeus code as is and without string(). I don't think keyboard_string is even implemented. Some while ago I added keyboard_lastchar so that works (and can be used to create a textbox you want), but I don't think we have keyboard_string. At least on Windows it doesn't work.
Even if it did work, why would that code stop inputing text when enter is pressed? You call an alarm event, you don't stop keyboard_string from populating. If you want that, then do something like this:
if (input_done == false){ draw_text(10,20,"Enter your name here: "+string(keyboard_string)); } else { draw_text(10,20,"Enter your name here: "+string(name)); } if (keyboard_check_pressed(vk_enter)) { name = keyboard_string; input_done = true; alarm[0]; } edit: Unless you meant that "Enter" should automatically clear the keyboard_string. That shouldn't be true in GM either. It just shows the last 1024 chars pressed. Enter will probably add a newline character, but it will not delete the previous ones. If you want keyboard_string to clear, then set it to an empty string.
I tried your code as is and without string() after pressing enter it does not go to alarm event. After the 1st enter press you can not see any more typing till you hit enter. Thanks Joe
|
|
|
Logged
|
|
|
|
TheExDeus
|
|
Reply #4 Posted on: September 08, 2013, 09:56:39 am |
|
|
Joined: Apr 2008
Posts: 1860
|
I tried your code as is and without string() after pressing enter it does not go to alarm event. After the 1st enter press you can not see any more typing till you hit enter. That is actually because alarm[0] doesn't do anything. To use alarms you must set the value after which the alarm event will run. I didn't notice that before in your code, but you must do this: alarm[0]=1; to run the alarm after 1 step. The reason why it didn't show anything typing is because I update the string only when enter is pressed. Anyway, I am still confused why keyboard_string works for you as it doesn't on windows.
|
|
|
Logged
|
|
|
|
intygamer
|
|
Reply #5 Posted on: September 08, 2013, 10:33:49 am |
|
|
Joined: Mar 2013
Posts: 77
|
I tried your code as is and without string() after pressing enter it does not go to alarm event. After the 1st enter press you can not see any more typing till you hit enter. That is actually because alarm[0] doesn't do anything. To use alarms you must set the value after which the alarm event will run. I didn't notice that before in your code, but you must do this:
alarm[0]=1; to run the alarm after 1 step. The reason why it didn't show anything typing is because I update the string only when enter is pressed. Anyway, I am still confused why keyboard_string works for you as it doesn't on windows.
I made the change and it will not go to the alarm event. if (input_done = 0){ draw_text(10,20,"Enter your name here: "+string(keyboard_string)); } else { draw_text(10,20,"Enter your name here: "+string(name)); } if (keyboard_check_pressed(vk_enter)) { name = keyboard_string; input_done = 1; alarm[0] = 1; } Alarm 0 code if (name = ' ') { room_restart; } else { room_goto_next; } Thanks! Joe
|
|
|
Logged
|
|
|
|
|
Goombert
|
|
Reply #7 Posted on: September 08, 2013, 11:59:04 am |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
@Harri, I added for Linux, I'll commit it for Windows too. https://github.com/enigma-dev/enigma-dev/search?q=keyboard_string&ref=cmdformenigma_user::keyboard_string += enigma_user::keyboard_lastchar;
if (enigma::last_keybdstatus[actualKey]==1 && enigma::keybdstatus[actualKey]==0) {
@intygamer, your on Windows right? or are you on Linux? Because it should work on Linux I have to go add it right now for Windows.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
Goombert
|
|
Reply #8 Posted on: September 08, 2013, 12:25:50 pm |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
@intygamer/Harri here I implemented it for Windows, somebody please merge my pull request on GitHub... https://github.com/enigma-dev/enigma-dev/pull/384
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
intygamer
|
|
Reply #9 Posted on: September 08, 2013, 12:27:15 pm |
|
|
Joined: Mar 2013
Posts: 77
|
room_restart and room_goto_next are functions, not variables. You need to have them like room_restart() and room_goto_next(). Is this your first time with GM/ENIGMA or programming? I think for GM there are some very good intro courses, but I just learned from examples. Remember recreating that 1945 plane game from scratch in GM when I was 12 or something. Couldn't remember whether x was horizontal or vertical position.
edit: Also, just for information - When using functions without parenthesis (so just the function name and not really calling a function) returns the function "id". In GM I think this breaks it, but in ENIGMA you can pass functions to scripts and such (at least theoretically). In C++ this would be a pointer. It doesn't work right now in ENIGMA either as we can't use pointers. I know that in GM (and ENIGMA) you can use scripts like this though. Like have a script scr_explode() and scr_explode_large(), then in create event write explosion_script = scr_explode; and then script_execute(explosion_script). This is possible because in these cases only resource id's are used and not pointers.
Duh I forgot the () for the functions. It works Thanks for your help TheExDeus. I was using drag and drop now tring just to write code instead, better for copy and paste. I do have the 1945 plane example. @Harri, I added for Linux, I'll commit it for Windows too.
https://github.com/enigma-dev/enigma-dev/search?q=keyboard_string&ref=cmdform
enigma_user::keyboard_string += enigma_user::keyboard_lastchar;
if (enigma::last_keybdstatus[actualKey]==1 && enigma::keybdstatus[actualKey]==0) {
@intygamer, your on Windows right? or are you on Linux? Because it should work on Linux I have to go add it right now for Windows.
I have Ubuntu Linux. TheExDeus helped me fix my code and now it works. Thanks for help Robert. Thanks! Joe
|
|
|
Logged
|
|
|
|
|
|