#Well that’s hard to answer because there

1 messages · Page 1 of 1 (latest)

ruby pivot
#

let's make it a thread

#

I mean you're doing -=

#

so that's a subtraction

main acorn
#

Right, but it’s not intended to subtract the stat itself, if that makes sense.

ruby pivot
#

and -= is shorthand for writing something like

#

variable = something - variable

#

I believe

#

if you want just the player damage minus the boss defense

#

remove the =

#

if I am getting your problem right

#

when faced with stuff like this it could help to draw out a flowchart of the steps you want your function/coroutine to take

main acorn
#

Ok, that worked.

ruby pivot
#

not in code, but pseudocode or words

main acorn
#

Thanks.

ruby pivot
#

np

#

anything else?

main acorn
#

There is something else but I’m wondering if it’s more suited for the advanced sections.

ruby pivot
#

well you can ask

#

if I don't know I'll tell you where to ask

#

:P

main acorn
#

Basically, the coroutine is supposed to stop when either of the characters reach 0HP, but it seems to be forcing me to use a waitforseconds command to get those results. It might just be an issue of how I structured the coroutine though.

ruby pivot
#

from what I know

#

you have to cache a reference to the coroutine

#

you can do that in start or whatever

#

but also the coroutine will stop at the end regardless since you're not looping

#

Think of coroutines as any other function, except that you can pause in the middle

#

so if it reaches the end, that's it

#

this shows an example of caching it

#

any progress?

main acorn
#

Not quite, I’m trying a bunch of different things right now to try and solve the problem, right now I’m making the conditions if an actor’s hp is < 0 as opposed to <= 0.

ruby pivot
#

that doesn't really matter

#

do you want the coroutine to run the entire boss fight until a condition is met?

main acorn
#

Yes, that’s the plan.

ruby pivot
#

you can just wrap the code in a while(true) loop for example

#

waitforseconds pauses the whole execution and right now your stats will only be evaluated once when you start the coroutine

#

also in case you're starting this coroutine in update, try not to

#

you usually don't want to run the same coroutine multiple times at the same time

main acorn
#

Ok, thanks for helping. Problem isn’t quite solved yet but I think I know what I’m going for now.

ruby pivot
#

👍