Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help How to create a User-Input Script?
ehovda321 Offline
Junior Member

Posts: 38
Threads: 22
Joined: Dec 2011
Reputation: 0
#1
How to create a User-Input Script?

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
(This post was last modified: 01-06-2013, 10:26 AM by ehovda321.)
01-06-2013, 10:24 AM
Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#2
RE: How to create a User-Input Script?

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: (Select All)
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: (Select All)
// 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
    
}

(This post was last modified: 01-06-2013, 12:30 PM by TheGreatCthulhu.)
01-06-2013, 12:18 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#3
RE: How to create a User-Input Script?

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

Tutorials: From Noob to Pro
01-06-2013, 06:53 PM
Website Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#4
RE: How to create a User-Input Script?

(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.
(This post was last modified: 01-06-2013, 08:59 PM by TheGreatCthulhu.)
01-06-2013, 08:58 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#5
RE: How to create a User-Input Script?

(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).

Tutorials: From Noob to Pro
01-06-2013, 11:04 PM
Website Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#6
RE: How to create a User-Input Script?

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.
(This post was last modified: 01-07-2013, 12:33 AM by TheGreatCthulhu.)
01-06-2013, 11:55 PM
Find




Users browsing this thread: 1 Guest(s)