Integrated Dynamics

Integrated Dynamics

63M Downloads

[API] How to properly invaidate variables?

LubieKakao1212 opened this issue · 6 comments

commented

Issue type:

  • ❓ Question

Question:

I was trying to make a OpenComputers compatibility addon, and encountered a problem with updating variable values.
When I was testing and used variable card directly referencing my value it updated corectly, but when I used a variable referencing that variable card it updated its value only when I reinserting the card.
Is calling invalidate on a variable not enough?

commented

@LubieKakao1212 It looks like your re-creating the variable after invalidation.
Instead, you probably want to reuse the same variable, but call invalidate() if its value has changed.

I recommend having a look at the source code of Integrated REST: https://github.com/CyclopsMC/IntegratedREST/
It feels very similar to what you are trying to achieve.

GitHub
Expose Integrated Dynamics networks as a REST API. Contribute to CyclopsMC/IntegratedREST development by creating an account on GitHub.
commented

@rubensworks
Thanks, It almost works now.

commented

Someone will answer your question soon. In the meantime, you might be able to get help more quickly on our Discord server.

commented

I forgot about that possibility.

commented

@LubieKakao1212 Could you share your code? It's a bit difficult to understand what could be going on.

In any case, the variables created from proxies should be a good basis to start from in your case.

commented

I added you to my repository.
Please don't judge the cleannes of my code.
see class TIleDataBridge method setValue