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 Piano/Lever Triggers Script
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#1
Piano/Lever Triggers Script

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):

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).

[Image: quote_by_rueppells_fox-d9ciupp.png]
(This post was last modified: 03-05-2013, 01:02 AM by CarnivorousJelly.)
03-05-2013, 12:09 AM
Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#2
RE: Piano/Lever Triggers Script

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:
PHP Code: (Select All)
void Script_BadVision(string &in asParentstring &in asChildint alState
to:
PHP Code: (Select All)
void Script_BadVision(string asEntityint alState
for it to work.

In Ruins [WIP]
(This post was last modified: 03-05-2013, 02:05 AM by NaxEla.)
03-05-2013, 02:04 AM
Find
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#3
RE: Piano/Lever Triggers Script

(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:
PHP Code: (Select All)
void Script_BadVision(string &in asParentstring &in asChildint alState
to:
PHP Code: (Select All)
void Script_BadVision(string asEntityint alState
for it to work.

Works perfectly! Thank you Big Grin

[Image: quote_by_rueppells_fox-d9ciupp.png]
03-05-2013, 11:00 PM
Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#4
RE: Piano/Lever Triggers Script

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.

In Ruins [WIP]
03-05-2013, 11:54 PM
Find




Users browsing this thread: 1 Guest(s)