Frictional Games Forum (read-only)

Full Version: Some beginner help, door
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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!
I would help you, except that I can't get the editor working... :\ Help me please.
I tried your script and it works for me.
Are you sure you called the door "door_1" in the editor?
Entity names are case sensitive.
I have checked tons of times, my entities are called that. Perhaps I should mention that I use a level door, but that should work the same, should it not?
I wasn't expecting to release my videos before I had made a few more.

But I'll make an exception Tongue Here's one: http://hpl2.frictionalgames.com/wiki:user:mulledk19
(09-20-2010, 12:38 AM)grenadecx Wrote: [ -> ]I have checked tons of times, my entities are called that. Perhaps I should mention that I use a level door, but that should work the same, should it not?

Yes you should, that actually is the problem.
The level door isn't a swing door. =/

You have to use
Code:
SetLevelDoorLocked(door_1, false);
or
Code:
SetLevelDoorLocked(asEntity, false);
instead.
Oh, how dumb someone can be Blush

Thanks, all of you!
(09-20-2010, 12:41 AM)MulleDK19 Wrote: [ -> ]I wasn't expecting to release my videos before I had made a few more.

But I'll make an exception Tongue Here's one: http://hpl2.frictionalgames.com/wiki:user:mulledk19

you asked for feedback after the tutorial.
You explain quite well and it's sounds easy to do -if a bit hard to follow at first.
I have not tried that yet but it looks fairly straightforward, it shows how to do it - but a bit hurried. so I'll be re-winding and pausing a lot.
it'll really help if you keep reminding us, when using the keyboard, what keys are being used to help navigation and shortcuts.
Am looking forward to more.
(09-20-2010, 09:43 AM)Jinix Wrote: [ -> ]
(09-20-2010, 12:41 AM)MulleDK19 Wrote: [ -> ]I wasn't expecting to release my videos before I had made a few more.

But I'll make an exception Tongue Here's one: http://hpl2.frictionalgames.com/wiki:user:mulledk19

you asked for feedback after the tutorial.
You explain quite well and it's sounds easy to do -if a bit hard to follow at first.
I have not tried that yet but it looks fairly straightforward, it shows how to do it - but a bit hurried. so I'll be re-winding and pausing a lot.
it'll really help if you keep reminding us, when using the keyboard, what keys are being used to help navigation and shortcuts.
Am looking forward to more.

Thanks for the feedback. I'll keep that in mind Smile
Yeah, great tutorial MulleDK19! That helped me out a ton!