The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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
Doors behave stangely
ingedoom Offline
Member

Posts: 120
Threads: 12
Joined: Feb 2012
Reputation: 0
#1
Doors behave stangely

Hi forum.

I have a problem that i hope you can help me solve. The problem is; that the OpenDoor() function doesn't seem to work when it's called from within a timer function (in this case IntroHalt()). The debug message "door opens" is sent but the door is not affected by the script. When i call the function from Onstart() or StartIntro() it works just fine and the door opens.
I've also tried to put the door opening script inside the timer function itself, but this does not work either..

Do i have to make a ScriptArea for this to work, or can i do something else to avoid it? So i won't have to worry about adding areas in the level editor?

Also, can you explain why i can't seem to call the door opening script from a timer?


Spoiler below!

PHP Code: (Select All)
//======================
//Functions 
    
void AddDebugMessage(string text)// Just for debug purposes
        
{
            
AddDebugMessage(textfalse);
        }
    
void StartIntro()//Starts intro sequence
        
{
            
AddDebugMessage("Intro Started");
            
FadeOut(0.0f);
            
FadeIn(15.0f);
            
SetPlayerActive(false);
            
AddTimer("MoveForward"0.01f"IntroMove");
            
AddTimer("StopMoving"53.0f"IntroHalt");
        }
    
void IntroMove(string TimerName)
        {
            
MovePlayerForward(0.005f);
            
AddTimer("MoveForward"0.01f"IntroMove");
        }
    
void IntroHalt(string TimerName)
        {
            
AddDebugMessage("Player stops");
            
RemoveTimer("MoveForward");
            
OpenDoor("prison_11");
        }
    
void OpenDoor(string door)
        {
            
AddDebugMessage("Door opens");
            
SetSwingDoorDisableAutoClose(doortrue);
            
SetSwingDoorClosed(doorfalsefalse);
            
SetMoveObjectState(door0.1f);
            
AddPropForce(door, -50000"world");
        }
//======================
//Run when map first starts
    
void OnStart()
        {
            if(
ScriptDebugOn() and ! HasItem("lantern"))
                {
                    
GiveItemFromFile("lantern""lantern.ent");
                    
SetPlayerLampOil(100.0f);
                    
SetPlayerRunSpeedMul(5.0f);
            
                    for(
int i 0;10;i++)
                        {
                            
GiveItemFromFile("tinderbox""tinderbox.ent");
                        }
                }
            
StartIntro();
        }

//=====================
//Run when entering map//
    
void OnEnter()
        {
            
        }

//=====================
//Run when leaving map//
    
void OnLeave()
        {
        
        } 


Edit: I tried to call the OpenDoor function with an EntityCollideCallback, but that didn't help either. I still only get the debug message
Spoiler below!

PHP Code: (Select All)
//======================
//Functions
    
void AddDebugMessage(string text)// Just for debug purposes
        
{
            
AddDebugMessage(textfalse);
        }
//Starts intro sequence
    
void StartIntro()
        {
            
AddDebugMessage("Intro Started");
            
/*FadeOut(0.0f);
            FadeIn(15.0f);
            SetPlayerActive(false);
            AddTimer("MoveForward", 0.01f, "IntroMove");
            AddTimer("StopMoving", 54.0f, "IntroHalt");*/
        
}
    
void IntroMove(string TimerName)
        {
            
MovePlayerForward(0.005f);
            
AddTimer("MoveForward"0.01f"IntroMove");
        }
    
void IntroHalt(string TimerName)
        {
            
AddDebugMessage("Player stops");
            
RemoveTimer("MoveForward");
        }
    
void CollideScriptArea_1(string ParentNamestring ChildNameint alState)
        {
            
AddDebugMessage("Player collides with " ChildName);
            
OpenDoor("prison_11");
        }
    
void OpenDoor(string door)
        {
            
AddDebugMessage("Door opens");
            
SetSwingDoorDisableAutoClose(doortrue);
            
SetSwingDoorClosed(doorfalsefalse);
            
SetMoveObjectState(door0.1f);
            
AddPropForce(door, -50000"world");
        }
//======================
//Run when map first starts
    
void OnStart()
        {
//==========Map testing
            
if(ScriptDebugOn() and ! HasItem("lantern"))
                {
                    
GiveItemFromFile("lantern""lantern.ent");
                    
SetPlayerLampOil(100.0f);
                    
SetPlayerRunSpeedMul(5.0f);
            
                    for(
int i 0;10;i++)
                        {
                            
GiveItemFromFile("tinderbox""tinderbox.ent");
                        }
                }
//==========Actual map script
            
StartIntro();
            
AddEntityCollideCallback("Player""ScriptArea_1""CollideScriptArea_1"true1);
        }

//=====================
//Run when entering map//
    
void OnEnter()
        {
            
        }

//=====================
//Run when leaving map//
    
void OnLeave()
        {
        
        } 


[Image: 23778.png]
(This post was last modified: 03-22-2013, 04:53 PM by ingedoom.)
03-20-2013, 05:36 PM
Website Find


Messages In This Thread
Doors behave stangely - by ingedoom - 03-20-2013, 05:36 PM
RE: Calling functions from timers - by The chaser - 03-20-2013, 05:53 PM
RE: Calling functions from timers - by ingedoom - 03-20-2013, 06:01 PM
RE: Calling functions from timers - by Adrianis - 03-22-2013, 12:29 PM
RE: Calling functions from timers - by ingedoom - 03-22-2013, 04:21 PM
RE: Calling home made functions - by ingedoom - 03-21-2013, 07:25 AM
RE: Doors behave stangely - by Adrianis - 03-22-2013, 05:18 PM



Users browsing this thread: 1 Guest(s)