Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Lufia on October 03, 2010, 05:49:00 AM

Title: Doing stuff on startup / includes
Post by: Lufia on October 03, 2010, 05:49:00 AM
I want to make some stuff happen on startup. Is the beginning of the game.script file the correct place to put it?
Specifically, I want to set some "custom properties" for a bunch of windows, so I try to use LoadWindow to access them and change their attributes but I get the following error message: "Function LoadWindow is referenced but not defined".
So, where do I put my code?

Do inc files have to be in the scripts folder?
I got a SyntaxError on the following line: #include "\interface\gui.inc"
and I'm at a loss as to why this would be the case.

Cheers.
Title: Re: Doing stuff on startup / includes
Post by: metamorphium on October 03, 2010, 10:15:34 AM
hi Lufia,

1. Game.LoadWindow(path to window file); is correct syntax
2. you can put it in the game.script if you want to perform a one-time init.
3. the include path is relative to your packages so #include "interface\gui.inc" or  #include "scenes\somescene\test.inc"  should work alike.

Hope this helps!
Title: Re: Doing stuff on startup / includes
Post by: Lufia on October 03, 2010, 11:03:51 AM
Hi!

Actually, I came back to the forum just now with the intention of editing my message because I stopped being stupid and solved these problems. But I'm still quite blond so I've got some more questions.

1. Can you use an event in a condition?
I want to do something like (pardon my pseudo-code)
Code: [Select]
on left click {
  loop {
    break if left button is released
    ...
  }
}
and I can't find how to write that condition.

2. Can you access window objects without loading them? I made a global array referencing the objects the first time I load them, which works just fine, but I was wondering if there's a built-in way.

3. Is it better to load/unload windows or just to toggle their visible / disabled status?

Thanks for your time. :)
Title: Re: Doing stuff on startup / includes
Post by: Mnemonic on October 03, 2010, 11:29:21 AM
1. Something like this:

Code: WME Script
  1. var isDragging = false;
  2.  
  3. on "LeftClick"
  4. {
  5.   isDragging = true;
  6.   while (isDragging)
  7.   {
  8.     ...
  9.     Sleep(100);
  10.   }
  11. }
  12.  
  13. on "LeftRelease"
  14. {
  15.   isDragging = false;
  16. }
  17.  

2. No.

3. It depends. Unloading the window saves memory. So if it's a window that's rarely used, you should unload it when it's no longer needed. Frequently used windows, on the other hand, are better kept loaded, so that you don't degrade performance by loading them from disk all the time.
Title: Re: Doing stuff on startup / includes
Post by: Lufia on October 03, 2010, 06:52:19 PM
I got it working, thank you.  ^^