Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: HIman on August 24, 2005, 07:36:56 AM

Title: Question about include, global variables and a site of scripts.
Post by: HIman on August 24, 2005, 07:36:56 AM
Greetings!

  Three questions, I in fact only study:)

The first:

   In an example wme_demo
From interface\menu\menu.script
In scripts\base.inc
Has transferred a line global MenuObject,
Mistakes are not present but after start the black screen, why?

The second question:
    In an example wme_demo after successful insert Edit in
interface\menu\menu.window
Example of a code
Code: [Select]
EDIT
  {
    NAME = "desc"
    BACK = "ui_elements\editor.image"
    FONT = "fonts\outline_green.font"
    FONT_SELECTED = "fonts\outline_red.font"
    SCRIPT = "scripts\parser.script"
    X = 0
    Y = 100
    WIDTH = 250
    HEIGHT = 20
    FRAME_WIDTH = 4
    TEXT = " "
    MAX_LENGTH = 200
    PARENT_NOTIFY = TRUE
    CURSOR_BLINK_RATE = 300
}
Has created scripts\parser.script with a code
Code: [Select]
#include "scripts\base.inc"
#nclude "scripts\keys.inc"

  var Editor = self. GetWidget ("desc");
  Editor. Text = self.xDescription;
  Editor. SelStart = 0;
  Editor. SelEnd = 200;

on "Keypress"
{
 self. Close ();
 if (Keyboard. KeyCode == VK_RETURN)
  {
    actor. Talk (Editor. Text);
}
  MenuObject = null;
}
  error opening script 'interface\menu\parser.script'
Why? I have obviously specified a way and what script will process EDIT.

The third question:
I have created parser.script in 'interface\menu\parser.script' with code look above.
Has specified what script will be will be executed:
Code: [Select]
EDIT
  {
     ..
    SCRIPT = "interface\menu\parser.script"
     ..
After start:
 Error. Call to undefined method 'GetWidget.' Ignored.

I have absolutely got confused: (
Title: Re: Question about include, global variables and a site of scripts.
Post by: kelmer on August 24, 2005, 07:54:59 AM
I can't understand what you're asking in your first question, but I can see two mistakes in your parser.script, which may very well be causing the error you're getting.

First is you typed '#nclude "scripts\keys.inc"' instead of "#include "scripts/keys.inc". Also, you left a space when calling the method GetWidget from the self object, it should look "self.GetWidget("desc");". Same with the next functions, Editor.Text, Editor.SelStart, etc.
Title: Re: Question about include, global variables and a site of scripts.
Post by: metamorphium on August 24, 2005, 08:27:51 AM
Ok. to clarify, it's equal if you use

#include "something/something" or #include "something\something"
Both will work.

the space is really a big mistake and also you should use "this" instead of "self".
If you are still confused about variables and objects you can check out my short tutorial on them:

http://wiki.dead-code.org/wakka.php?wakka=ObjectsVariables&v=k95

Hope that helps
Title: Re: Question about include, global variables and a site of scripts.
Post by: Nihil on August 24, 2005, 08:32:55 AM
The first:

   In an example wme_demo
From interface\menu\menu.script
In scripts\base.inc
Has transferred a line global MenuObject,
Mistakes are not present but after start the black screen, why?

If I get you right you copied global MenuObject from your menu.script to base.inc? If yes, check if global MenuObject is defined in a script that includes base.inc, in that case it would be defined twice which I causes an error.

Does WME.log give out any errors?
Title: Re: Question about include, global variables and a site of scripts.
Post by: HIman on August 24, 2005, 08:55:49 AM
[If I get you right you copied global MenuObject from your menu.script to base.inc? If yes, check if global MenuObject is defined in a script that includes base.inc, in that case it would be defined twice which I causes an error.
Does WME.log give out any errors?
global MenuObject it is determined only once.

It would be quite good to add search in WME Project Manager  ::)

I have not copied, and have transferred definition of a variable
From interface\menu\menu.script
In scripts\base.inc
Mistakes in WME.log are not present, but does not work :(
Title: Re: Question about include, global variables and a site of scripts.
Post by: Nihil on August 24, 2005, 08:59:58 AM
I have just looked at the wme-demo, and MenuObject is also defined in Game.Script which includes base.inc  - did you delete it there?
Title: Re: Question about include, global variables and a site of scripts.
Post by: kelmer on August 24, 2005, 09:04:33 AM
#include "something/something" or #include "something\something"
Both will work.

Alright, that was a mistake of mine, but I was pointing at the "inculde" vs. "nclude"
Title: Re: Question about include, global variables and a site of scripts.
Post by: metamorphium on August 24, 2005, 09:07:40 AM
#include "something/something" or #include "something\something"
Both will work.

Alright, that was a mistake of mine, but I was pointing at the "inculde" vs. "nclude"

Ah, and I am blind. LOL

Title: Re: Question about include, global variables and a site of scripts.
Post by: HIman on August 24, 2005, 09:59:53 AM
#include "something/something" or #include "something\something"
Both will work.

Alright, that was a mistake of mine, but I was pointing at the "inculde" vs. "nclude"

Thanks for "ncude" but it only a mistake in a forum and in the program "include"  ;)
Title: Re: Question about include, global variables and a site of scripts.
Post by: HIman on August 24, 2005, 10:16:00 AM
I have just looked at the wme-demo, and MenuObject is also defined in Game.Script which includes base.incĀ  - did you delete it there?
Is not present did not delete, after change in scripts\game.script
global MenuObject = null;
On
MenuObject=null;

Works, but then the question remains as it turns out that has been determined two times a global variable in WME_demo?
Title: Re: Question about include, global variables and a site of scripts.
Post by: Nihil on August 24, 2005, 10:24:26 AM
I'm not sure if I got you right, but anyway:  A global variable must be defined in every script you use it, but only once per script - just like normal variables. So if you define your variable in an .inc-file and include it in a script, for example scene_init.script, you can't define the same varaible in that script again.
Title: Re: Question about include, global variables and a site of scripts.
Post by: HIman on August 24, 2005, 10:40:27 AM
I have understood all... Thanks metamorphium and him
 tutorial http: // wiki.dead-code.org/wakka.php? wakka=ObjectsVariables*v=k95
>>>>>>>>>
!!This is important! If you use global variables they MUST be declared using the global keyword in every script you are using them. Otherwise it won't work and you will end up with script compiler errors.
Title: Re: Question about include, global variables and a site of scripts.
Post by: Nihil on August 24, 2005, 11:46:40 AM
Fine :-)