I create and load the state of the object from JSON but there is a problem with the ZI variable.
Then I check if the state of the object is different from the state in JSON saved previously, if it is different, then I save the new state in JSON.
Because of this "problem" with the ZI variable, the state is always different because the JSON ZI variable and the newly created object do not match.
So I use the plugin to match them.
I create the object.
I write in JSON (previously saved) the new ZI value.
I assign the JSON state to the object.
When the level is finalized I compare the states (sprite.asJSON <> stateJSON)
If there are differences in the states then -> stateJSON = sprite.asJSON
Now when comparing the state of the object (sprite.asJSON) with the state saved in the JSON chain, it will only be saved if something has changed (such as the damage it has or the coordinates).
I'm doing tests with a REX plugin to get that.