Difference between revisions of "variable"

(added an example)
m (Example)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
A variable is a value like val, var, and any other letter or word that is not already assigned to something else.
 
A variable is a value like val, var, and any other letter or word that is not already assigned to something else.
  
==Example==
+
== Example ==
 
Changes a variable by 1 each time the left mouse button is clicked
 
Changes a variable by 1 each time the left mouse button is clicked
 
<source lang="lua">
 
<source lang="lua">
 
function love.mousepressed( x, y, button )
 
function love.mousepressed( x, y, button )
if button == "l" then
+
    if button == 1 then -- Versions prior to 0.10.0 use the MouseConstant 'l'
time = time + 1
+
        time = time + 1
 +
    end
 
end
 
end
 +
</source>
 +
 +
== See Also ==
 +
* [[love.mousepressed]]
 +
 +
== Other Languages ==
 +
{{i18n|variable}}

Latest revision as of 08:35, 23 March 2019

A variable is a value like val, var, and any other letter or word that is not already assigned to something else.

Example

Changes a variable by 1 each time the left mouse button is clicked

function love.mousepressed( x, y, button )
    if button == 1 then -- Versions prior to 0.10.0 use the MouseConstant 'l'
        time = time + 1
    end
end

See Also

Other Languages