Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Doing stuff on startup / includes  (Read 3250 times)

0 Members and 1 Guest are viewing this topic.

Lufia

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 3
    • View Profile
Doing stuff on startup / includes
« 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.
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Doing stuff on startup / includes
« Reply #1 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!
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Lufia

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 3
    • View Profile
Re: Doing stuff on startup / includes
« Reply #2 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. :)
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Doing stuff on startup / includes
« Reply #3 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.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Lufia

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 3
    • View Profile
Re: Doing stuff on startup / includes
« Reply #4 on: October 03, 2010, 06:52:19 PM »

I got it working, thank you.  ^^
Logged
 

Page created in 0.057 seconds with 25 queries.