Pages: « 1 2
  Print  
Author Topic: game end EVENT issues  (Read 2034 times)
Offline (Male) Goombert
Reply #15 Posted on: May 23, 2014, 08:44:31 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3107

View Profile
You could thread your code with script_thread and just block game end with sleep()
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.

Offline (Unknown gender) Darkstar2
Reply #16 Posted on: May 23, 2014, 09:04:38 PM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
lol.

Could you please give me an example?

Let's say I am inside a game window and click the "X" to close the window, before the program exits, I would like a page to display a message and wait 10 seconds or wait for any key then game end.

BTW when using script thread, do I have to end the thread or close it, or is this done automatically upon the return from the script ?


« Last Edit: May 23, 2014, 09:26:36 PM by Darkstar2 » Logged
Offline (Male) Goombert
Reply #17 Posted on: May 23, 2014, 09:31:19 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3107

View Profile
Just put this code in game end and make your myadvertisementscript set global.readtofinish to true whenever it is finished.
Code: (EDL) [Select]
global.readytofinish = false;
var thread;
thread = script_thread(myadvertisementscript, 0, 0, any other parameters...);
while (!global.readytofinish) {
  sleep(1000);
}
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.

Offline (Unknown gender) Darkstar2
Reply #18 Posted on: May 23, 2014, 09:47:27 PM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
Thanks :D

BTW, why do I have to use thread=script_thread, can't I call script_thread directly ?

Logged
Offline (Male) Goombert
Reply #19 Posted on: May 24, 2014, 02:33:41 AM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3107

View Profile
Yes you can but you may want to keep the id for thread_get_return or something, idk, it was just pseudo-code.
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.

Offline (Unknown gender) Darkstar2
Reply #20 Posted on: May 24, 2014, 03:04:41 AM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
Oh I forgot about that ...
ok used alone if not using a return value
and index if using a return value.
much like a regular script

Logged
Offline (Unknown gender) TheExDeus
Reply #21 Posted on: May 24, 2014, 06:08:08 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Quote
However I have a question, it looks like the game end event executes everything linearly (not like a step)
EVERYTHING in ENIGMA executes linearly. Including step event. So of course you cannot drawn anything from game end event to the screen, just like you cannot do it from step or key press. Drawing happens in draw event. What you want is "Close button" check event and Esc key event. There you check if the user wants to close your game. Then you set a variable like "close_popup = true; alarm[0] = room_speed*3;" and in draw event do "if (close_popup == true) draw_text("Game will end in 3 seconds!");". In alarm[0] you just put game_end(). Or you can just do "room_goto(room_end);" and then have an alarm to end it there.

So what game end event does is call the event when the game ends (magical, isn't it?). And after that event there isn't any other event. So no drawing, no step, no alarm, nothing. It's the last event your game calls. So you shouldn't add text prompts in there. The point of game end event is to release resources, change back resolution, write save to file and so on.
Logged
Pages: « 1 2
  Print