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: WME resets door state  (Read 4112 times)

0 Members and 1 Guest are viewing this topic.

Eyes_Only

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 18
    • View Profile
WME resets door state
« on: June 26, 2009, 02:28:23 PM »

Hello everybody,

I have two rooms. When I want to walk from room1 to room2 I have to open the door from room1 and when I click, I can change scene. Now I am in room2. But when I go back from room2 to room1 and the scene is loaded, the room1 door is closed.

I tried to change the starting order so that I start with room2 and then go to room1 and there it's the same, when returnig a second time to the room the room1 door is set back to closed, while room2 door stays open.

How can this be? Has anyone an idea?

Thank you...
Logged

HelLRaiseR

  • I don't want to make a Monkey Island clone :(
  • Wiki editor
  • Frequent poster
  • ****
  • Karma: 4
  • Offline Offline
  • Posts: 270
    • View Profile
    • Adventure Box Studios
Re: WME resets door state
« Reply #1 on: June 26, 2009, 06:15:16 PM »

II think that the better way is store a value to save the door status, for example in the var StateScene that is created when WME create the scene from template.

If you has a entity in the screen, you can put a sprite with the door open or close depending of the value.

For example:

Code: [Select]
////////////////////////////////////////////////////////////////////////////////
// scene state
global StateRoom1;
var doorEntity;

// default values
if(StateRoom1==null)
{
  StateRoom1.Visited = false;
  // add scene states here
  StateRoom1.DoorOpened = false; // Initial value for the door. This is closed.
}

////////////////////////////////////////////////////////////////////////////////
// setup scene according to state variables

doorEntity = GetNode("door_entity"); // This is a entity in the scene tahat contain the sprite of the door open or closed

if(StateRoom1.DoorOpened) // If the door is opened
   doorEntity.SetSprite("door_open.png");
else // If the door is closed
   doorEntity.SetSprite("door_close.png");

////////////////////////////////////////////////////////////////////////////////
if(!StateRoom1.Visited)
{
  StateRoom1.Visited = true;

  // this is our first visit in this scene...
}

And in the script of the door (script assigned to the entity), for example in event "use/take":

Code: [Select]
global StateRoom1;

////////////////////////////////////////////////////////////////////////////////
on "Take"
{
  if (!StateRoom1.DoorOpened) //if the door is closed, then open.
  {
    actor.GoToObject(this);
    actor.PlayAnim("open_the_door");
    this.SetSprite("door_open.png");
    StateRoom1.DoorOpened = true; //stores in the scene state var the status of the door. When you return to the scene, the script used this value for draw the door open.
  }
  else // else, close the door
  {
    actor.GoToObject(this);
    actor.PlayAnim("close_the_door");
    this.SetSprite("door_close.png");
    StateRoom1.DoorOpened = false; //stores in the scene state var the status of the door. When you return to the scene, the script used this value for draw the door close.
  }
}

Logged
Regards,

    Fernando

Eyes_Only

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 18
    • View Profile
Re: WME resets door state
« Reply #2 on: June 27, 2009, 02:01:45 PM »

Thanks for your reply, but it doesn't work. I also tried another method. In room2 after opening the door, there is a corridor entity which I can click on, to change to room1 so in the corridor script I wrote:

Code: [Select]
#include "scripts\base.inc"

var room1_door = Scene.GetNode ("scenes\room1\room1.scene\room1_door_closed");

on "LeftClick"
{
  actor.GoToObject(this);
  room1_door.Active = false; 
  Game.ChangeScene ("scenes\room1\room1.scene");
}

But the crazy thing is, that when I enter room1, the door ist still there... How can this be???

Thanks...
« Last Edit: June 27, 2009, 02:03:42 PM by Eyes_Only »
Logged

HelLRaiseR

  • I don't want to make a Monkey Island clone :(
  • Wiki editor
  • Frequent poster
  • ****
  • Karma: 4
  • Offline Offline
  • Posts: 270
    • View Profile
    • Adventure Box Studios
Re: WME resets door state
« Reply #3 on: June 27, 2009, 10:32:26 PM »

Well, It's logical. When you return to room1, the scene load again. You don't has modifing the entity of the scene becouse the scene isn't still created. You has modifing a copy of the entity.

