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
Problem
maitalr Offline
Junior Member

Posts: 16
Threads: 3
Joined: May 2012
Reputation: 0
#1
Problem

I just started to develop a game, and I'm trying to use scrip. I made a simple thing - open door.
The key's name: key_1. The door's name: Door_3
And it doesn't work! where is the mistake? :



////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key_1", "Door_3", "UsedKeyOnDoor", true);
void MyFunc(string &in asItem, string &in asEntity)
SetSwingDoorLocked(Door_3, false, true);
PlaySoundAtEntity("", "unlock_door", "Door_3", 0, "false");
RemoveItem(key1);
}

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

}


THANK YOU!
05-08-2012, 02:10 PM
Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#2
RE: Problem

(05-08-2012, 02:10 PM)maitalr Wrote: I just started to develop a game, and I'm trying to use scrip. I made a simple thing - open door.
The key's name: key_1. The door's name: Door_3
And it doesn't work! where is the mistake? :



////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key_1", "Door_3", "UsedKeyOnDoor", true);
void MyFunc(string &in asItem, string &in asEntity)
SetSwingDoorLocked(Door_3, false, true);
PlaySoundAtEntity("", "unlock_door", "Door_3", 0, "false");
RemoveItem(key1);
}

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

}


THANK YOU!
What's this doing here?
void MyFunc(string &in asItem, string &in asEntity)

Also, put double-quotes around key1 on the last line.

Edit:
Of course, what you want is probably something like this:
////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key_1", "Door_3", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Door_3", false, true);
PlaySoundAtEntity("", "unlock_door", "Door_3", 0, "false");
RemoveItem("key1");
}

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

}

Noob scripting tutorial: From Noob to Pro

(This post was last modified: 05-08-2012, 02:18 PM by Cranky Old Man.)
05-08-2012, 02:15 PM
Find
darkadders Offline
Junior Member

Posts: 44
Threads: 1
Joined: Mar 2012
Reputation: 3
#3
RE: Problem

ill try fixing it for ya:


void OnStart()
{
AddUseItemCallback("", "key_1", "Door_3", "UsedKeyOnDoor", true);
}


void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Door_3", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "Door_3", 0, false);
RemoveItem("key_1");
}





WHAT I DID (along with some unrelated tutorial information on further development.)




I basically changed the script from void OnEnter to void OnStart.

Also, i added a function for your AddUseItemCallback. so when you use the item on the AddUseItemCallback, it will call the function of UsedKeyOnDoor, which: unlocks the door, plays the sound "unlock_door.snt" and removes the key item from your inventory

i also added some ""s here and there where theyre needed. true's and false's dont need "".

and i also changed some typos in your item names.



REMEMBER: you need to have a filetype for your sound which you want played.

the default filetypes of both sounds and music in amnesia is .ogg

a SOUND uses .snt files
MUSIC uses .ogg files

if you want a quick tutorial on filetypes, click the spoilerbutton below, if interested.

Spoiler below!

a .SNT file is a file which tells the script what sounds which are to be played.

example: lets say i have 6 sounds named "MYSOUND_1.ogg", "MYSOUND_2.ogg", "MYSOUND_3.ogg", "MYSOUND_4.ogg", "MYSOUND_5.ogg"
and "MYSOUND_6.ogg".

id probably want these sounds to play at random, to add some realism to the sounds (when you hit something, it doesnt make the same sound all the time, it maks a variety of sounds), so i make a .snt file for these sounds, named MYSOUND.snt

i open another .snt made already, and i copy its contents and paste it into mine. i customise the names of the sounds being played from "whatever_sounds_its_told_to_play_at_random" to "MYSOUND_1,2,3,4,5,6"

this will tell the game to play the MYSOUND sounds at random.

music doesnt need a .snt file to be played. to play music you just copy the script from the list on the wiki and type in the music name, with a .ogg filetype.


this script can be copied from my post if you wish. it should be functioning now.
Just remember what ive typed here, and i hope you'll learn from the things i have done and explained.


