Frictional Games Forum (read-only)
Problem with scripts for level editor,please help. - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Problem with scripts for level editor,please help. (/thread-26333.html)



Problem with scripts for level editor,please help. - ezra627 - 09-25-2014

Guys AHHHH GODDD!!!This script is confusing me,how to use this line to make level doors work?My key says when it is used "No object to use item on!"
void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked("Key1", "Doorlvl1");
}AngryExclamationHuhDodgy


RE: Problem with scripts for level editor,please help. - Mudbill - 09-25-2014

Did you add the UseItem callback for the key and door?


RE: Problem with scripts for level editor,please help. - FlawlessHappiness - 09-25-2014

Also:
The script line you're using should be used like this:

PHP Code:
SetLevelDoorLocked("NameOfDoor"false); 
You put false or true in there to make the door unlocked or locked.

So in your case:
PHP Code:
void UseKeyOnDoor(string &in asItemstring &in asEntity)
{
SetLevelDoorLocked("Doorlvl1"false);


You already had the parameters right! That's great!
But if you only have what you just wrote (Which I'm going to assume since you didn't write anything else)
then you're gonna need a void OnStart()

In this void OnStart() you're gonna use (as Mudbill said) an AddUseItemCallback.

It looks like this:
PHP Code:
AddUseItemCallback(stringasNamestringasItemstringasEntitystringasFunctionbool abAutoDestroy); 

So with your setup it will look like this:

PHP Code:
void OnStart()
{
AddUseItemCallback("""Key1" "Doorlvl1""UseKeyOnDoor"false);


Remember, if you already have a void OnStart(), don't just copy mine and paste it in your script. You cannot have 2 void OnStart()! THen just copy the script line, AddUseItemCallback, and put it in your void OnStart()


RE: Problem with scripts for level editor,please help. - Viper85626 - 09-26-2014

Flawless pretty much got it. Just relax and follow his instruction. It'll work. Good luck! Smile