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.
i have 4 chairs and i want to call a function as soon as all of those Chairs are populated, i subscribed to the Seated event of each chair and linked it to a function that increases a playercount int and Calls another function which “starts the game” as soon as the playercount hits 4 (1 for testing purposes). Now as soon as the game starts i wanna draw a random word. This is where everything gets confusing.
chooseword(): void =
Print("choosing word")
rndmnumber := GetRandomInt(0, Wordlist.Length)
Print(Wordlist[rndmnumber])
Choosing my random number as the number in the wordlist array automatically turns this into a decides function and it gives me errors if its not a decides function.
Now if i wanna call the chooseword function:
IncreasePlayerCount(Agent:agent):void =
set Playercount += 1
Print(ToString(Playercount))
if(Playercount = 1):
chooseword[]
This gives me the 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.”
How can i call a decides Function inside a non decides function???
I had this problem with a suspends function before and managed to get away by using “spawn:” but how does it work with decides functions??