YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

How do I make a delay?
Jon
#1 Posted : Friday, March 20, 2015 3:43:00 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/20/2015(UTC)
Posts: 2
Location: Norway

Thanks: 2 times
Was thanked: 0 time(s) in 0 post(s)
Hello there!

I'm new to squirrel, and I'm currently trying to make a mutation gamemode for Left 4 Dead 2.
What I'm looking for is a delay of 5 seconds before an action occurs. In this case, reviving Nick from incapicitation.

This is small part of the code:

while( ( Nick = Entities.FindByModel( Nick, "models/survivors/survivor_gambler.mdl" ) ) != null )
{
if( Nick.IsIncapacitated() == true )
{
//Some sort of delay/wait/sleep command here.
Nick.ReviveFromIncap();
}
}

Any help would be appreciated. :)
~Jon
bluehazzard
#2 Posted : Tuesday, March 24, 2015 3:03:18 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 1/1/2013(UTC)
Posts: 58
Location: italy

Thanks: 14 times
Was thanked: 3 time(s) in 3 post(s)
i think you have to ask a valve developer to answer this question... I don't know if they have exposed a delay function...
squirrel per se has no such function...

greetings
Jon
#3 Posted : Wednesday, March 25, 2015 8:44:39 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/20/2015(UTC)
Posts: 2
Location: Norway

Thanks: 2 times
Was thanked: 0 time(s) in 0 post(s)
So there's no delay function in Squirrel? That's sad, because the mutation script files are build on the squirrel program language, with a few
extra variables for the L4D2 game.

Thank you anyways :)

~Jon
bluehazzard
#4 Posted : Wednesday, March 25, 2015 8:59:05 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 1/1/2013(UTC)
Posts: 58
Location: italy

Thanks: 14 times
Was thanked: 3 time(s) in 3 post(s)
I think you missunderstand that squirrel is a programming language not a framework. All functions to communicate with the outer world (like sleep or pause) has to be provided from the programmer who embedd squirrel in his program.
There exists a basic library for math and file IO but it is not guaranteed that this library is integrated in your program...

I think that there has to be some sort of delay in L4D but this is simply the wrong place to ask. You will find more help in the valve forums or mail the developer of l4d...

Greetings
1 user thanked bluehazzard for this useful post.
Jon on 3/25/2015(UTC)
devlin
#5 Posted : Sunday, June 21, 2015 7:53:41 PM(UTC)
Rank: Member

Groups: Registered
Joined: 6/21/2015(UTC)
Posts: 10
Location: Sweden

Thanks: 0 times
Was thanked: 1 time(s) in 1 post(s)
You could spawn a generator, store it in an array (with other generators) - then loop through them all once per frame, update with current frame delta time.

This is pseudo code for how I do it in my engine:

Code:

  class Threads
  {
    ...
    function Spawn(t) { /* add to array of generators, add 0 to another array called "waits" */ }
    function Update(delta) { /* loop through all generators, substract delta from all waits, if <= 0 then resume it - store the return value in "waits" index slot - remove it if it returns null */ }
  }

  class Nick
  {
    function RespawnInFive()
    {
       yield 5;  // could just as easily be a parameter to the function
       Nick.ReviveFromIncap();
    }

    function Update(delta)
    {
       Threads.Update(delta);

       if( ( Nick = Entities.FindByModel( Nick, "models/survivors/survivor_gambler.mdl" ) ) != null )
       {
         if( Nick.IsIncapacitated() == true )
         {
           Threads.Spawn(RespawnInFive());
         }
       }
    }
  }


Not sure if something similar could be done with L4D, but the language itself isn't stopping you. :)

Regards,
Johan
1 user thanked devlin for this useful post.
Jon on 7/4/2015(UTC)
EugenioSadlon
#6 Posted : Monday, July 25, 2022 4:24:59 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/25/2022(UTC)
Posts: 2
Location: Los Angeles

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Everything that players and characters learn during the game. Knowledge about the game world and its inhabitants is not usually part of the mechanics of the game, but players and https://epiccarry.com/us/boost/pvp-gear/ characters tend to use it however they want. For me, the knowledge that the heroes have is part of their progress in the game, part of their coolness. Sometimes it's better to just know where not to go than to have five points pumped into your shooting, trust me. And while I don't like written settings, I love giving details to the characters for them to use later.
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.041 seconds.