2019-02-17 17:12:50

Hi! I am creating a game but i have a problem: I followed all the steps to create a new function, for example, keyboard practice, so it waits my keypresses. But when i run the game and choose the option from the mainmenu to run this function, it exits the game. Here is the code:


#include

Best regards: Marco

2019-02-17 17:18:01

hi
I just saw #include, not anything else of your coad: where's another parts?

2019-02-17 17:47:56 (edited by marko 2019-02-17 17:48:22)

Oh sorry, here is the rest of the code:


#include "dynamic_menu.bgt";
void main()
{

tts_voice voice;

voice.speak_wait("Welcome");

dynamic_menu mainmenu;

mainmenu.allow_escape=true;

mainmenu.wrap=true;

mainmenu.add_item_tts("Start");

mainmenu.add_item_tts("Exit");show_game_window("Test");


int choice;

do
{

choice=mainmenu.run("mainmenu",true);

if(choice==1)
{

game();

}
else if(choice==2)
{
exit();
}
}

void game()
{

voice.speak_wait("Welcome");

while(key_pressed(KEY_ESCAPE));
{
if(key_pressed(KEY_RETURN))
{

tts_voice voice;

voice.speak_wait("Test");
}
}
}

Best regards: Marco

2019-02-17 17:54:42 (edited by Simter 2019-02-17 18:07:18)

this can not work. Because of the fackt that the script thinks it's funktion is done so it closes. Here is a right version, also you can not do that what you did with the escape.

#include "dynamic_menu.bgt";
void main()
{
show_game_window("game");
tts_voice voice;
voice.speak_wait("Welcome");
dynamic_menu mainmenu;
mainmenu.allow_escape=true;
mainmenu.wrap=true;
mainmenu.add_item_tts("Start");
mainmenu.add_item_tts("Exit");show_game_window("Test");

int choice;
do
{
choice=mainmenu.run("mainmenu",true);
if(choice==1)
{
game();
}
else if(choice==2)
{
exit();
}
}
void game()
{
voice.speak_wait("Welcome");
while(true)
{

if(key_down(KEY_ESCAPE));
{
if(key_pressed(KEY_RETURN))
{
tts_voice voice;
voice.speak_wait("Test");
}
}
}
}
}

Lamas with hats, but with sponge bob as carl Stay tuned.

https://www.youtube.com/channel/UCvAUQt … subscriber

2019-02-17 17:56:38

also you have to open a window first before you can do anything.

Lamas with hats, but with sponge bob as carl Stay tuned.

https://www.youtube.com/channel/UCvAUQt … subscriber

2019-02-17 18:00:37

I still get this error:
File: C:\Users\marco\Desktop\restaurant.bgt
On line: 39 (1)
Error: Unexpected end of file

File: C:\Users\marco\Desktop\restaurant.bgt
On line: 4 (1)
Information: While parsing statement block

What should i do?

Best regards: Marco

2019-02-17 18:07:31

i edited my previus post with the code, does it work now?

Lamas with hats, but with sponge bob as carl Stay tuned.

https://www.youtube.com/channel/UCvAUQt … subscriber

2019-02-17 18:14:03

It says the following:
File: C:\Users\marco\Desktop\restaurant.bgt
On line: 2 (1)
Information: Compiling void main()

File: C:\Users\marco\Desktop\restaurant.bgt
On line: 25 (1)
Line: void game()
Error: Expected 'while'

File: C:\Users\marco\Desktop\restaurant.bgt
On line: 25 (1)
Line: void game()
Error: Instead found 'void'

I don't understand what is going on...

Best regards: Marco