Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Random or Looping
lllDash Offline
Member

Posts: 108
Threads: 12
Joined: Apr 2012
Reputation: 3
#1
Question  Random or Looping

Ive just created lightning for my custom story, now all I need to do is get it to repeat randomly....which I do not know how to do. I'm guessing it could be "RandFloat" but I have not a clue how to implement it. here's the script to the lightning. How would you implement random OR EVEN Looping in this script?




void OnStart()
{
PreloadSound("general_thunder.snt");
SetSkyBoxActive(true);
SetSkyBoxColor(0.05, 0.05, 0.10, 1);
SetLightVisible("SpotLight_1", false);
SetLightVisible("SpotLight_2", false);
SetLightVisible("SpotLight_3", false);
SetLightVisible("SpotLight_4", false);
SetLightVisible("SpotLight_5", false);
SetLightVisible("SpotLight_6", false);
AddTimer("", 3.0f, "flashes");
}
//The many flashes that makes up the lightning. all triggered with "flashes"
void flashes(string &in asTimer)
{
AddTimer("", 0.01f, "flashesOn");
AddTimer("", 0.40f, "flashesOff");
AddTimer("", 0.45f, "flashesOn");
AddTimer("", 0.50f, "flashesOff");
AddTimer("", 0.63f, "flashesOn");
AddTimer("", 0.67f, "flashesOff");
AddTimer("", 0.70f, "flashesOn");
AddTimer("", 0.90f, "flashesOff");
AddTimer("", 1.10f, "Thunder");
}
void Thunder(string &in asTimer)
{
PlayGuiSound("general_thunder.snt" , 1.0f);
}
void flashesOn(string &in asTimer)
{
SetLightVisible("SpotLight_1", true);
SetLightVisible("SpotLight_2", true);
SetLightVisible("SpotLight_3", true);
SetLightVisible("SpotLight_4", true);
SetLightVisible("SpotLight_5", true);
SetLightVisible("SpotLight_6", true);
SetSkyBoxColor(0.5, 0.5, 0.6, 1);
}
void flashesOff(string &in asTimer)
{
SetLightVisible("SpotLight_1", false);
SetLightVisible("SpotLight_2", false);
SetLightVisible("SpotLight_3", false);
SetLightVisible("SpotLight_4", false);
SetLightVisible("SpotLight_5", false);
SetLightVisible("SpotLight_6", false);
SetSkyBoxColor(0.05, 0.05, 0.10, 1);
}
04-27-2012, 09:43 PM
Find
narutohokager Offline
Member

Posts: 149
Threads: 28
Joined: Jan 2011
Reputation: 0
#2
RE: Random or Looping

For RandomFloat I do not know... We should be able to put a name and then use GetLocalVarFloat.
But to use the loops, for all my scripts, I do like her :

void OnStart()
{
PreloadSound("general_thunder.snt");
SetSkyBoxActive(true);
SetSkyBoxColor(0.05, 0.05, 0.10, 1);
SetLightVisible("SpotLight_1", false);
SetLightVisible("SpotLight_2", false);
SetLightVisible("SpotLight_3", false);
SetLightVisible("SpotLight_4", false);
SetLightVisible("SpotLight_5", false);
SetLightVisible("SpotLight_6", false);
AddTimer("", 3.0f, "flashes");
}
//The many flashes that makes up the lightning. all triggered with "flashes"
void flashes(string &in asTimer)
{
AddTimer("", 0.01f, "flashesOn");
AddTimer("", 1.10f, "Thunder");
}
void Thunder(string &in asTimer)
{
PlayGuiSound("general_thunder.snt" , 1.0f);
}
void flashesOn(string &in asTimer)
{
SetLightVisible("SpotLight_1", true);
SetLightVisible("SpotLight_2", true);
SetLightVisible("SpotLight_3", true);
SetLightVisible("SpotLight_4", true);
SetLightVisible("SpotLight_5", true);
SetLightVisible("SpotLight_6", true);
SetSkyBoxColor(0.5, 0.5, 0.6, 1);
AddTimer("", 0.40f, "flashesOff");
}
void flashesOff(string &in asTimer)
{
SetLightVisible("SpotLight_1", false);
SetLightVisible("SpotLight_2", false);
SetLightVisible("SpotLight_3", false);
SetLightVisible("SpotLight_4", false);
SetLightVisible("SpotLight_5", false);
SetLightVisible("SpotLight_6", false);
SetSkyBoxColor(0.05, 0.05, 0.10, 1);
AddTimer("", 0.65f, "flashesOn2");
}
  void flashesOn2(string &in asTimer)
{
SetLightVisible("SpotLight_1", true);
SetLightVisible("SpotLight_2", true);
SetLightVisible("SpotLight_3", true);
SetLightVisible("SpotLight_4", true);
SetLightVisible("SpotLight_5", true);
SetLightVisible("SpotLight_6", true);
SetSkyBoxColor(0.5, 0.5, 0.6, 1);
AddTimer("", 0.40f, "flashesOff2");
}
  void flashesOff2(string &in asTimer)
{
SetLightVisible("SpotLight_1", false);
SetLightVisible("SpotLight_2", false);
SetLightVisible("SpotLight_3", false);
SetLightVisible("SpotLight_4", false);
SetLightVisible("SpotLight_5", false);
SetLightVisible("SpotLight_6", false);
SetSkyBoxColor(0.05, 0.05, 0.10, 1);
AddTimer("", 0.01f, "flashesOn");
}
In short: At start, he play FlashLightOn, after, FlashLightOff, after, FlashLightOn2, after, FlashLightOff2, And here, his back to the first FlashLightOn, Normally it will play forever Wink
Modifies or adds FlashLightOn / Off to vary the timer





Sorry for my bad english
Amnesia The Revenge - Chapter 1
04-27-2012, 10:02 PM
Website Find
lllDash Offline
Member

Posts: 108
Threads: 12
Joined: Apr 2012
Reputation: 3
#3
RE: Random or Looping

Thanks narutohokager. I feel like an idiot. It never occurred to me that, in order to make the lightning loop, I would have to create a literal loop in the script itself. With that knowledge, I found a shorter way of doing it which would make it easier to create variations with just a single line of code.




AddTimer("", 0.1f, "flashSequence"); //loop start
}
void flashSequence(string &in asTimer)
{
AddTimer("", 5.0f, "flashes"); //I can add as many of these as I want Tongue
AddTimer("", 10.0f, "flashLoop");
}
void flashLoop(string &in asTimer)

{
AddTimer("", 0.1f, "flashSequence"); //loop end
}



Thanks again. Big Grin
04-27-2012, 11:10 PM
Find
narutohokager Offline
Member

Posts: 149
Threads: 28
Joined: Jan 2011
Reputation: 0
#4
RE: Random or Looping

No problem. Wink Dont hesitate to come back if you have another problem Big Grin

Sorry for my bad english
Amnesia The Revenge - Chapter 1
04-28-2012, 12:23 AM
Website Find




Users browsing this thread: 1 Guest(s)