Frictional Games Forum (read-only)
[SCRIPT] Error trying to run map - 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: [SCRIPT] Error trying to run map (/thread-14697.html)

Pages: 1 2


Error trying to run map - Macetrow - 04-11-2012

Hey, trying to make my own map for the first time and i've run into some error once i started to make it a bit more complicated.
1: I want my key (key_1) to activate a monster
2: I want that key to unlock a door (door_1)
3: I want to set a patrolnode for that monster once i activate it
(Optinal)4: if anyone could also assist me with how to changemap once i've opened the last door that would be great.
I'm deeply grateful for any assistance since i'm a noob and all!

I'm getting an error message which says:
[Image: scripterror.png]

This is my script so far:

////////////////////////
//Run when starting map
void OnStart()
{
SetEntityPlayerInteractCallBack("key_1", "ActivateMonster", true);
}
////////////////////////
//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("key_1");
}
void ActivateMonster(string &in item)
{
SetEntityActive("monster_1", true);
AddEnemyPatrolNode("monster_1", "PathNodeArea_1", 0, "idle");
AddEnemyPatrolNode("monster_1", "PathNodeArea_2", 0, "idle");
}
////////////////////////
//Run when leaving map
void OnLeave()
{

}



RE: Error trying to run map - ClayPigeon - 04-11-2012

The capital 'B' is misplaced.
SetEntityPlayerInteractCallback

As you see, the 'b' is non-capital.


RE: Error trying to run map - Macetrow - 04-11-2012

Thanks for the reply, that fixed the first part of the error message.
I'm still getting "main (10,59): ERR : Expected identifier" thou.

Any idea what that could be?


RE: Error trying to run map - ClayPigeon - 04-11-2012

AddUseItemCallback("","key_1","door_1","UsedKeyOnDoor". true);


There's a '.' where there should be a comma.


AddUseItemCallback("","key_1","door_1","UsedKeyOnDoor", true);



RE: Error trying to run map - Macetrow - 04-11-2012

Thank you so much, that fixed it!

But my key doesn't activate the monster also it doesn't open my locked door, do you know why?


RE: Error trying to run map - ClayPigeon - 04-11-2012

Firstly, the addition of the patrol nodes should be on OnStart/OnEnter.

Code:
void OnStart()
{    
    AddEnemyPatrolNode("monster_1", "PathNodeArea_1", 0, "idle");
    AddEnemyPatrolNode("monster_1", "PathNodeArea_2", 0, "idle");
}

And I think the player cannot interact a pickable item so 'ActivateMonster' is not called!

A valid usage would be:

Code:
void OnStart()
{        
    SetEntityCallbackFunc("key_1", "ActivateMonster");
}

void ActivateMonster(string &in asEntity, string &in type)
{        
    if(type == "OnPickup")        
    {            
        SetEntityActive("monster_1", true);        
    }
}



RE: Error trying to run map - Macetrow - 04-11-2012

Hmm i did change it to this, not sure if this is what you meant, but it's not working. Also for some reason the key or the door does not have a name.
Any idea what i managed to screw up? I'm such a noob lol

////////////////////////
//Run when starting map
void OnStart()
{
SetEntityCallbackFunc("key_1", "ActivateMonster");
}

void ActivateMonster(string &in asEntity, string &in type)
{
if(type == "OnPickup")
{
SetEntityActive("monster_1", true);
}
}
////////////////////////
//Run when entering map
void OnEnter()
{
AddUseItemCallback("","key_1","door_1","UsedKeyOnDoor", true);
AddEnemyPatrolNode("monster_1", "PathNodeArea_1", 0, "idle");
AddEnemyPatrolNode("monster_1", "PathNodeArea_2", 0, "idle");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
RemoveItem("key_1");
}

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

}


RE: Error trying to run map - ClayPigeon - 04-11-2012

Are you sure all of the names are correct?
And to change the inventory name you need to set the SubItemName in the level editor to some thing, like TEST for example and then add this in your extra_english.lang:


<CATEGORY Name="Inventory">

<Entry Name="ItemName_TEST">The name of the key.</Entry>
<Entry Name="ItemDesc_TEST">The description of the key.</Entry>


</CATEGORY>


RE: Error trying to run map - Macetrow - 04-11-2012

Ahh, i see. Give me a min and i'll try it.
Hmm i did change it to this, also removed the "_1" in the key, monster and door incase that was screwing it up somehow. Yet i still can't see the name of the key/door and the monster doesn't activate when i touch the key.

PS: The story's description is gone.
<LANGUAGE>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">
You start Martin's journey into what seems to be a never ending nightmare!
</Entry>
</CATEGORY>
<CATEGORY Name="Inventory">
<Entry Name="ItemName_key">Hallway Key.</Entry>
<Entry Name="ItemDesc_key">This is the key to the door at the end of the hall.</Entry>
</CATGEROY>
</LANGUAGE>



RE: Error trying to run map - ClayPigeon - 04-11-2012

I am really not getting why the key doesn't activate the monster Confused
As for the names, read "THE ITEM" part of the tutorial:

http://wiki.frictionalgames.com/hpl2/tutorials/script/scripting_by_xtron_-_item_that_unlocks_a_door#the_item