Frictional Games Forum (read-only)

Full Version: Сode
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
hi all C: how can I make code lock?._. (player must enter the code to open door)
Enter the code how?
(02-23-2013, 11:42 AM)MulleDK19 Wrote: [ -> ]Enter the code how?

I think he meant inputting a code, then a door unlocks. Just like in Penumbra: Overture.
(02-23-2013, 11:46 AM)JustAnotherPlayer Wrote: [ -> ]
(02-23-2013, 11:42 AM)MulleDK19 Wrote: [ -> ]Enter the code how?

I think he meant inputting a code, then a door unlocks. Just like in Penumbra: Overture.

I know. But with what? There are no keypads in Amnesia. So does he have his own keypad, or does he want to use levers, or wheels?
It's a little advanced puzzle.

You will firstly need a model with the numbers.
Then cover each number in a script area, and create the code from with interaction callbacks.

You will be needing variables and if-statements.

When you know how the script functions work, you should be able to script it yourself
(02-23-2013, 11:48 AM)BeeKayK Wrote: [ -> ]It's a little advanced puzzle.

You will firstly need a model with the numbers.
Then cover each number in a script area, and create the code from with interaction callbacks.

You will be needing variables and if-statements.

When you know how the script functions work, you should be able to script it yourself

I don't understand theese "if" anyway there will be 9 buttuns ._. from amnesia
buttuns pls

dnalange made something seemed, this is the thread:

http://www.frictionalgames.com/forum/thread-19588.html

As you can see, it's quite complicated, but he finally got it working.
yeah, use buttons, you can scale them down if you want to so that'll be good. I would probably try using this and somehow figure out the rest of it. I remember seeing a tutorial somewhere about opening a door with multiple levers so it should be fairly easy.
(02-23-2013, 12:51 PM)The chaser Wrote: [ -> ]buttuns pls

dnalange made something seemed, this is the thread:

http://www.frictionalgames.com/forum/thread-19588.html

As you can see, it's quite complicated, but he finally got it working.

Fuck me. He needs a scripting course.

I made this once. Doesn't fill more than 30 lines.
I made a code for this a while ago... let me see if I still have it.

EDIT: Ok found it. This code will work if the script areas are called PressButton_1, PressButton_2, PressButton_3, etc... If you want to change the password, just change the number at the very top of the script.

PHP Code:
const string correctCode "6274";
string playersGuessedCode "";

void OnStart(){}

void OnEnter()
{
    
SetLocalVarInt("ButtonsPressed"0);
    
    for(
int i=1i<=9i++) {
        
SetEntityPlayerInteractCallback("PressButton_"+i"PressedButton"false);
    }
}

void PressedButton(string &in entity)
{
    
int buttonsPressed;
    
    
AddLocalVarInt("ButtonsPressed"1);
    
    
playersGuessedCode += GetButtonPressed(entity);
    
buttonsPressed GetLocalVarInt("ButtonsPressed");
    
    
AddDebugMessage("Buttons Pressed: "+buttonsPressed+"  Guessed Code: "+playersGuessedCodefalse);
    
    if(
playersGuessedCode == correctCode) {
        
// unlock door or whatever here
        
for(int i=1i<=9i++) {
            
SetEntityActive("PressButton_"+ifalse);
        }
        
ResetCode();
        
AddDebugMessage("Correct code!"false);
        
        return;
    }
    
    if(
buttonsPressed == 4) {
        
ResetCode();
        
AddDebugMessage("Wrong code!"false);
    }
}

void ResetCode()
{
    
SetLocalVarInt("ButtonsPressed"0);
    
playersGuessedCode "";
}

string GetButtonPressed(string entity)
{
    if(
entity == "PressButton_1") {
        return 
"1";
    }
    else if(
entity == "PressButton_2") {
        return 
"2";
    }
    else if(
entity == "PressButton_3") {
        return 
"3";
    }
    else if(
entity == "PressButton_4") {
        return 
"4";
    }
    else if(
entity == "PressButton_5") {
        return 
"5";
    }
    else if(
entity == "PressButton_6") {
        return 
"6";
    }
    else if(
entity == "PressButton_7") {
        return 
"7";
    }
    else if(
entity == "PressButton_8") {
        return 
"8";
    }
    else if(
entity == "PressButton_9") {
        return 
"9";
    }
    else {
        return 
"";
    }
}

void OnLeave(){} 
Pages: 1 2