Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Catacomber on October 21, 2008, 03:45:49 AM

Title: Script errors
Post by: Catacomber on October 21, 2008, 03:45:49 AM
SOB!!!!!!!  CRY!!!!  CATERWAUL!!!!

Following the warehouse demo:

I have these errors in the WME Log--I thought I followed the instructions--where do I declare the variable "door"?--am not so much worried about Molly errors:

CBSprite::LoadFile failed for file 'actors\molly\dr\stand.sprite'
22:39: CBSprite::LoadFile failed for file 'actors\molly\dr\walk.sprite'
22:39: CBSprite::LoadFile failed for file 'actors\molly\dr\talk.sprite'
22:39: CBSprite::LoadFile failed for file 'actors\molly\dr\turn.sprite'
22:39: CBSprite::LoadFile failed for file 'actors\molly\dr\turn.sprite'
22:39: Compiling script 'scenes\Warehouse\scr\Door.script'...
22:39:   Error@line 5: Variable 'Door' is referenced but not defined
22:39: Compiling script 'scenes\Warehouse\scr\Door.script'...
22:39:   Error@line 6: Variable 'Door' is referenced but not defined
22:39: Compiling script 'scenes\Warehouse\scr\Door.script'...
22:39:   Error@line 5: Variable 'Door' is referenced but not defined
22:39: Compiling script 'scenes\Warehouse\scr\Door.script'...
22:39:   Error@line 6: Variable 'Door' is referenced but not defined

Title: Re: Script errors
Post by: metamorphium on October 21, 2008, 07:52:56 AM
Hi cat,

please post the contents of your code here.

Unlike in the book, you use variable in Door.script while in the book, there's no variable like this. Maybe you misplaced parts of the script with a bomb.script?
Title: Re: Script errors
Post by: Catacomber on October 21, 2008, 02:57:11 PM
Thank you!!!!   I'll post the script tonight--am not at my regular computer.  I did not put a variable in the door script--just copied the script from the book--was working my way to the bomb script.   

BTW, your book is very amusing and very clear.
Title: Re: Script errors
Post by: Catacomber on October 21, 2008, 11:43:28 PM
I made a small donation for the online book.  It's helped a lot.  But I don't understand one of the buttons on the "Scripts for the "Door" object"--it's the open folder icon between the new script button and the edit script buttion.  What is that used for?  To attach the script to the object?  If it is, where do I save the script with that?

This is the code on the door--I didn't have a variable:

#include "scripts\base.inc"
on "LeftClick"
{
   Game.Interactive = false;
   actor.GoToObject(Door);
   Door.Active = false;
   actor.Talk("Oh no. The door is welded shut.");
   Game.Interactive = true;
}

should it have been--

#include "scripts\base.inc"
var = Door = new Object("Door.script");
on "LeftClick"
{
Game.Interactive = false;
actor.GoToObject(Door);
Door.Active = false;
actor.Talk("Oh no. The door is welded shut.");
Game.Interactive = true;
}

Or something else???  Thanks for any help.

Title: Re: Script errors
Post by: Catacomber on October 22, 2008, 04:40:52 AM
I've fixed the script errors that referred to Molly--it's only the script on the door that is a problem now but I realize that's a very important problem--help is welcome.  : ) 
Title: Re: Script errors
Post by: Azrael on October 22, 2008, 07:07:19 AM
It should be more something like:

Code: [Select]
var Door = Scene.GetNode("Door");
If "Door" is an entity or a region in the scene.
Title: Re: Script errors
Post by: metamorphium on October 22, 2008, 08:55:16 AM
Cat, the code in the book is meant verbatim, so you should put it there in its entirety. In the book is written:

Code: WME Script
  1. on "LeftClick"   
  2. {
  3.   Game.Interactive = false;    // We want our player to make more things at once and we don't want to be interrupted.
  4.  
  5.   actor.GoToObject(this);
  6.  
  7.   this.Active = false// We disable the door so the hotspot is not visible or active anymore.
  8.   actor.Talk("Oh no. The door is welded shut.");        
  9.   Game.Interactive = true; // Allow player to play some more.
  10. }
  11.  

