Changed events to use common format

This commit is contained in:
Cooldude2606
2019-06-14 16:00:48 +01:00
parent 3b5ccd997e
commit b13940b74c
11 changed files with 132 additions and 121 deletions

View File

@@ -79,8 +79,11 @@ local Store = {
registered={},
synced={},
callbacks={},
on_value_update=script.generate_event_name()
events = {
on_value_update=script.generate_event_name()
}
}
Global.register(Store.data,function(tbl)
Store.data = tbl
end)
@@ -184,7 +187,7 @@ function Store.set(location,child,value,from_sync)
data[location] = value
end
script.raise_event(Store.on_value_update,{
script.raise_event(Store.events.on_value_update,{
tick=game.tick,
location=location,
child=child,
@@ -215,7 +218,7 @@ function Store.clear(location,child,from_sync)
data[location] = nil
end
script.raise_event(Store.on_value_update,{
script.raise_event(Store.events.on_value_update,{
tick=game.tick,
location=location,
child=child,
@@ -235,7 +238,7 @@ function Store.get_children(location)
end
-- Handels syncing
Event.add(Store.on_value_update,function(event)
Event.add(Store.events.on_value_update,function(event)
if Store.callbacks[event.location] then
Store.callbacks[event.location](event.value,event.child)
end