In the example the order is:

- Declare and create a instance of the entity (This entity there isn't in any scene).
- Whe you make Left click:
  - actor goes to object
  - Hide the instance of the entity that you are create before (remember that this entity isn't in the scene, the scene hasn't been still loaded)
  - Change the scene (then, the scene is reloaded and the entities of the scene has the default status).

Due to this, I say you in my other message that you can store the status, and when you open the scene, in the scene_init script, you can prepare the status of the door depending on value stored.
Logged
Regards,

    Fernando

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: WME resets door state
« Reply #4 on: June 28, 2009, 06:37:01 AM »

Imho, this shouldn't be a problem.  You have scene remember node states set in properties right for the door?

Do you have an opened and closed door for the sprites?  Or is it just a door that either lets you through (is active) or blocks you (is not active)--same graphic sprite or region entity for both?

You can set globals so that if you go back to that scene the global is set in such a way that the door has to be open.   
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Eyes_Only

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 18
    • View Profile
Re: WME resets door state
« Reply #5 on: June 28, 2009, 12:55:24 PM »

for the door I have a closed (door_closed) and an open (door_open) sprite and when opening (door_opening) or closing (door_closing) there is for each playing an animation containig 10 sprites. so for the closed door I have for example:

Code: [Select]
#include "scripts\base.inc"

var dooropen = Scene.GetNode ("fiona_door_open");
var doorclosed = Scene.GetNode ("fiona_door_closed");
var dooropenblocked = Scene.GetNode ("blocked_door_open");
var dooropening = Scene.GetNode ("fiona_door_opening");
var flur = Scene.GetNode ("fiona_flur");

on "LeftClick"
{
actor.GoToObject (this);
Game.Interactive = false;
actor.Talk ("Ich öffne sie mal.");
doorclosed.Active = false;
dooropening.Active = true;
var sprite = dooropening.GetSpriteObject();
while (!sprite.Finished) Sleep(1);
sprite.Reset ();
dooropening.Active =false;
dooropen.Active = true;
dooropenblocked.Active = true;
flur.Active = true;
Game.Interactive = true;
}

And the same for the open door. But the strange thing is, that wme reminds the status of the second room. That is, when I enter the second room again, the door is still open.

I tried what HelLRaiseR posted first, but while having 4 different entities for the door, the whole thing was (for me) to difficult to code. Has perhaps anyone an example how I can do this with globals?

Thanks a lot...
Logged

Eyes_Only

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 18
    • View Profile
Re: WME resets door state
« Reply #6 on: June 28, 2009, 01:35:55 PM »

I solved it -  :D :D :D - Jippiiiiiiiii

in my scene_init script I wrote:

Code: [Select]
#include "scripts\base.inc"

// here comes the stuff which initializes the scene

actor.SkipTo(461, 566);
actor.Direction = DI_DOWNRIGHT;
actor.Active = true;


////////////////////////////////////////////////////////////////////////////////
// scene state
global StateFionas_Zimmer;


// default values
if(StateFionas_Zimmer==null)
{
  StateFionas_Zimmer.Visited = false;
  // add scene states here
  StateFionas_Zimmer.dooropen = false;
}



////////////////////////////////////////////////////////////////////////////////
// setup scene according to state variables
if(StateFionas_Zimmer.dooropen) // If the door is opened
{
var doorclosed = Scene.GetNode ("fiona_door_closed");
var dooropen = Scene.GetNode ("fiona_door_open");
var flur = Scene.GetNode ("fiona_flur");

doorclosed.Active = false;
dooropen.Active = true;
flur.Active = true;
}
else // If the door is closed
{
doorclosed.Active = true;
dooropen.Active = false;
flur.Active = false;
}

////////////////////////////////////////////////////////////////////////////////
if(!StateFionas_Zimmer.Visited)
{
  StateFionas_Zimmer.Visited = true;

  // this is our first visit in this scene...
}

And then when opening or closing the door, I changed the StateFionas_Zimmer value to true or false and now it works.

It's a bit different from what HelLRaiseR posted, but the idea is the same, thanks alot...
Logged
 

Page created in 0.023 seconds with 25 queries.