good luck on your story ^^

*insert creative signature here*
(This post was last modified: 05-08-2012, 02:59 PM by darkadders.)
05-08-2012, 02:32 PM
Find
Traggey Offline
is mildly amused

Posts: 3,257
Threads: 74
Joined: Feb 2012
Reputation: 185
#4
RE: Problem

Wrong forum, I've moved this to the support section.
05-08-2012, 03:07 PM
Find
maitalr Offline
Junior Member

Posts: 16
Threads: 3
Joined: May 2012
Reputation: 0
#5
RE: Problem

It doesn't make any sense! Its not working! both ways! What i'm doing WRONG?
05-08-2012, 03:16 PM
Find
darkadders Offline
Junior Member

Posts: 44
Threads: 1
Joined: Mar 2012
Reputation: 3
#6
RE: Problem

(05-08-2012, 03:16 PM)maitalr Wrote: It doesn't make any sense! Its not working! both ways! What i'm doing WRONG?
tell me the error youre recieving when you run your map.

*insert creative signature here*
05-08-2012, 03:19 PM
Find
maitalr Offline
Junior Member

Posts: 16
Threads: 3
Joined: May 2012
Reputation: 0
#7
RE: Problem

Everything works well. But when I try to open the door with the key, it does not open
05-08-2012, 03:31 PM
Find
darkadders Offline
Junior Member

Posts: 44
Threads: 1
Joined: Mar 2012
Reputation: 3
#8
RE: Problem

(05-08-2012, 03:31 PM)maitalr Wrote: Everything works well. But when I try to open the door with the key, it does not open
so its still locked after you use the key on it?

*insert creative signature here*
05-08-2012, 04:08 PM
Find
Datguy5 Offline
Senior Member

Posts: 629
Threads: 25
Joined: Dec 2011
Reputation: 12
#9
RE: Problem

I dont think this affects much,but change this PlaySoundAtEntity("", "unlock_door.snt", "Door_3", 0, false); to
PlaySoundAtEntity("", "unlock_door", "Door_3", 0, false);
I just removed the snt from the end.Thats how its in my script and it works fine.Can you show us the whole script(if it has something else).

Also check the names in the level editor.

(05-08-2012, 04:08 PM)DarkShadowz Wrote:
(05-08-2012, 03:31 PM)maitalr Wrote: Everything works well. But when I try to open the door with the key, it does not open
so its still locked after you use the key on it?

I think he means that when he tries to use the key on the door,it says cannot use item this way.

(This post was last modified: 05-08-2012, 04:29 PM by Datguy5.)
05-08-2012, 04:26 PM
Find
maitalr Offline
Junior Member

Posts: 16
Threads: 3
Joined: May 2012
Reputation: 0
#10
RE: Problem

(05-08-2012, 04:08 PM)DarkShadowz Wrote:
(05-08-2012, 03:31 PM)maitalr Wrote: Everything works well. But when I try to open the door with the key, it does not open
so its still locked after you use the key on it?
Yes. its still locked and it say "you cannot use this item that way//.."
(05-08-2012, 04:26 PM)Datguy5 Wrote: I dont think this affects much,but change this PlaySoundAtEntity("", "unlock_door.snt", "Door_3", 0, false); to
PlaySoundAtEntity("", "unlock_door", "Door_3", 0, false);
I just removed the snt from the end.Thats how its in my script and it works fine.Can you show us the whole script(if it has something else).

Also check the names in the level editor.

(05-08-2012, 04:08 PM)DarkShadowz Wrote:
(05-08-2012, 03:31 PM)maitalr Wrote: Everything works well. But when I try to open the door with the key, it does not open
so its still locked after you use the key on it?

I think he means that when he tries to use the key on the door,it says cannot use item this way.

Tried. it didn't work. and i checked the names again.
there isn't. that's the whole script.
I have no idea what i'm doing wrong
and you all probable have no idea what i want
05-08-2012, 05:06 PM
Find




Users browsing this thread: 2 Guest(s)