09-19-2010, 10:05 PM
Hey.
I made a basic map and I wanted to have a locked door and a key to open it with. So I have a door entity called "door_1" and a key entity called "key_1". And from what information I could gather, I need to create a "mapname.hps" file, where I add the script that makes this possible.
Since I'm not familiar with this kinda of scripting, I read a few threads and I came up with this:
mapname.hps
So when I use the key on the door, the key get removed, but the door does not get unlocked. Some help would be appreciated!
I made a basic map and I wanted to have a locked door and a key to open it with. So I have a door entity called "door_1" and a key entity called "key_1". And from what information I could gather, I need to create a "mapname.hps" file, where I add the script that makes this possible.
Since I'm not familiar with this kinda of scripting, I read a few threads and I came up with this:
mapname.hps
Code:
void UseKey(string &in asItem, string &in asEntity){
// Set the entity(desk or door) to unlocked
SetSwingDoorLocked(asEntity, false, true);
// Remove the item used from the inventory
RemoveItem(asItem);
}
void OnStart(){
//Add the Lantern and 10 Tinderboxes when in Debug mode, always good to have light!
if(ScriptDebugOn()){
GiveItemFromFile("lantern", "lantern.ent");
for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
}
AddUseItemCallback("useexit", "key_1", "door_1", "UseKey",true);
}
So when I use the key on the door, the key get removed, but the door does not get unlocked. Some help would be appreciated!