You replaced the keyword this with a word Door which is never declared before. That's why your code is not working. I'll try to explain to you the meaning of life err. the *this* keyword.

Imagine you have a pet dog, let's call him Slowey. Now think of your dog as of some WME entity, for example the image of a dog. We'd call this dog internally "object" because apart from his visual side (image of a dog) it also has some behavior - he walks around, waves his tail and bark. This behavior would have been defined in his script file, which is attached to the dog. So at the end of the day, your dog consists of an image and of a script (or more scripts) defining his behavior.

Now the script is internally part of a dog and if you want inside of this script refer to dog itself, you can conveniently refer to dog using the keyword this.

Now back to your example - and how to correct it (if you really don't want to use my code):

Code: WME Script
  1. #include "scripts\base.inc"
  2. on "LeftClick"
  3. {
  4.    Game.Interactive = false;
  5.    var Door = Scene.GetNode("Door")// we have to tell WME what the Door really is! So instead of using convenient this, we add extra line and define a useless variable. :)
  6.  
  7.    actor.GoToObject(Door);
  8.    Door.Active = false;
  9.    actor.Talk("Oh no. The door is welded shut.");
  10.    Game.Interactive = true;
  11. }
  12.  

Hope this helps!
Title: Re: Script errors
Post by: Catacomber on October 22, 2008, 02:40:50 PM
Thank you both, Azrael and Metamorphium.  The meaning of life . . err. . code is more clear.  I'll try it tonight.   :)  Will try it both ways.  Object oriented coding is a little bit new to me but am lapping it up.  : ) 

EDIT:  Just one little question -- if I use the code in the book verbatim, I don't have to declare the var door?  The game already knows that "this" is door?  I will use your code because I understand the value of less is more codewise in a big game.  : )  Thanks again.
Title: Re: Script errors
Post by: metamorphium on October 22, 2008, 03:03:59 PM
yes. As I tried to explain - the script is part of an object (in this case the object is Door region) so *this* refers to the door region. As you are inside of the door object, this points to itself (door) and says "Hey, it's me! Your trusty door." :)
Title: Re: Script errors
Post by: Catacomber on October 22, 2008, 03:21:16 PM
Now I understand.  :  ) ) )  Thank you for your patience, your book, and your wonderful humor which makes slogging through all the exercises in the book a lot less painful than it otherwise would be!!!!  I hope I can make a nice, commercial game eventually.  : )   I'm one of 2 partners called Zarista Games--my partner is a Russian guy--we make games usually involving Russian history--rpg fighting stuff.  Can't wait to get further with your fine editor.  We just got licensed by Apple but before I try the Apple sdk I want to make a game with Wintermute. 

Thank you for the change in title.  :  ) 
Title: Re: Script errors
Post by: metamorphium on October 22, 2008, 03:51:26 PM
Cat, I am not sure now, if you're not mistaking me with the engine creator (Mnemonic)? I know it's hard when our names both start with M. :) I'm just a humble book writer and game developer, the real master mind behind the engine and editors is Mnemonic. :D

Anyway, feel free to ask if you're stuck again. ;)
Title: Re: Script errors
Post by: Catacomber on October 22, 2008, 03:58:54 PM
Thank you both then, M & M.  :  ) 
Title: Re: Script errors
Post by: Mnemonic on October 22, 2008, 05:17:26 PM
You're welcome :) Thanks for the donation.

We just got licensed by Apple but before I try the Apple sdk I want to make a game with Wintermute. 
You mean the iPhone development license?
Title: Re: Script errors
Post by: Catacomber on October 22, 2008, 05:40:31 PM
You're welcome.  Will make another as soon as I learn enough to make a little game.  I like your editor very much.  I have very few problems with it and those are my fault.

