Difference between revisions of "love.event.restart"

(Created page)
 
m
Line 1: Line 1:
 
{{newin|[[12.0]]|120|type=function}}
 
{{newin|[[12.0]]|120|type=function}}
Restarts the game without relaunching the executable, by adding a restart event to the queue. This cleanly shuts down the main Lua state instance and creates a brand new one.
+
Restarts the game without relaunching the executable, by adding a quit event with a "restart" parameter to the queue. This cleanly shuts down the main Lua state instance and creates a brand new one.
  
  

Revision as of 16:55, 26 March 2023

Available since LÖVE 12.0
This function is not supported in earlier versions.

Restarts the game without relaunching the executable, by adding a quit event with a "restart" parameter to the queue. This cleanly shuts down the main Lua state instance and creates a brand new one.


Equivalent to love.event.push("quit", "restart", restartarg).


O.png If LÖVE is programmatically restarted, all active Lua threads must stop their work and the main thread must wait for them to finish, otherwise LOVE may fail to start again.  


Function

Synopsis

love.event.restart( restartarg )

Arguments

Variant restartarg (nil)
A value which will appear in the love.restart table field after restarting. Can be a table containing multiple Lua values.

Returns

Nothing.

Example

local restartcount = love.restart or 0

function love.keypressed(k)
   if k == "r" then
      love.event.restart(restartcount + 1)
   end
end

function love.draw()
   love.graphics.print("Restarted " .. restartcount .. " times.", 8, 8)
end

See Also

Other Languages