31
Technical forum / Question on code
« on: February 25, 2004, 04:34:29 PM »Code: [Select]
// fan speed (0-off, 1-normal speed, 2-fast speed)
var EntFan = Scene.GetNode("fan");
if(StateRoom.FanSpeed==0) EntFan.SetSprite("scenes\room\sprites\fan_off.sprite");
else if(StateRoom.FanSpeed==1) EntFan.SetSprite("scenes\room\sprites\fan.sprite");
else EntFan.SetSprite("scenes\room\sprites\fan_fast.sprite");
What's this code for, if there is
Code: [Select]
on "Take"
{
GoToObject();
Game.Interactive = false;
// get the fan entity
var EntFan = Scene.GetNode("fan");
// set the fan etity sprite depending on the state variable
// (0-off, 1-normal, 2-false)
if(StateRoom.FanSpeed==0)
{
actor.Talk("It's turned off. I'll turn it on...");
actor.PlayAnim("actors\molly\ur\take1.sprite");
EntFan.SetSprite("scenes\room\sprites\fan.sprite");
actor.PlayAnim("actors\molly\ur\take2.sprite");
StateRoom.FanSpeed = 1; // save the new fan state
}
else if(StateRoom.FanSpeed==1)
{
actor.Talk("It's running at normal speed. Let's make it spin faster...");
actor.PlayAnim("actors\molly\ur\take1.sprite");
EntFan.SetSprite("scenes\room\sprites\fan_fast.sprite");
actor.PlayAnim("actors\molly\ur\take2.sprite");
StateRoom.FanSpeed = 2;
}
else if(StateRoom.FanSpeed==2)
{
actor.Talk("OK, I'll turn it off.");
actor.PlayAnim("actors\molly\ur\take1.sprite");
EntFan.SetSprite("scenes\room\sprites\fan_off.sprite");
actor.PlayAnim("actors\molly\ur\take2.sprite");
StateRoom.FanSpeed = 0;
}
Game.Interactive = true;
}
in the fan.script?