| 
 Piano/Lever Triggers Script - CarnivorousJelly -  03-05-2013
 
 It appears I'm having a "minor" problem with my script: the game loads fine as the script currently is, but it won't execute "Script_BadVision" when the piano lid is closed.
 
 Here's what I've done (broken script at bottom):
 
 
 Code: void OnStart(){
 AddEntityCollideCallback("Player", "Area_VisionTrigger", "Script_VisionTrigger", false, 0);
 SetLocalVarInt("HasWindPlayed", 0);
 SetLocalVarInt("TimerTriggered", 0);
 SetMultiSliderCallback("piano_1", "Script_BadVision");
 }
 
 void OnEnter()
 {
 
 }
 
 void Script_VisionTrigger (string &in asParent, string &in asChild, int alState)
 {
 if(alState == 1)
 {
 if (GetLocalVarInt("HasWindPlayed") == 0)
 {
 CreateParticleSystemAtEntity("Area_VisionWind", "ps_dust_whirl.ps", "Area_VisionWind", false);
 SetLampLit("candlestick_floor_1", false, true);
 SetLampLit("candle_floor_small_1", false, true);
 PlaySoundAtEntity("blow", "general_wind_whirl", "Player", 0.0f, false);
 SetLocalVarInt("HasWindPlayed", 1);
 }
 
 if (GetLocalVarInt("TimerTriggered") == 0)
 {
 PlayMusic("vision_music", false, 1, 1, 7, false);
 AddTimer("continue_music", 17.962f, "timer_continuemusic");
 }
 }
 if(alState == -1)
 {
 if (GetLocalVarInt("TimerTriggered") == 0)
 {
 StopMusic(3, 7);
 RemoveTimer("continue_music");
 }
 }
 
 }
 
 void timer_continuemusic(string &in asTimer)
 {
 SetLocalVarInt("TimerTriggered", 1);
 AddTimer("violinist", 32.658f, "timer_violinist");
 AddTimer("cellist_i", 83.858f, "timer_firstcellist");
 AddTimer("cellist_ii", 96.001f, "timer_secondcellist");
 AddTimer("cellists_off", 149.000f, "timer_cellistsoff");
 AddTimer("violinist_off", 170.433f, "timer_violinistoff");
 AddTimer("pianist_off", 203.571f, "timer_pianistoff");
 FadeLightTo("Pianist_Light", 1.000f, 0.517f, 0.225f, 0.000f, 1.00f, 0.5f);
 }
 
 ///////Timers that work perfectly/////////
 //////More Stuff//////
 
 void Script_BadVision(string &in asParent, string &in asChild, int alState)
 {
 if (GetLeverState("piano_1") == -1)
 {
 if(GetLocalVarInt("VisionTriggered") == 1)
 {
 StopMusic (3, 7);
 PlaySoundAtEntity("whisper", "insanity_whisper", "Player", 0.0f, false);
 PlaySoundAtEntity("screams", "ui_emotion_stone", "Player", 1.0f, false);
 SetEntityActive("corpse_male_1", true);
 FadeLightTo("Pianist_Light", 0.000f, 0.000f, 0.000f, 0.000f, 0.00f, 1.0f);
 FadeLightTo("Violinist_Light", 0.000f, 0.000f, 0.000f, 0.000f, 0.00f, 1.0f);
 FadeLightTo("Cellist_I_Light", 0.000f, 0.000f, 0.000f, 0.000f, 0.00f, 1.0f);
 FadeLightTo("Cellist_II_Light", 0.000f, 0.000f, 0.000f, 0.000f, 0.00f, 1.0f);
 RemoveTimer("continue_music");
 
 }
 }
 }
 
 void OnLeave()
 {
 
 }
Any suggestions?
 
 Edit: it's not a jump scare (if that changes anything).
 
 
 RE: Piano/Lever Triggers Script - NaxEla -  03-05-2013
 
 Use SetEntityConnectionStateChangeCallback(string& asName, string& asCallback) in stead of SetMultiSliderCallback. The piano entity is of type Lever, so it should work. You'll also need to change this line:
 to:PHP Code: void Script_BadVision(string &in asParent, string &in asChild, int alState) 
for it to work.PHP Code: void Script_BadVision(string asEntity, int alState) 
 
 RE: Piano/Lever Triggers Script - CarnivorousJelly -  03-05-2013
 
 
  (03-05-2013, 02:04 AM)NaxEla Wrote:  Use SetEntityConnectionStateChangeCallback(string& asName, string& asCallback) in stead of SetMultiSliderCallback. The piano entity is of type Lever, so it should work. You'll also need to change this line: to:PHP Code: void Script_BadVision(string &in asParent, string &in asChild, int alState) 
for it to work.PHP Code: void Script_BadVision(string asEntity, int alState) 
 Works perfectly! Thank you
   
 
 RE: Piano/Lever Triggers Script - NaxEla -  03-05-2013
 
 Also i forgot to mention: it will call asCallback when ever the piano opens OR closes. alState will be 1 when the piano opens, and -1 when it closes.
 
 
 
 |