Frictional Games Forum (read-only)
[SCRIPT] How to create a User-Input Script? - 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] How to create a User-Input Script? (/thread-19828.html)



How to create a User-Input Script? - ehovda321 - 01-06-2013

How could I do something like this...?

void 2choices(); // ASKS THE PLAYER IF YES OR NO?
{

if(Input.GetKeyDown("y") == true)
{
SetSwingDoorLocked("door1", false, true);
RemoveItem("key1");
}

if(Input.GetKeyDown("n") == true)
{

}

}

I've seen it done a couple times in custom stories before, but I've lost the names of the custom stories... Sad

Anybody got any ideas? Could I do something like this in the HPL2 engine? Thanks for taking the time to read this! Smile


RE: How to create a User-Input Script? - TheGreatCthulhu - 01-06-2013

I don't think Amnesia exposes any script functions that can query keyboard state (there certainly aren't any on the documentation wiki), but you can use buttons or levers, or even just script areas, and respond when the user interacts with them.

For example, using script areas set over some button-like object:
PHP Code:
void OnEnter()
{
    
SetEntityPlayerInteractCallback("ScriptArea_1""OnButtonPress"false);
    
SetEntityPlayerInteractCallback("ScriptArea_2""OnButtonPress"false);
}

void OnButtonPress(string &in sender)
{   
    
// check sender var to determine which script area,
    // then do something


Another example, using levers:
PHP Code:
// LEVER STATES: just some constants for the sake of readability 
const int YES 1;
const 
int NO = -1;

// note: there's an intermediate state as well (state 0), but it's not used

void OnEnter()
{
    
SetEntityConnectionStateChangeCallback("lever_yesno""OnLeverMoved");
}

void OnLeverMoved(string &in entityIDint state)
{
    if(
state == YES)
    {
        
// do something
    
}
    else if (
state == NO)    // have to check, there's an intermediate state as well, but it's not used
    
{
        
// do something else
    
}




RE: How to create a User-Input Script? - Your Computer - 01-06-2013

Only HPL3 would allow for accessing keyboard events, but we can only confirm mouse button events for HPL3 for now.


RE: How to create a User-Input Script? - TheGreatCthulhu - 01-06-2013

(01-06-2013, 06:53 PM)Your Computer Wrote: Only HPL3 would allow for accessing keyboard events, but we can only confirm mouse button events for HPL3 for now.

There are details of HPL3 known already? Where can I read more about that?
Also, I'm suspecting that it is likely that thechineseroom team will probably modify the source code of HPL2 (for Amnesia:AMFP) and maybe expose some new functions to the script engine, to suit their own needs - if so, it will be interesting to see what they've done.


RE: How to create a User-Input Script? - Your Computer - 01-06-2013

(01-06-2013, 08:58 PM)TheGreatCthulhu Wrote: There are details of HPL3 known already? Where can I read more about that?

The official FrictionalGames youtube channel has videos concerning HPL3. Accessing mouse events, calling global functions, better class support, etc, can be seen from those videos. Also, the FrictionalGames blog gives some extra insight, like reading and writing your own configuration files (in XML format).


RE: How to create a User-Input Script? - TheGreatCthulhu - 01-06-2013

Thanks. I read the blog from time to time, so I'm pretty familiar with what's there, although I might have missed a thing or two. Didn't know there were more engine-details related videos on YT, except for those two (or was it one?) where Thomas showcases the new script side capabilities for the first time. Gonna check it out.

EDIT: Oh, that's in those very videos! XD
I've seen them, but I've apparently forgotten; what do remember is that I was happy for the full support for AngelScript's OOP capabilities.

But thanks nevertheless.