Difference between revisions of "love.event.restart"
(Created page) |
m |
||
(One intermediate revision by the same user not shown) | |||
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 | + | 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. |
Line 19: | Line 19: | ||
== Example == | == Example == | ||
<source lang="lua"> | <source lang="lua"> | ||
− | local restartcount = love.restart or 0 | + | local restartcount = tonumber(love.restart) or 0 |
function love.keypressed(k) | function love.keypressed(k) |
Latest revision as of 17:03, 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)
.
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 = tonumber(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
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info