isActive() on Links is not working.
-
IsActive() on Link structure return True while the structure is not active.
(Due to room level degradation)
In room E41S48
Link 5825b46c995ae8292897b33f (top left)
is inactive (marked in red)
as my room goes from level 8 to level 7.But calling the function isActive() on the link return true.
Expected behavior: return false.This makes it very hard to properly handle the situation.
---
Is there any other way to discriminate that a structure is not active than calling isActive() ?
Here below is the documentation for the method :isActive()Check whether this structure can be used. If room controller level is insufficient, then this method will return false, and the structure will be highlighted with red in the game.
-
:waves:
Yes, you can write a client side version of isActive, if you wish. You can check the server side code for how that's done.
It's quite useful for pre RCL 8 rooms to avoid issues with inactive structures as you rightfully noticed.
-
FWIW I've dealt with that by checking for error codes.
If you try to send from an inactive link, it tells you RCL not enough or whatever that error is.
If you try to send to an inactive link, it tells you invalid target.
As the cost of isActive() is significant, I never actually call it. I just look at the error codes and mark them as internally inactive the first time I get an error trying to use one. Worst case you have 1 error returned when you try to do something, and in any case you never waste extra CPU polling isActive.