Please help with the "Delay" function in lua with the add-on love2d. Searching in Google I found features that VERY inhibit the game. For example, I will write an excerpt from my code.

subspeed = 5 -- вычитание голода за одну минуту -- function hungersubstract(subspeed) playerhunger = playerhunger - subspeed -- Тут нужна задержка на одну минуту-- end 
  • Apologies for trasslit equate to agreeing to edit the comment;) Approved. - AK

1 answer 1

The functions you did not find are inhibiting the game - but the fact of the delay itself. When you put a delay - you stop the whole program.

You need to handle the love.update event, and there inside it will produce updates of all such values. Do not forget to take into account how much time has passed - otherwise the complexity of your game will depend on the characteristics of the user's computer.

 function love.update(dt) -- ... playerhunger = playerhunger - subspeed * dt -- ... end