How end work.

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
Nutte
Prole
Posts: 32
Joined: Sat Feb 27, 2016 1:08 pm

How end work.

Post by Nutte » Sun May 08, 2016 10:50 am

Hi!

I trying to make a game. But i wonder how the end command work? Why i must have 2 end in love.draw function ?

User avatar
zorg
Party member
Posts: 2697
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How end work.

Post by zorg » Sun May 08, 2016 10:55 am

Exactly where did you see that you needed two ends with love.draw?
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

Nutte
Prole
Posts: 32
Joined: Sat Feb 27, 2016 1:08 pm

Re: How end work.

Post by Nutte » Sun May 08, 2016 11:06 am

Code: Select all

  function love.draw()
                       	     love.graphics.draw(grill, 500)
                       	     love.graphics.draw(bakrund)
                       	             if burgare then
                       	     love.graphics.draw(burgare, 40) 
                       	              love.graphics.draw(raw, 50)
                       	               end
                       	           end
My code i have write. Evryone write this drawcode with 2 ends, why?

User avatar
zorg
Party member
Posts: 2697
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How end work.

Post by zorg » Sun May 08, 2016 11:10 am

Let me fix your identation first:

Code: Select all

function love.draw()
    love.graphics.draw(grill, 500)
    love.graphics.draw(bakrund)
    if burgare then
        love.graphics.draw(burgare, 40) 
        love.graphics.draw(raw, 50)
    end
end
The keywords "function", "if", "do", "while", "for" need their blocks to be closed with "end".
In your case, one end is for the if block, the other for the whole function.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

Nutte
Prole
Posts: 32
Joined: Sat Feb 27, 2016 1:08 pm

Re: How end work.

Post by Nutte » Sun May 08, 2016 11:23 am

Thank you so much Zorg.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests