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: Interactive Code Problem  (Read 3901 times)

0 Members and 1 Guest are viewing this topic.

Darryl

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 4
    • View Profile
Interactive Code Problem
« on: June 24, 2015, 10:28:06 PM »

Hi Dear Friends,
I Have amazing problem with "Interactive" code,
Please help me.
But problem:
In scene after left click on Region , I write : this.Interactive=false;
And interactive be false,
But when I go to another scene and come back to scene , interactive don't work and its be true;
In other word this.interactive=false; only work until we are in scene and if we go to another scene and come back , its don't work.!!
I look forward to hear from you.
Best Regards.
Logged

binary1

  • Supporter
  • Occasional poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 51
    • View Profile
Re: Interactive Code Problem
« Reply #1 on: June 24, 2015, 11:13:38 PM »

I'm not sure exactly what you mean.  When you click on the region, are you making the region non-interactive?  You could try using the name of the structures as in myRegion.interactive = false; 

If everything resets when you come back in, you could set a global flag something like global canInteract = true; in the game.script.  Then, when you click on the region:

on "LeftClick"
{
  canInteract = false;
  this.Interactive = false;
}

In the init method for the scene, check the flag
if (canInteract == false)
{
   myRegion.Interactive = false;
}

else
{
  myRegion.Interactive = true;
}

I'm not sure if that's what you are looking for.
Logged

Dan Peach

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 100
    • View Profile
    • Viperante - Game Development
Re: Interactive Code Problem
« Reply #2 on: June 26, 2015, 01:26:18 AM »

I think in scene properties, you need to make sure "remember node states" is checked.  If it isn't, the scene will load the initial states each time the scene is loaded.

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: Interactive Code Problem
« Reply #3 on: June 28, 2015, 12:10:03 PM »

Hi Darryl, welcome to the forum.

Dan Peach has provided one solution below. Indeed, "Remember node states" will make sure that the engine remembers changes you made to nodes in scenes.

Alternatively you can use the scene_init.script to achieve this.

Code: WME Script
  1. ////////////////////////////////////////////////////////////////////////////////
  2. // scene state
  3. global StateScene;
  4.  
  5.  
  6. // default values
  7. if(StateScene == null)
  8. {
  9.         StateScene.RegionInteractive = true;
  10. }
  11.  
  12. if(StateScene.LetterHotspotVisible){
  13.         var node = Scene.GetNode("region_name");
  14.         node.Interactive = StateScene.RegionInteractive;
  15. }
  16.  

Then, inside the script of the region:

Code: WME Script
  1. on "LeftClick"
  2. {
  3.         var node = Scene.GetNode("region_name");
  4.         node.Interactive = false;
  5.         StateScene.RegionInteractive = false;
  6. }
  7.  

This way, you have the node state inside a global variable. Every time you re-enter the scene, the code in scene_init will run and set Interactive to false. Hope this helps.
Logged
 

Page created in 0.025 seconds with 25 queries.