function dostuff(x)
end
using it sowhere else:y=dostuff(4) -- do stuff with 4 and assign the value thats returned to y.
You will notice that there is '--' here. It means that lua should ignore everything after this. It's called a comment. For another example lets do something more usefull:function square(x)
return x*x -- multiply x by itself (thus squaring) and return it to be used later
end
functions can return one (or more separated with ',') value or not return any value at all. In that case there comes a special value called 'nil'. Setting something to nil means that that item does not exist or is not set.favourite_number=5 -- :) five my favourite number
favourite_number=nil -- on the other hand i don't need a favourite number.
box={} -- this is to create an empty table called 'box'
box['thingy']='candy' -- set item in the box called 'thingy' to string 'candy'
y=box['thingy'] -- set y to what the 'thingy' is in the box
y=box.thingy -- same thing as a line before, this is more comfortable but limited in some ways
Also you can create manipulate tables in other ways:box={} -- lets recreate the box (forgetting the old one)
table.insert(box,"candy") -- it adds "candy" to the box table like this- first it finds last numbererd item in the box and appends candy after it.
y=box[1] -- gets "candy"
here table.insert is one of many helpful functions supplied by lua to make our life easier. Also it can be replaced (only in this example) by this:box[1]='candy'
function love.draw()
love.graphics.print("Hello World", 10, 10)
end
Save it and zip it, then rename it to have the ending ".love". If everything is done correctly you should see "Hello world" in a black screen. To run games quicker (without reziping and renaming files) you can make a ".bat" file:"C:\Program Files (x86)\LOVE\love.exe" %CD%
Just replace "C:\Program Files (x86)\LOVE\love.exe" with the path to where you installed LOVE.