calling fuctions

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
skyHights
Citizen
Posts: 78
Joined: Mon Aug 25, 2014 12:14 pm

calling fuctions

Post by skyHights »

along with my line of asking all the questions recently, I have a new one:

is it possible to do something along the lines of this

Code: Select all

function run(String, function)
      if String == "a" then
            do function
      end
end

and call that with:

Code: Select all

run("a", b()) 
Learning to Löve.
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: calling fuctions

Post by ivan »

Code: Select all

function run(s, func)
  if s == 'a' then
    func()
  end
end
It's called using:

Code: Select all

run('a', function() end)
or

Code: Select all

function b() end
run('a', b)
Not very elegant though, there may be simpler ways to implement what you are trying to do.
User avatar
skyHights
Citizen
Posts: 78
Joined: Mon Aug 25, 2014 12:14 pm

Re: calling fuctions

Post by skyHights »

ivan wrote:Not very elegant though, there may be simpler ways to implement what you are trying to do.
Thank you <3
Learning to Löve.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 227 guests