Custom functions
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Lazy Waffle
- Prole
- Posts: 5
- Joined: Sat Nov 28, 2009 11:26 pm
- Location: Somewhere
Custom functions
Is it possible to make my own functions? It's just to shorten certain things (find the distance between 2 sets of coordinates, etc.)
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Denver, CO
- Contact:
Re: Custom functions
Of course!
Is the same as
I didn't actually test my distance function, but you probably get the function idea.
Code: Select all
function love.load()
local x, y, dis
x = 10
y = 5
dis = math.sqrt(math.pow(x,2)+math.pow(y,2))
end
Code: Select all
function love.load()
local dis
dis = distance(10,5)
end
--Finds the distance from the origin to an (x,y) point.
function distance(x, y)
return math.sqrt(math.pow(x,2)+math.pow(y,2))
end
Who is online
Users browsing this forum: Ahrefs [Bot] and 79 guests