Draw and keypressed events inthe middle of a function
Posted: Tue Aug 01, 2017 4:29 pm
Hi guys,
I’ve begun to play around with LÖVE and decided to make a roguelike game but I’m having a problem and was wondering if you could help me.
I think I understand the concept of draw() and I’m using several global variables to decide what to effectively show (dungeon, character sheet, talent usage, etc).
My problem right now is with talents(or skills). I defined them like this:
So, the question is, how can I make this work? I want to allow the player to choose one target and then do something to that target and maybe some other stuff
If I use those global variables, I could probably do the targeting part, but how would I then continue to execute the rest of the code?
Is there a way to “interrupt” the function execution, do the drawing and the target selection, and then continue where I left off?
Thanks guys
PS: Another unrelated question: In that example above, is there a way to use in the function the other fields of the talent? For instance to have the damage be proportional to the level?
I’ve begun to play around with LÖVE and decided to make a roguelike game but I’m having a problem and was wondering if you could help me.
I think I understand the concept of draw() and I’m using several global variables to decide what to effectively show (dungeon, character sheet, talent usage, etc).
My problem right now is with talents(or skills). I defined them like this:
Code: Select all
local talent = Talents:new( {
name = "Magic arrow",
range = 10,
description = "Shoot a magic arrow",
level = 1
use = function(user)
-- Select a target
local target = getTarget(user, 10)
-- do something to target
target:takeDamage(10)
-- do something else
user:spendMana(5)
end
} )
If I use those global variables, I could probably do the targeting part, but how would I then continue to execute the rest of the code?
Is there a way to “interrupt” the function execution, do the drawing and the target selection, and then continue where I left off?
Thanks guys
PS: Another unrelated question: In that example above, is there a way to use in the function the other fields of the talent? For instance to have the damage be proportional to the level?