Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Mikael on March 14, 2007, 01:44:53 PM

Title: Entity connected to variable
Post by: Mikael on March 14, 2007, 01:44:53 PM
I just need a quick explanation of how I make entity xxx visible only when variable yyy has the value of 1.

Thanks!

Regards,

Mikael
Title: Re: Entity connected to variable
Post by: fireside on March 14, 2007, 02:02:09 PM

var ent = Scene.GetNode("xxx");
if(yyy) ent.Active = true;
else ent.Active = false;
Title: Re: Entity connected to variable
Post by: Mikael on March 14, 2007, 05:30:43 PM
Thanks, but if I change the value of the variable in the same scene as the entity that is supposed to become visible, I have to go to another scene, and re-enter the scene with the entity before the entity gets visible.

Regards,

Mikael
Title: Re: Entity connected to variable
Post by: TheDerman on March 14, 2007, 06:58:18 PM
It depends how and when you want to do it. The only script that runs in a loop normally is game_daemon.script.

All other scripts only run once when you tell them to. So, setting the variable to 1 won't change the entity because there is nothing that is checking the variable. Hope that makes sense.

Sounds like you're checking the variable in scene_init.script, which only runs when you first enter the scene.

So, for example, if you wanted to left click on something, and then make the entity visible only if the variable is 1, you'd do this:

on "LeftClick"
 {
  var ent = Scene.GetNode("xxx");
  if(yyy==1) ent.Active = true;
 }

Then it will become visible when you left click. You can set the variable in any other script that you like.
Title: Re: Entity connected to variable
Post by: Mikael on March 15, 2007, 12:50:06 AM
I would never have figured that out for myself. It works now. Thanks Fireside and TheDerman!

Regards,

Mikael