Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I'm a dumb person.
Author Message
evertuy Offline
Junior Member

Posts: 46
Joined: Mar 2011
Reputation: 0
Post: #1
I'm a dumb person.

I've always had a knack when it comes to map building, but when it comes to scripting, I'm totally lost.

But I decided to give it a go and I got this, and of course it doesn't work, can someone help me fix it so I can understand it? I'm trying to make it so when the player walks it a script area a sound plays.

void OnStart(){
    int GiveLanternOnStart = 0; // Set to 1 to receive a Lantern on start of game
    int TinderboxStartAmount = 0; // Amount of Tinderboxes you receive on start of game
    
    // SetPlayerSanity(100.0f);
    SetPlayerLampOil(0.0f);
        
    SetNumberOfQuestsInMap(1);
    
    AddQuest("Explore","Explore");
    
    PlayMusic("06_amb.ogg", true, 1, 3, 0, true);
    
    SetEntityPlayerInteractCallback("Player","Script1","PlaySound("Sound_1")",true,1);
    }

//if(ScriptDebugOn()){
    }

void OnEnter(){
    }

      void OnLeave(){
    }
(This post was last modified: 03-21-2011 03:29 AM by evertuy.)
03-21-2011 03:27 AM
Find all posts by this user Quote this message in a reply
Tanshaydar Offline
From Beyond

Posts: 3,086
Joined: Mar 2009
Reputation: 66
Post: #2
RE: I'm a dumb person.

You have an interaction callback. Is this what you want? Or you want to make a collide call back, when player enters that script area.

03-21-2011 03:41 AM
Visit this user's website Find all posts by this user Quote this message in a reply
thepaleking Offline
Member

Posts: 93
Joined: Dec 2010
Reputation: 0
Post: #3
RE: I'm a dumb person.

void Func(stuff)
{
    PlaySoundAtEntity(stuff);
}

Void OnStart()
{
     AddEntityCollideCallback(stuff);
}
03-21-2011 03:42 AM
Find all posts by this user Quote this message in a reply
Anxt Offline
Senior Member

Posts: 589
Joined: Mar 2011
Reputation: 10
Post: #4
RE: I'm a dumb person.

As Tanshaydar said, there are multiple ways to call functions. Thepaleking's example is how you would go about making it so a sound plays when a character enters an area.

Check the script functions page for more information, but here's the general format for what you are trying to do:

/*The 1 signifies that the function will be called upon entering the area.  -1 means it will be called upon leaving the area.  0 means both.
*/
void OnStart()
{
   AddEntityCollideCallback("Player", "NameOfArea", "NameOfFunction", "DestroyCallbackOnUse(true or false)", 1);  
}

void NameOfFunction(string &in asParent, string &in asChild, int alState)
{
    PlaySoundAtEntity("soundname", "soundfile", "entity", "fadetime", "savesound")
}

Note that you should probably keep "savesound" as false, because it will loop otherwise. Soundname isn't important, just pick something that no other sound uses.

03-21-2011 04:05 AM
Find all posts by this user Quote this message in a reply
evertuy Offline
Junior Member

Posts: 46
Joined: Mar 2011
Reputation: 0
Post: #5
RE: I'm a dumb person.

(03-21-2011 03:41 AM)Tanshaydar Wrote:  You have an interaction callback. Is this what you want? Or you want to make a collide call back, when player enters that script area.

Yes I want a collide call back so when I enter the area.
Double post sorry, but what does

"NameOfFunction" mean? Or where can I find it?
(This post was last modified: 03-21-2011 04:16 AM by evertuy.)
03-21-2011 04:07 AM
Find all posts by this user Quote this message in a reply
Tanshaydar Offline
From Beyond

Posts: 3,086
Joined: Mar 2009
Reputation: 66
Post: #6
RE: I'm a dumb person.

It is a placeholder. It can be like that, or you can write there "ThisIsAnAwesomeFunctionThatWillBlowYourMind_Version_2" or simply "AreaCollision".
That's something you decide.

(This post was last modified: 03-21-2011 04:29 AM by Tanshaydar.)
03-21-2011 04:28 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: