Jump to content

How to end Leadwerks


Thirsty Panther
 Share

Recommended Posts

The App.lua script shows how you can do this:

 

if self.window:Closed() or self.window:KeyDown(Key.Escape) then return false end

 

So, if the App:Loop() method returns false, then the program will close. In your scenario, when you click a button just return false in the App:Loop() method if that button is pressed and the app will close.

 

The second question can be complicated. I just looked it up on StackOverflow since I wasn't too sure about some of the things:

http://stackoverflow.com/questions/9033931/memory-leak-c

 

So, the OS releases memory for closed processes that aren't released. IDK if it's properly deallocated in the engine, but you don't really need to worry about this. For your purposes, it doesn't matter.

  • Upvote 2
Link to comment
Share on other sites

Thanks for the quick reply Nick.

 

I looked at the way app.Lua closed and thought that would be the answer but my scripting skill is beyond it.

 

How do I pass false to the App.Lua?

 

I also thought I could just close the window when the button is pressed but I couldn't get window closed to work for me.

 

Cheers for the help.

Link to comment
Share on other sites

Ironically someone asked me the same question yesterday evening. Here is my suggestion on how you can do this:

 

1. In app.lua before the App.Start function, add the following variable:

 

App.quitGame = false

 

2. in the main loop change the following line

if self.window:Closed() or self.window:KeyDown(Key.Escape) then return false end

 

with this:

if self.window:Closed() or App.quitGame or self.window:KeyDown(Key.Escape) then return false end

 

I simply added a check on whether the quiGame variable is true. Because if it is, then the App.Loop should be stopped.

 

 

3. Now, in your object script do the following:

 

App.quitGame = true

  • Upvote 1
Link to comment
Share on other sites

Speaking of Irony, I'm trying to do this for your FlowGUI example map. Great product BTW?

 

Thanks I think I can follow that.

 

Thanks Aggror and Nick.

Im still stuck at loading my game from FlowGUI. . . . . lol, I can get a map to load but the main screen is still there. Although I cant get my head around writing scripts, I do try. Prolly why my head hurts all the time now. . . sad.png

Asus sabertooth 990FX, AMD FX 9590 , Windows 7 Home Premium 64 Bit, 4 HDD's Western Digital Caviar Black set in Raid 0, 16 GB Crucial Ballistix Elite, Asus Radeon R9 270 X 4GB, Corsair CM750M,

Link to comment
Share on other sites

I have attempted this and as you know, given that you have helped me in the past, I'm not very good at learning scripting. I havnt gotten it figured out just yet. Where it makes perfect sense to you guys, some of us aren't "geared" this way. It's not that we don't try. It's fine if you don't want to help any one actually make sense with your system, it don't hurt me any. :) where one leaves off, another would be willing to accept my money!

Asus sabertooth 990FX, AMD FX 9590 , Windows 7 Home Premium 64 Bit, 4 HDD's Western Digital Caviar Black set in Raid 0, 16 GB Crucial Ballistix Elite, Asus Radeon R9 270 X 4GB, Corsair CM750M,

Link to comment
Share on other sites

It's fine if you don't want to help any one actually make sense with your system, it don't hurt me any. smile.png where one leaves off, another would be willing to accept my money!

I have never said that I wouldn't help people with FlowGUI. When people have questions regarding the use of FlowGUI, they can send me a private message. Many have done so already and I am glad to help them out. Making entire gameplay scripts is an entire question.

 

But again if you have a question regarding FlowGUI, you send me a pm about it. I would be happy to happy to have a look at it. If you have a script that doesn't work or when when you have trouble with FlowGUI, this is something I will assist in. Personally I find this not only my responsibility, it also lets gives me direct feedback in to what users want or what they expect.

 

Let us not hijack this topic any further on this.

Link to comment
Share on other sites

 

 

@Thirsty panter: Since so many people have questions about ending the game, I will propably do a quick video tutorial about it.

 

Sounds like a good idea.

 

I'm also interested in loading my first level from FlowGUI. I haven't got this stage yet ( time poor ).

 

I'm in the process of designing my intro screen. I've imported a new font, got some animated characters. Now I just need to add some music and load the first level.

 

Many thanks again.

Link to comment
Share on other sites

Ironically someone asked me the same question yesterday evening. Here is my suggestion on how you can do this:

 

1. In app.lua before the App.Start function, add the following variable:

 

App.quitGame = false

 

2. in the main loop change the following line

if self.window:Closed() or self.window:KeyDown(Key.Escape) then return false end

 

with this:

if self.window:Closed() or App.quitGame or self.window:KeyDown(Key.Escape) then return false end

 

I simply added a check on whether the quiGame variable is true. Because if it is, then the App.Loop should be stopped.

 

 

3. Now, in your object script do the following:

 

App.quitGame = true

 

Thanks Aggror. Got a chance to add this to my project and It works.

 

Why do you use app.quitgame? why not just quitgame?

 

Again many thanks.

Link to comment
Share on other sites

  • 6 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...