Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Entity connected to variable  (Read 1810 times)

0 Members and 1 Guest are viewing this topic.

Mikael

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 127
    • View Profile
    • MDNA Games
Entity connected to variable
« 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
« Last Edit: March 14, 2007, 01:46:35 PM by Mikael »
Logged

fireside

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 211
    • View Profile
Re: Entity connected to variable
« Reply #1 on: March 14, 2007, 02:02:09 PM »


var ent = Scene.GetNode("xxx");
if(yyy) ent.Active = true;
else ent.Active = false;
Logged

Mikael

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 127
    • View Profile
    • MDNA Games
Re: Entity connected to variable
« Reply #2 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
Logged

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Entity connected to variable
« Reply #3 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.
« Last Edit: March 14, 2007, 06:59:50 PM by TheDerman »
Logged

Mikael

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 127
    • View Profile
    • MDNA Games
Re: Entity connected to variable
« Reply #4 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
Logged
 

Page created in 0.026 seconds with 23 queries.