Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Molly and Sally  (Read 5973 times)

0 Members and 1 Guest are viewing this topic.

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Molly and Sally
« on: October 25, 2008, 04:48:22 AM »

I have now 2 actors in my game---following the tutorial.  Molly and Sally.  But I can't place more than 1 in the scene at a time it seems.  : (
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Azrael

  • Regular poster
  • ***
  • Karma: 9
  • Offline Offline
  • Gender: Male
  • Posts: 155
    • View Profile
    • Mad Orange
Re: Molly and Sally
« Reply #1 on: October 25, 2008, 07:26:38 AM »

You should post your code so we can find the problem ;)

However the code should be something like that:

Code: [Select]
//For the main Actor
actor.SkipTo(200, 200);
actor.Active = true;

//For secondary Actor
var sally = Scene.LoadActor("actors\sally\sally.actor");    //I assumed this was the path to your actor, change it if is not this
sally.SkipTo(300, 300);
sally.Active = true;
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: Molly and Sally
« Reply #2 on: October 25, 2008, 09:02:16 AM »

Cat, you don't place actors in Scene editor itself. the placing there is just for the sake of getting the right coordinates. the real placement is done through scripts as Azrael mentioned.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Molly and Sally
« Reply #3 on: October 25, 2008, 08:29:54 PM »

I understand now.  Thanks to both of you!!!!   :D
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Molly and Sally
« Reply #4 on: October 25, 2008, 09:02:09 PM »

Now I have Molly and Sally in the room:



One of them can move -- the other doesn't.  But I have a script error in the game loop that I can't track down why.  This is the compiler log:

User selected:
15:55:   Video: NVIDIA GeForce4 MX 440 with AGP8X (accelerated)
15:55:          Windowed:no  Colors:32bit  T&L:no  Multisample:0
15:55:   Audio: Primary Sound Driver
15:55: Maximum texture size: 2048x2048
15:55: Engine initialized in 47 ms
15:55:
15:55: Compiling script 'scripts\game_loop.script'...
15:55:   Error@line 43: syntax error
15:55:
15:55: Shutting down...
15:55: Shutting down scripting engine

This is my game loop script:

#include "scripts\base.inc"

// this script runs in an endless loop and does all the user-interface work
// that needs to be periodically updated
// such as the floating items captions display and positioning
// and the sliding inventory window handling


global WinCaption;

// infinite loop
while(true){

  // save the active object for later
  var ActObj = Game.ActiveObject;

  // handle the standard foating caption
  if(Game.Interactive && ActObj!=null)
  {
   
      WinCaption.X = Game.MouseX;
      WinCaption.Y = Game.MouseY + 20;
      WinCaption.TextAlign = TAL_LEFT;
      WinCaption.Text = ActObj.Caption;

      // keep the caption on screen
      WinCaption.SizeToFit();
      if(WinCaption.X + WinCaption.Width > Game.ScreenWidth) WinCaption.X = Game.ScreenWidth - WinCaption.Width;
      if(WinCaption.Y + WinCaption.Height > Game.ScreenHeight) WinCaption.Y = Game.ScreenHeight - WinCaption.Height;
     }
    // handle the caption when you want to use an object with another
    else {
      var Item = Game.SelectedItem;

      WinCaption.X = 0;
      WinCaption.Y = 580;
      WinCaption.Width = Game.ScreenWidth;
      WinCaption.TextAlign = TAL_CENTER;
      WinCaption.Text = "Use " + Item.Caption + " with " + ActObj.Caption;
    }
    WinCaption.Visible = true;
    }
  else WinCaption.Visible = false;

    // go to sleep for 20 miliseconds to allow the engine to perform other tasks
  // it is important for the "endless" scripts to call the Sleep command, otherwise the game will get stuck
  Sleep(20);
}

Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Spellbreaker

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • View Profile
    • Apeiron Studios
Re: Molly and Sally
« Reply #5 on: October 25, 2008, 09:08:11 PM »

You destroyed your script.

