08-17-2012, 01:50 AM
Hello everybody! I have a question about Scripting. I actually started doing this less than a week ago, so I know nothing. Anyways, I am making little maps for me learn the basics of Scripting. My first map was called "ScriptTest" which was learning how to do Journal Entries, which I managed to learn. Now, I made a map called "ScriptTest2", and I'm using this map to figure out how to unlock doors. And I'm stuck. I was wondering if anybody could look at these functions and see if they're correct or if I did something wrong? I got the key name and description down correctly. But the unlocking the door part..?
The key's CustomSubItemTypeName is "Key1" and the actual name is just "Key_1", and the door's name is "LockedDoor1"
extra_english.lang file:
<LANGUAGE>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">Just a description.</Entry>
</CATEGORY>
<CATEGORY Name="Journal">
<Entry Name="Note_Test01_Name">Mysterious Note</Entry>
<Entry Name="Note_Test01_Text">How did you get here, you're probably wondering. You will never escape.</Entry>
</CATEGORY>
<CATEGORY Name="Inventory">
<Entry Name="ItemDesc_Key1">A simple key</Entry>
<Entry Name="ItemName_Key1">A key to unlock a nearby door</Entry>
</CATEGORY>
</LANGUAGE>
------------------------------------------
ScriptTest2.hps file:
////////////////////////////
// Run when the map starts
void OnStart()
{
AddUseItemCallback("", "Key1", "LockedDoor1", "UsedKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor1", false, true);
PlaySoundAtEntity("", "unlock_door", "LockedDoor1", 0, false);
RemoveItem("Key1");
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
---------------------------
Whenever I test play it, it says that I can't use the item on anything when I go up to the door.
The key's CustomSubItemTypeName is "Key1" and the actual name is just "Key_1", and the door's name is "LockedDoor1"
extra_english.lang file:
<LANGUAGE>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">Just a description.</Entry>
</CATEGORY>
<CATEGORY Name="Journal">
<Entry Name="Note_Test01_Name">Mysterious Note</Entry>
<Entry Name="Note_Test01_Text">How did you get here, you're probably wondering. You will never escape.</Entry>
</CATEGORY>
<CATEGORY Name="Inventory">
<Entry Name="ItemDesc_Key1">A simple key</Entry>
<Entry Name="ItemName_Key1">A key to unlock a nearby door</Entry>
</CATEGORY>
</LANGUAGE>
------------------------------------------
ScriptTest2.hps file:
////////////////////////////
// Run when the map starts
void OnStart()
{
AddUseItemCallback("", "Key1", "LockedDoor1", "UsedKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor1", false, true);
PlaySoundAtEntity("", "unlock_door", "LockedDoor1", 0, false);
RemoveItem("Key1");
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
---------------------------
Whenever I test play it, it says that I can't use the item on anything when I go up to the door.