Search the Community
Showing results for tags 'Sleep'.
-
Is there a way to do a thread.sleep function like in java, but in lua? I am making a piston-like function based off the sliding door function where it pushes out, then waits for a set amount of time, then falls back in. I had it as time:Delay(1000) but that would pause the game and I didn't want that. Any help?
-
I'm currently working on coroutines in lua. This will help people setup scripting sequences for their game. The cool part of this will be that you will use it in the editor like any other entity. Drag it into your scene and now in your other scripts you'll have access to these functions. Here is an example usage of what you would do in lua. --- This defines the function that stores your script sequence function MyScript01(cr) -- cr is the coroutine to this function. The functions that pause execution of the script require it to be passed in MoveTo(cr, player, pivot1) -- This method will move the player entity to the pivot1 entity and only return when it has reached it's destination PlaySound(cr, "hello.wav") -- This method will return only after the hello.wav is finished playing PlayAnimation(cr, "animation") -- This method returns after the animation is complete Wait(cr, 2000) -- This method will simply wait for 2 seconds before returning. Time is in ms. end -- When you are ready to run your script function simply pass the function to RunScriptFunction() and it'll start playing out RunScriptFunction(MyScript01) This can give us more interactive games than seen in the past with LE. You could create a volume trigger that runs a script when it's touched by the player, that moves an NPC to a location. Have it start talking. Have it play an animation, etc all in sequence. Maybe you make a button in game that when the player presses the 'use' key it runs a script. The script could do all sorts of things. The main benefit of using coroutines like this is that the function where you define your script is actually "paused" until something restarts it again. This means that your game continues to run. That's where I come in. I'm defining the function that will pause and how they will start up again. I'm interested in hearing if people have other functions that would be useful to them that act like this. So far the functions I have are: Wait() MoveTo() PlayAnimation() PlaySound()
- 6 comments
-
- coroutines
- wait
-
(and 2 more)
Tagged with: