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?
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


Messages In This Thread
How to create a User-Input Script? - by ehovda321 - 01-06-2013, 10:24 AM
RE: How to create a User-Input Script? - by TheGreatCthulhu - 01-06-2013, 12:18 PM



Users browsing this thread: 5 Guest(s)