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: window problem  (Read 3688 times)

0 Members and 1 Guest are viewing this topic.

Stucki

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Posts: 325
  • I'm a llama!
    • View Profile
    • Schach-Welten
window problem
« on: October 21, 2007, 04:43:54 PM »

Hello i have a little problem concerning a window i want to use for an automap. it should act just like the inventory.
if the mouse is over y=700 it should come in and if it is under 650 again it should get away.

the coming in part works fine but the get away part gives me this error:
17:34: Runtime error. Script 'scripts\game_daemon.script', line 64
17:34:   Call to undefined method 'FadeOut'. Ignored.

here is the part of the gamedaemonscript:

var InvWindow = Game.GetInventoryWindow();
var MapWindow;
   
// display the inventory window
if(Game.Interactive && Game.MouseY < 100 && !Game.ResponsesVisible && !WinMenu.Visible && Scene.Name!="Intro" && Scene.Name!="Kapitel_1" && Scene.Name!="Schachwelt" && invsichtbar==0)
   {
     InvWindow.FadeIn();
     }
else if(Game.MouseY > 150 || Game.ResponsesVisible || !Game.Interactive)
   {
   InvWindow.FadeOut();
   }
// display the automap window
 
if(Game.Interactive && Game.MouseY > 700 && !Game.ResponsesVisible && !WinMenu.Visible && Scene.Name!="Intro" && Scene.Name!="Kapitel_1" && Scene.Name!="Schachwelt" && invsichtbar==0 && Map !=true)
   {
     MapWindow = Game.LoadWindow("interface\automap.window");
   MapWindow.FadeIn();
   Map=true;
     }
else if(Game.MouseY < 650 && Map==true )
   {
   MapWindow.FadeOut();
   //Game.UnloadObject(MapWindow);
   Map=false;
   }

and here is the automap.script:

#include "scripts\base.inc"

Map=false;
method FadeOut()
   {
   for (var i = 255; i >= 0; i = i - 15)
      {
      this.AlphaColor = RGB(255, 255, 255, i);
      this.Y=this.Y+6;
      Sleep(5);
      }
   this.AlphaColor = RGB(255, 255, 255, 0);
   }
   
method FadeIn()
   {
   for (var i = 0; i <= 255; i = i + 15)
      {
      this.AlphaColor = RGB(255, 255, 255, i);
      this.Y=this.Y-6;
      Sleep(5);
      }
   this.AlphaColor = RGB(255, 255, 255, 255);
   }

anybody any idea ??
greets stucki

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: window problem
« Reply #1 on: October 21, 2007, 05:50:07 PM »

I think you need to load window into the MapWindow variable at the top of the daemon script.

Currently you just have:

var MapWindow;

If you change that to:

var MapWindow = Game.LoadWindow("interface\automap.window");

...and then remove the window loading code further down, I think that will help.
Logged

Stucki

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Posts: 325
  • I'm a llama!
    • View Profile
    • Schach-Welten
Re: window problem
« Reply #2 on: October 21, 2007, 06:37:17 PM »

yes, you are right !! thanks that helped very much.

but can you explain me why this is so... ?
i do not understand why it hasnt worked my way

the fadeout() method only is called when the window was loaded into the var ..
i cant see the error ...

best regards
stucki

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: window problem
« Reply #3 on: October 21, 2007, 08:05:28 PM »

I think it's because local variables are only effective within the block of code that they are declared and set. So you were setting MapWindow within a certain code block, but then trying to use a method associated with that window outside of the code block, so it doesn't work.

Even though you declared the varibale at the top of the script, you didn't set it to equal the window at the same time, so the variable only equalled the window within that code block further down. Outside of that code block the variable probably equalled null.

Setting the variable to equal the window at the top of the script means it's effective throughout the entire script.
Logged

Stucki

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Posts: 325
  • I'm a llama!
    • View Profile
    • Schach-Welten
Re: window problem
« Reply #4 on: October 22, 2007, 05:46:14 PM »

thanks again for the detailed explanation.  O0 ::rock O0
i will have to think about it a little ... maybe i will get it ..... maybe not ... ;D
 

Page created in 0.044 seconds with 20 queries.