This simple tutorial will show you how to stop gameplay for a set amount of seconds, using scripting.
This will literally freeze the game for a specified amount of time.
Wait() Function[]
To freeze the game, create a simple function like so:
function Behavior:wait(seconds) local _start = os.time() local _end = _start+seconds while (_end ~= os.time()) do -- whatever -- end end
What this will do is "Wait", obviously. You can easliy call this function from anywhere in the script, however you would like.
An example of this would be:
function Behavior:Awake() end function Behavior:Update() if CraftStudio.Input.WasButtonJustPressed( "u" ) then Behavior:wait(5) print "Aww yeehaw!" end end function Behavior:wait(seconds) local _start = os.time() local _end = _start+seconds while (_end ~= os.time()) do -- whatever -- end end
This script will, upon pressing the "u" key, freeze the game for 5 seconds and then print "Aww yeehaw!" to the console.
Happy CraftStudioing! --Wolfbanejackal