Yes, the iphone program.  : )  But before I do much with it I hope to be able to make an adventure game with Wintermute.  Apple will not kill us if we are idle for a little bit--besides I now have to learn Objective C--which is not too different from C but is very heavy in object oriented programming and right now that's my weakness---working on that weakness.  :  ) 

Thank you again for your fine editor.  I hope you will be developing it further but am happy with what it is right now.

If....If I can get to the point where I have a windows executable for a PC game, can I then convert that to a pocket pc game for windows mobile via Microsoft's SDK for Windows Mobile or that is not an option?  Would have to make a cab file.  I have instructions somewhere for making a cab file from an exec--was just wondering if anyone has done that or if there is anything about the structure of the exec file that would prevent my doing that. 
Title: Re: Script errors
Post by: Catacomber on October 22, 2008, 07:33:26 PM
Metamorphium---I just corrected my confusion between you and Mnemonic for the book.  Thanks again. 
Title: Re: Script errors
Post by: Catacomber on October 23, 2008, 02:27:12 AM
I have no further script errors in my log (using my script as modified by you : )) but am not sure how to attach the bomb script to the door.  I can't attach it directly to the door object as it already has one script and I know the new script will "call" the bomb script---but how do I add the bomb script?  Puzzled.
Title: Re: Script errors
Post by: Catacomber on October 23, 2008, 03:57:00 AM
Figured out how to make the bomb script and am at the end of the tutorial for that section.  BUT--have new error log using all the scripts ---

********** DEBUG LOG OPENED 22-10-2008 (Release Build) *****************
22:52: Wintermute Engine ver 1.8.6, Compiled on Apr  6 2008, 13:49:35
22:52: Platform: Windows XP Service Pack 3 (Build 2600)
22:52: DirectX version: 9.0
22:52:
22:52: Scanning packages...
22:52:   Registered 0 files in 0 package(s)
22:52: Initializing scripting engine...
22:52:   Script compiler bound successfuly
22:52: Loading plugins...
22:52:   wme_sample_pixel.dll
22:52:   wme_snow.dll
22:52: Loading string table...
22:52:   49 strings loaded
22:52: Enumerating Direct3D devices...
22:52: Enumerating DirectSound devices...
22:52: Available video devices:
22:52:   NVIDIA GeForce4 MX 440 with AGP8X (accelerated)
22:52:     nv4_disp.dll 6.14.10.9371
22:52: Available audio devices:
22:52:   Primary Sound Driver
22:52:   Realtek AC97 Audio
22:52:   [no sound]
22:52:
22:52: User selected:
22:52:   Video: NVIDIA GeForce4 MX 440 with AGP8X (accelerated)
22:52:          Windowed:no  Colors:32bit  T&L:no  Multisample:0
22:52:   Audio: Primary Sound Driver
22:52: Maximum texture size: 2048x2048
22:52: Engine initialized in 32 ms
22:52:
22:52: Runtime error. Script 'scenes\Warehouse\scr\Door.script', line 7
22:52:   actor.GoToObject method accepts an entity refrence only
22:53: Runtime error. Script 'scenes\Warehouse\scr\Door.script', line 7
22:53:   actor.GoToObject method accepts an entity refrence only
22:53:
22:53: Shutting down...
22:53: Shutting down scripting engine


My door script -- copied from the online book unless I made a mistake:

   #include "scripts\base.inc"
 
on "LeftClick"   
{
   Game.Interactive = false;    // We want our player to make more things at once and we don't want to be interrupted.
   global doorClicked = true;
   actor.GoToObject(this);
   this.Active = false;  // We disable the door so the hotspot is not visible or active anymore.
   actor.Talk("Oh no. There's a timed bomb attached to the door! I have to find an exit before it explodes.");   
   Scene.AttachScript("scenes\warehouse\scr\bomb.script");
   Game.Interactive = true; // Allow player to play some more.
}

Sigh. : )  Molly nicely dies and starts over!) : ).  My only problem is that script error and the fact that I can't seem to change scenes here--but then Molly isn't living long enough to change scenes. 

If you get the hourglass during playing a scene does it mean it's somehow bugged?