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

Privacy Policy


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help a funtion with the same name and parameter already exists
Author Message
chweaw Offline
Junior Member

Posts: 4
Joined: Apr 2012
Reputation: 0
Post: #1
a funtion with the same name and parameter already exists
Ok hi! I know you hear this a lot but I am new to the whole making of customstories and Im not good with scripting. I tried to read some about it but i get dizzy and get headaches so I figured you guys might help me and teach me a thing about this problem of mine.
So what I have done is that I have created an area that closes a door behind me on collision and what I wanted to do next was to make a sound play as i enter the new room.

Script as it looks like so far:


////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true);
}


void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "Unlock_door", "door_1", 0, false);
RemoveItem("keyl_1");
}

void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "DoorCloseFunc1" , true , 1);
}
void DoorCloseFunc1(string &in asParent , string &in asChild , int alState)
{
SetSwingDoorClosed("door_1", true, true);
}

void OnStart()
{
PreloadSound("00_laugh.snt");
AddEntityCollideCallback("Player", "ScriptArea_1", "Sound", true, 1);
}


void Sound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sound", "00_laugh.snt", "ScriptArea_1", 0.0, false);
}
////////////////////////////
// Run when leaving map
void OnLeave()
{

}
I get the error 21,1 : a funtion with the same name and parameter already exists


So what should I do? I want to learn more.
04-24-2012 11:19 PM
Find all posts by this user Quote this message in a reply
Your Computer Offline
SCAN ME!

Posts: 3,268
Joined: Jul 2011
Reputation: 223
Post: #2
RE: a funtion with the same name and parameter already exists
(04-24-2012 11:19 PM)chweaw Wrote:  I want to learn more.

Then do research on function overloading.

Tutorials: From Noob to Pro
04-24-2012 11:20 PM
Visit this user's website Find all posts by this user Quote this message in a reply
chweaw Offline
Junior Member

Posts: 4
Joined: Apr 2012
Reputation: 0
Post: #3
RE: a funtion with the same name and parameter already exists
(04-24-2012 11:20 PM)Your Computer Wrote:  
(04-24-2012 11:19 PM)chweaw Wrote:  I want to learn more.

Then do research on function overloading.
Ok, just need the keywords to search and I will Smile thx
(04-24-2012 11:20 PM)Your Computer Wrote:  
(04-24-2012 11:19 PM)chweaw Wrote:  I want to learn more.

Then do research on function overloading.
You might just think I'm lazy but man, I do not understand how to get this working! could you please just tell me and why so that i can fix my future problems?
(This post was last modified: 04-24-2012 11:43 PM by chweaw.)
04-24-2012 11:31 PM
Find all posts by this user Quote this message in a reply
Your Computer Offline
SCAN ME!

Posts: 3,268
Joined: Jul 2011
Reputation: 223
Post: #4
RE: a funtion with the same name and parameter already exists
(04-24-2012 11:31 PM)chweaw Wrote:  You might just think I'm lazy but man, I do not understand how to get this working! could you please just tell me and why so that i can fix my future problems?

You have two void OnStart() functions. You can only have one.

Tutorials: From Noob to Pro
04-24-2012 11:57 PM
Visit this user's website Find all posts by this user Quote this message in a reply
TeamSD Offline
Member

Posts: 50
Joined: Apr 2012
Reputation: 2
Post: #5
RE: a funtion with the same name and parameter already exists
Here you go. This should do the trick! Smile

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "DoorCloseFunc1" , true , 1);
PreloadSound("00_laugh.snt");
AddEntityCollideCallback("Player", "ScriptArea_1", "Sound", true, 1);
}


void DoorCloseFunc1(string &in asParent , string &in asChild , int alState)
{
SetSwingDoorClosed("door_1", true, true);
}

void Sound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sound", "00_laugh.snt", "ScriptArea_1", 0.0, false);
}

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true);
}


void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "Unlock_door", "door_1", 0, false);
RemoveItem("keyl_1");
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

04-25-2012 12:19 PM
Find all posts by this user Quote this message in a reply
chweaw Offline
Junior Member

Posts: 4
Joined: Apr 2012
Reputation: 0
Post: #6
RE: a funtion with the same name and parameter already exists
(04-24-2012 11:57 PM)Your Computer Wrote:  
(04-24-2012 11:31 PM)chweaw Wrote:  You might just think I'm lazy but man, I do not understand how to get this working! could you please just tell me and why so that i can fix my future problems?

You have two void OnStart() functions. You can only have one.
But lets say that i have a series of functions that uses the same name, what do i do to make it work? not having multiple void OnStart() functions?
thanks for the help btw
04-25-2012 04:06 PM
Find all posts by this user Quote this message in a reply
SilentStriker Offline
Posting Freak

Posts: 939
Joined: Jul 2011
Reputation: 39
Post: #7
RE: a funtion with the same name and parameter already exists
btw, Callbacks should be in OnStart since usually you only want the callbacks to happen the first time you enter the map Smile if it's on enter it calls every time you enter the map

04-25-2012 04:09 PM
Find all posts by this user Quote this message in a reply
chweaw Offline
Junior Member

Posts: 4
Joined: Apr 2012
Reputation: 0
Post: #8
RE: a funtion with the same name and parameter already exists
(04-25-2012 12:19 PM)TeamSD Wrote:  Here you go. This should do the trick! Smile

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "DoorCloseFunc1" , true , 1);
PreloadSound("00_laugh.snt");
AddEntityCollideCallback("Player", "ScriptArea_1", "Sound", true, 1);
}


void DoorCloseFunc1(string &in asParent , string &in asChild , int alState)
{
SetSwingDoorClosed("door_1", true, true);
}

void Sound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sound", "00_laugh.snt", "ScriptArea_1", 0.0, false);
}

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true);
}


void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "Unlock_door", "door_1", 0, false);
RemoveItem("keyl_1");
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}
Thank you! i really appreciate the help Blush
04-25-2012 04:10 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)