Closed endel closed 1 year ago
One idea was to add a register ACE that did the following:
registerOnChange(path)
{
state[path].onAdd = (entry, id) => {
entry.onChange = (changes) => {
changes.forEach((change) => {
self.lastPreviousValue = change.previousValue;
self.lastField = change.field // gold
self.lastValue = change.value // 10
self.Trigger(C3.Plugins.Colyseus.Cnds.OnSchemaFieldChange);
})
}
}
}
Though this may not work, I can't quite remember how C3 will handle multiple triggers in one tick (e.g. multiple changes in one tick.) I think it will be ok, if it is defined as a regular trigger, not a fake trigger.
Thank you @MikalDev, on the latest there is a "On change at"
condition that can now handle these! 🙏
In pure JavaScript, to be able to catch
players.xxxx.gold
, for example, you would do this:C3 only seems to allow adding events statically at layout startup, so we can't register events for each player by id.
(if we could register "On Change" for each
[id]
, likeentities.fh91h3f.gold
it would work, but it doesn't seem to be possible atm)