Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: Scripting - Return from a non interactive scene  (Read 5188 times)

0 Members and 1 Guest are viewing this topic.

Pelrock

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
Scripting - Return from a non interactive scene
« on: December 26, 2011, 03:04:20 PM »

Hi,

I´m developing the code of my adventure and I need some help if someone knows how to do this:

Quote
The character picks up a piece of paper. Then he goes into the inventory to check it. When he right clicks on the object, it takes him to another scene, non interactive, where he can only move the mouse and highlight the text to see the paper in detail.
When he finish to look at it he can leave the scene by clicking out of the image.

I´ve figured out how to bring him to the scene, but not how to return.

How can I save the character position to return to the previous scene? So after checking the paper he can return to where he was before.

The idea is that you can check this paper anywhere, anytime during the game.

I´ve got the three scripts for the moment:

      - The script of the paper on the inventory, paper.script    /// It takes him to the other scene throught this  "Game.ChangeScene("Scenes/paper_detail.scene");

      - The script of the scene, scene.init.script                    /// I´ve got hidden the character and set up the interactive regions
      - The script of the region inside the scene to leave, exit_scene.script   /// What should I use to return?


Any help would be much appreciate it,
many thanks
Logged

Ennio

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Posts: 40
    • View Profile
Re: Scripting - Return from a non interactive scene
« Reply #1 on: December 26, 2011, 05:21:34 PM »

How about adding new Layer instead of changing scene?
Maybe using a close-up layer (like the example in the online book http://res.dead-code.org/doku.php/wmebook:ch8 ) you could avoid the problem!
Logged

Pelrock

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
Re: Scripting - Return from a non interactive scene
« Reply #2 on: December 26, 2011, 05:51:45 PM »

Sounds really good. I didn´t know about that. Thank you.

Although I´m not sure if would work in this case, because the layer must be visible/invisible on every scene of the game, as the character would check this from his inventory...

But I will take a further look to the tutorial,

Thanks!
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Scripting - Return from a non interactive scene
« Reply #3 on: December 26, 2011, 06:22:44 PM »

Or if the new scene isn't too complex, it could be a window.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Ennio

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Posts: 40
    • View Profile
Re: Scripting - Return from a non interactive scene
« Reply #4 on: December 26, 2011, 06:58:35 PM »

I have the same state in the game wich i'm working on.
A letter in inventory wich the player can read, displaying a new layer with a close up to it. (the only difference is that i'm not allowing player to do anything more than reading the letter)

This is how i code that
(letter.script)
Code: [Select]
on "Examine"
{
 
 Scene.AddLayer("letterCloseUp");
 var letterCloseUp = Scene.GetLayer("letterCloseUp");
 letterCloseUp.CloseUp;
 var letterSprite = letterCloseUp.AddEntity("letterSprite");
 letterSprite.AttachScript("items\letterCloseUp.script");
 letterSprite.X = 62;
 letterSprite.Y = 95;
 letterSprite.SetSprite("items\letterSprite.sprite");
 
}

(letterCloseUp.script)
This script is to autoclose the layer if player makes any action, obviously you can change the condition for closing the layer at your wish!
Code: [Select]
#include "scripts\base.inc"
var letterEntity = Scene.GetNode("letterSprite");
var letterLayer = Scene.GetLayer("letterCloseUp");

AutocloseCheck();

on "LeftClick"
{
  CloseLetterCloseUp();
 
}

function CloseLetterCloseUp()
{
 
  Scene.DeleteEntity(letterEntity);
  Scene.DeleteLayer(letterLayer);

}

//function to close the closeUp, if player move the actor anywhere
function AutocloseCheck()
{
  while(true)
  {
    if(actor.IsWalking())
{
CloseLetterCloseUp();
break;
}
Sleep(10);
  }
}
Logged

Pelrock

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
Re: Scripting - Return from a non interactive scene
« Reply #5 on: December 27, 2011, 01:04:56 AM »

That´s fantastic. Thanks for sharing that code.
I am also considering the window idea, which can be a good option too.

Many thanks :)
Logged

Pelrock

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
Re: Scripting - Return from a non interactive scene
« Reply #6 on: December 27, 2011, 02:10:44 AM »

I have finally created a window to do it and works really well!! :)
Thanks for that

Is there any option to create a fade-in/fade out effect on loading the window?
Logged

Ennio

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Posts: 40
    • View Profile
Re: Scripting - Return from a non interactive scene
« Reply #7 on: December 27, 2011, 09:46:01 AM »

Mnemonic linked this one on another post, is for fading actor, but you can easily convert for a window!

EDIT: Fixed link.
« Last Edit: December 27, 2011, 05:33:52 PM by Mnemonic »
Logged

Spellbreaker

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • View Profile
    • Apeiron Studios
Re: Scripting - Return from a non interactive scene
« Reply #8 on: December 28, 2011, 03:12:32 PM »

Just for Info, there's always the Game.PrevScene which always contains the Name of the last scene, so there shouldn't be the a problem doing a scene change on leftlick.

greets,

spellbreaker
Logged

Ennio

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Posts: 40
    • View Profile
Re: Scripting - Return from a non interactive scene
« Reply #9 on: December 28, 2011, 03:16:46 PM »

Just for Info, there's always the Game.PrevScene which always contains the Name of the last scene, so there shouldn't be the a problem doing a scene change on leftlick.

Yes, but how do you "remind" the prevescene state? Actor position, object state and things like that? PrevScene return only the name of the previous scene
Logged
 

Page created in 0.084 seconds with 24 queries.