Search the Community
Showing results for tags 'wait'.
-
Hello again! And again I'm here asking stupid questions... I still have some problems with the door jamming, but moved on for now. So I'm modifying default enemy AI for my needs and making slow, but steady progress. Now enemy has basic patrol mode and it attacks player. And gives up hunting if player gets too far away. Thanks for Nick Ace for navpoint tutorial! But I would like enemy to stop for a few seconds when reaching navpoint, so is there pause function in lua? I tried to search but could not find anything useful...
-
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: