Closed Kln95130 closed 3 years ago
Thanks for spotting that. The issue is that the =>
operator does not allow the use of this
. I have posted an updated.
The point of "eventIsActive" is to allow authors to override it in their games. If you look at the example game in the "game-eg" folder there is a flashlight that has a limited battery charge. The battery usage is tracked with a turnscript, which only runs when the flashlight is turned on. Rather than have the turn on/off script change an additional attribute "eventActive", the flashlight has its own "eventIsActive" script that tests whether the flashlight is turned on. I think this is a better approach because there is no chance of the two attributes being in mismatching states if there is only one! This is a general approach I have taken (it is not possible in Quest 5, as scripts cannot return a value).
I encountered the following issue, when trying to insert a turnscript event. The event is not recognized as active, despite having
eventActive: true
. After investigating, I found that it was caused by this check:If I replace
if (!this.eventIsActive())
byif (!this.eventActive)
, the event triggers correctly. The function is not used in the rest of doEvent, so I think it is safe to do the switch.