Count the brackets : You have 4 closing } but just 3 opening { .

My quick-guess:

The Line
  else WinCaption.Visible = false;

should be
  else { WinCaption.Visible = false;
Logged

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Molly and Sally
« Reply #6 on: October 25, 2008, 09:15:43 PM »

Thank you SpellBreaker---You set me on the right direction--I had copied the last part of the script incorrectly from the book--
this is what the script should be according to the book using bare bones scripting and this now works.  Thanks!!!!

#include "scripts\base.inc"

// this script runs in an endless loop and does all the user-interface work
// that needs to be periodically updated
// such as the floating items captions display and positioning
// and the sliding inventory window handling


global WinCaption;

// infinite loop
while(true){

  // save the active object for later
  var ActObj = Game.ActiveObject;

if(Game.Interactive && ActObj!=null)
  {
      WinCaption.X = Game.MouseX;
      WinCaption.Y = Game.MouseY + 20;
      WinCaption.TextAlign = TAL_LEFT;
      WinCaption.Text = ActObj.Caption;
      WinCaption.SizeToFit();
      if(WinCaption.X + WinCaption.Width > Game.ScreenWidth) WinCaption.X = Game.ScreenWidth - WinCaption.Width;
      if(WinCaption.Y + WinCaption.Height > Game.ScreenHeight) WinCaption.Y = Game.ScreenHeight - WinCaption.Height;
     WinCaption.Visible = true;
    }
    else WinCaption.Visible = false;
    Sleep(20);
}

My only problem now so far is that both Molly and Sally don't move--only one.
« Last Edit: October 25, 2008, 09:28:25 PM by Catacomber »
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Azrael

  • Regular poster
  • ***
  • Karma: 9
  • Offline Offline
  • Gender: Male
  • Posts: 155
    • View Profile
    • Mad Orange
Re: Molly and Sally
« Reply #7 on: October 25, 2008, 09:55:08 PM »

You mean when you left click somewhere?

If yes this should be, if there aren't particular scripts, normal beacause only the main character react to direct imput like "LeftClick", "RightClick" with defaults script.
If you want the other actor to do something you have to script it :)
Logged

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Molly and Sally
« Reply #8 on: October 25, 2008, 10:02:57 PM »

Yup, thanks--just don't know what to do here--I'm trying to follow the tutorial and am now up to giving control to the other actor but Sally is dead. Only Molly acts when I click on her.  She acts according to her script but Sally is quite dead.

This is my Sally script:

; $EDITOR_PROJECT_ROOT_DIR$ ..\..\..\

ACTOR
{
  NAME = "sally"
  CAPTION="Sally"
  SCALABLE = TRUE
  INTERACTIVE = FALSE
  X = 460
  Y = 400
  SCRIPT="actors\sally\sally.script"

  FONT = "fonts\outline_red.font"
 
   ANIMATION
  {
    NAME       = "idle"
   
    LEFT       = "actors\sally\ll\stand.sprite"
    RIGHT      = "actors\sally\rr\stand.sprite"
    UP         = "actors\sally\uu\stand.sprite"
    DOWN       = "actors\sally\dd\stand.sprite"

    UP_LEFT    = "actors\sally\ul\stand.sprite"
    UP_RIGHT   = "actors\sally\ur\stand.sprite"
    DOWN_LEFT  = "actors\sally\dl\stand.sprite"
    DOWN_RIGHT = "actors\sally\dr\stand.sprite"
  } 

  ANIMATION
  {
    [blah blah blah-the usual--deleted to save posting space]

This is my Game.script:
#include "scripts\base.inc"
#include "scripts\keys.inc"

// store some of the game's attributes in global variables for convenience
Keyboard = Game.Keyboard;
Scene = Game.Scene;

// load the "caption" window
var win = Game.LoadWindow("interface\system\caption.window");
global WinCaption = win.GetControl("caption");

// load our main actor
molly = Game.LoadActor("actors\molly\molly.actor");
sally = Game.LoadActor("actors\sally\sally.actor");
actor = molly;
actor = sally;
Game.MainObject = actor;

// run the "game loop" script
Game.AttachScript("scripts\game_loop.script");

Game.InventoryVisible = true;

// which scene to load?
Game.ChangeScene(Game.StartupScene);


////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
  // what did we click?
  var ActObj = Game.ActiveObject;
  if(ActObj!=null)
  {
     ActObj.ApplyEvent("LeftClick");
  }
  // else propagate the LeftClick event to a scene
  else
  {
    Scene.ApplyEvent("LeftClick");
  }
}

on "RightClick"
{
  if (Game.SelectedItem != null){
    Game.SelectedItem = null;
  }
}

////////////////////////////////////////////////////////////////////////////////
on "Keypress"
{
  // on Esc or F1 key
  if(Keyboard.KeyCode==VK_ESCAPE || Keyboard.KeyCode==VK_F1)
  {
    // load and display the main menu window
    WinCaption.Visible = false;
    var WinMainMenu = Game.LoadWindow("interface\system\mainmenu.window");
    WinMainMenu.Center();
    WinMainMenu.GoSystemExclusive();
    Game.UnloadObject(WinMainMenu);
  }
}


////////////////////////////////////////////////////////////////////////////////
on "QuitGame"
{
  // on Alt+F4 (window close)
  // load and display the quit confirmation window
  WinCaption.Visible = false;
  var WinQuit = Game.LoadWindow("interface\system\quit.window");
  WinQuit.Center();
  WinQuit.GoSystemExclusive();

  // and if the user selected Yes
  if(WinQuit.xResult)
  {
    // quit the game
    Game.QuitGame();
  }
  // otherwise just unload the quit window from memory
  else Game.UnloadObject(WinQuit);
}

Urgh!  (Not part of script)  ???

This is the part of the book am following:

Now what we’ve done is that we’ve created another actor named Sally which uses the same graphics as a Molly, but it’s entirely different person. We have her reference stored in the global variable actor2 and we’ve placed her in our Room scene. Next thing we’re going to do is that we’re going to implement a neat character switching.

If player clicks on Molly or Sally (without an inventory item selected) game gives control to the second actor.

Now remember that everything in our scripts is set to use the global variable “actor”. So if we want to implement character switching, we simply set this variable to character of our liking. Also we have to change the Game.MainObject because it drives the screen scrolling and we want to maintain this functionality as well. So let’s open the file molly.script in the actor folder and add here the LeftClick handler:
on "LeftClick"
{
   if (Game.MainObject == molly) actor.Talk("I am already selected!");
   else
   {
      actor = molly;
      Game.MainObject = actor;
   }
}

Analogically we’ll modify the sally.script to read:
on "LeftClick"
{
   if (Game.MainObject == sally) actor.Talk("I am already selected!");
   else
   {
      actor = sally;
      Game.MainObject = actor;
   }   
}

Although we could use single file for this, later on it pays off to have those separated when we want to perform different tasks with each actor.

Now run the game and note that we can switch between actors by simple Left Click on them.

I did all this. Sally is still dead.  Will place flowers on her grave.  : (
« Last Edit: October 25, 2008, 10:07:54 PM by Catacomber »
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Molly and Sally
« Reply #9 on: October 25, 2008, 10:24:00 PM »

The game seems to think both actors are Molly--when I click on the real molly--I get message on screen Molly.  When I click on Sally, no message.  Trying to track the problem down. 
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Molly and Sally
« Reply #10 on: October 26, 2008, 12:24:57 AM »

SOLVED!!!!!!!    ;D ;D ;D ^^

Everything is perfect now.  There was ONE line in sally.actor that made my life miserable:

INTERACTIVE = FALSE  How it got to false when I copied the file from Molly, I'll never know but will be very watchful in copying files in future.

Changing that to true solved my problem.  Sally is alive!!! 

I am learning a great deal from my mistakes!!!!  :  ) 
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  
 

Page created in 0.047 seconds with 25 queries.