How to do division? With two variables?

Hey! I am trying to figure out how to divide by two variables in verse. When trying to divide them it gives me this error, “This invocation calls a function that has the ‘decides’ effect, which is not allowed by its context. The ‘decides’ effect indicates that the invocation calls a function that might fail, and so must occur in a failure context that will handle the failure. Some examples of failure contexts are the condition clause of an ‘if’, the left operand of ‘or’, or the clause of the ‘logic’ macro”

The problem is with the calculation of Kd.

My Kd variable is = var KD : int = 0

showbillBoard(Agent : agent): void = 
        Print("Stats Check Stated.", ?Duration:=6.0)
        set elimations = elimationsTracker.GetValue(Agent)
        set playtime = PlayerTimeTracker.GetValue(Agent)
        set deaths = DeathTracker.GetValue(Agent)
        set wins = WinsTracker.GetValue(Agent)
        set KD = (elimations/deaths)

Are they all floats? Or are you trying to do that with integers?

No errors in this:

var elimations:float = 1.0
var deaths:float = 2.0
var KD:float = 0.0
...
set KD = (elimations/deaths)
1 Like

Integer divisions can fail since you could try to divide by 0, thus you need to handle the failure

You can use floats otherwise, since division by 0 is handled by the NaN value

1 Like