Difference between revisions of "love.event.push"

(oldin notice correction.)
(Specify what types of arguments are supported for the events)
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 +
{{newin|[[0.6.0]]|060|type=function}}
 
Adds an event to the event queue.
 
Adds an event to the event queue.
 +
 +
See [[Variant]] for the list of supported types for the arguments.
 +
 +
From [[0.10.0]] onwards, you may pass an arbitrary amount of arguments with this function, though the default callbacks don't ever use more than six.
 +
 
== Function ==
 
== Function ==
{{newin|[[0.8.0]]|type=variant}}
 
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
love.event.push( e, a, b, c, d )
+
love.event.push( n, a, b, c, d, e, f, ... )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|Event|e|The name of the event.}}
+
{{param|Event|n|The name of the event.}}
{{param|mixed|a (nil)|First event argument.}}
+
{{param|Variant|a (nil)|First event argument.}}
{{param|mixed|b (nil)|Second event argument.}}
+
{{param|Variant|b (nil)|Second event argument.}}
{{param|mixed|c (nil)|Third event argument.}}
+
{{param|Variant|c (nil)|Third event argument.}}
{{param|mixed|d (nil)|Fourth event argument.}}
+
{{New_feature|0.8.0|
=== Returns ===
+
{{param|Variant|d (nil)|Fourth event argument.}}
Nothing.
+
|080}}
== Function ==
+
{{New_feature|0.10.0|
{{oldin|[[0.8.0]]|type=variant}}
+
{{param|Variant|e (nil)|Fifth event argument.}}
=== Synopsis ===
+
{{param|Variant|f (nil)|Sixth event argument.}}
<source lang="lua">
+
{{param|Variant|... (nil)|Further event arguments may follow.}}
love.event.push( e, a, b, c )
+
|100}}
</source>
 
=== Arguments ===
 
{{param|Event|e|The type of event.}}
 
{{param|mixed|a (nil)|First event argument.}}
 
{{param|mixed|b (nil)|Second event argument.}}
 
{{param|mixed|c (nil)|Third event argument.}}
 
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
 
== Examples ==
 
== Examples ==
=== Quitting a game in 0.8.0 ===
+
{{New_feature|0.8.0|
 
<source lang="lua">
 
<source lang="lua">
 
function love.keypressed(k)
 
function love.keypressed(k)
Line 35: Line 34:
 
end
 
end
 
end
 
end
</source>
+
</source>}}
=== Quitting a game in 0.7.2 ===
+
{{Removed_new_feature|0.6.0|0.7.2|
 
<source lang="lua">
 
<source lang="lua">
 
function love.keypressed(k)
 
function love.keypressed(k)
Line 43: Line 42:
 
end
 
end
 
end
 
end
</source>
+
</source>}}
 
== See Also ==
 
== See Also ==
 
* [[parent::love.event]]
 
* [[parent::love.event]]

Latest revision as of 13:17, 17 July 2020

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

Adds an event to the event queue.

See Variant for the list of supported types for the arguments.

From 0.10.0 onwards, you may pass an arbitrary amount of arguments with this function, though the default callbacks don't ever use more than six.

Function

Synopsis

love.event.push( n, a, b, c, d, e, f, ... )

Arguments

Event n
The name of the event.
Variant a (nil)
First event argument.
Variant b (nil)
Second event argument.
Variant c (nil)
Third event argument.
Available since LÖVE 0.8.0
Variant d (nil)
Fourth event argument.


Available since LÖVE 0.10.0
Variant e (nil)
Fifth event argument.
Variant f (nil)
Sixth event argument.
Variant ... (nil)
Further event arguments may follow.

Returns

Nothing.

Examples

Available since LÖVE 0.8.0
function love.keypressed(k)
	if k == 'escape' then
		love.event.push('quit') -- Quit the game.
	end	
end


Available since LÖVE 0.6.0 and removed in LÖVE 0.7.2
function love.keypressed(k)
	if k == 'escape' then
		love.event.push('q') -- Quit the game.
	end	
end

See Also


Other Languages