Where i must put this in code?

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
IceQB
Citizen
Posts: 67
Joined: Sat Nov 03, 2012 1:11 pm

Where i must put this in code?

Post by IceQB »

HI all

First time I have weird problem like that.

so i have code

Code: Select all

if item[1] == used then
		min_items = min_items + 1
		eq_selected = eq_selected + 1
		item_pos = item_pos - 200
end
Problem is that, if i put this in update then commands repeats in infinity, but when i put this in load its not work... soo what i do wrong?
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Where i must put this in code?

Post by Plu »

Depends on what the behaviour should be. I'm guessing it should be run once, when you set the value to used?

In that case, it should go in update but you should add an extra line that removes the used value again so that it doesn't run indefinately.

Code: Select all

if item[1] == used then
      min_items = min_items + 1
      eq_selected = eq_selected + 1
      item_pos = item_pos - 200
      item[1] = not_used -- or whatever the alternative to the used variable is!
end
That should only make it work once per trigger. Keep in mind that if the trigger is something like love.keyboard.isDown() it'll still keep triggering constantly as long as the key is pressed.
User avatar
IceQB
Citizen
Posts: 67
Joined: Sat Nov 03, 2012 1:11 pm

Re: Where i must put this in code?

Post by IceQB »

Thanks, now everything works!
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests