From 2971416ec84207777960d99908920abdb3ce24f4 Mon Sep 17 00:00:00 2001 From: daireb <58991301+daireb@users.noreply.github.com> Date: Sat, 27 Sep 2025 17:02:10 +0100 Subject: [PATCH 1/4] added dummy datastore functionality to allow editing for non-published places --- package.json | 27 ++++++++++++++------------- src/init.lua | 31 +++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 0f8c20e..6dd5bc9 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,16 @@ { - "name": "@boatbomber/sheetvalues", - "version": "3.0.2", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/boatbomber/SheetValues.git" - }, - "contributors": [ - "boatbomber" - ], - "bugs": { - "url": "https://github.com/boatbomber/SheetValues/issues" - } + "name": "@boatbomber/sheetvalues", + "version": "3.0.3", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/boatbomber/SheetValues.git" + }, + "contributors": [ + "boatbomber", + "daireb" + ], + "bugs": { + "url": "https://github.com/boatbomber/SheetValues/issues" + } } diff --git a/src/init.lua b/src/init.lua index 30d357c..88b1513 100644 --- a/src/init.lua +++ b/src/init.lua @@ -258,6 +258,16 @@ local function DictEquals(a, b) return true end +local DummyDatastore = { + GetAsync = function() + return nil + end, + SetAsync = function() end, + UpdateAsync = function(_, callback) + return callback(nil) + end, +} + local SheetValues = {} function SheetValues.new(SpreadId: string, SheetId: string?) @@ -270,6 +280,15 @@ function SheetValues.new(SpreadId: string, SheetId: string?) local ChangedEvent = Instance.new("BindableEvent") + local dsSuccess, dsReturn = pcall(DatastoreService.GetDataStore, DatastoreService, GUID, "SheetValues") + local DataStore + if dsSuccess then + DataStore = dsReturn + else + DataStore = DummyDatastore + warn("SheetValues: Failed to get DataStore:", dsReturn) + end + local SheetManager = { Changed = ChangedEvent.Event, @@ -278,7 +297,7 @@ function SheetValues.new(SpreadId: string, SheetId: string?) Values = {}, _ValueChangeEvents = {}, - _DataStore = DatastoreService:GetDataStore(GUID, "SheetValues"), + _DataStore = DataStore, _MessageListener = nil, _Alive = true, } @@ -385,12 +404,8 @@ function SheetValues.new(SpreadId: string, SheetId: string?) -- Send these values to all other servers if self.LastSource == "Google API" then - local msgSuccess, msgResponse = pcall( - MessagingService.PublishAsync, - MessagingService, - GUID, - #json < 1000 and json or "TriggerStore" - ) + local msgSuccess, msgResponse = + pcall(MessagingService.PublishAsync, MessagingService, GUID, #json < 1000 and json or "TriggerStore") --if not msgSuccess then warn(msgResponse) end end @@ -469,7 +484,7 @@ function SheetValues.new(SpreadId: string, SheetId: string?) table.clear(self) end - pcall(function() + task.spawn(pcall, function() SheetManager._MessageListener = MessagingService:SubscribeAsync(GUID, function(Msg) local msgTimestamp = math.floor(Msg.Sent) if msgTimestamp <= SheetManager.LastUpdated then From 075326ee2c53f6f1372b2f33b0e6472bf03c86b9 Mon Sep 17 00:00:00 2001 From: daireb <58991301+daireb@users.noreply.github.com> Date: Sat, 27 Sep 2025 17:04:42 +0100 Subject: [PATCH 2/4] fixed accidental formatting change --- src/init.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/init.lua b/src/init.lua index 88b1513..19c4802 100644 --- a/src/init.lua +++ b/src/init.lua @@ -404,8 +404,12 @@ function SheetValues.new(SpreadId: string, SheetId: string?) -- Send these values to all other servers if self.LastSource == "Google API" then - local msgSuccess, msgResponse = - pcall(MessagingService.PublishAsync, MessagingService, GUID, #json < 1000 and json or "TriggerStore") + local msgSuccess, msgResponse = pcall( + MessagingService.PublishAsync, + MessagingService, + GUID, + #json < 1000 and json or "TriggerStore" + ) --if not msgSuccess then warn(msgResponse) end end From e12a05734c526bd553ea26d0d066fe98fbf9e1a8 Mon Sep 17 00:00:00 2001 From: daireb <58991301+daireb@users.noreply.github.com> Date: Sat, 27 Sep 2025 17:06:09 +0100 Subject: [PATCH 3/4] added comment explaining DummyDatastore --- src/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.lua b/src/init.lua index 19c4802..a2f6bd4 100644 --- a/src/init.lua +++ b/src/init.lua @@ -258,7 +258,7 @@ local function DictEquals(a, b) return true end -local DummyDatastore = { +local DummyDatastore = { -- Dummy Datastore object to fall back to if DataStoreService fails GetAsync = function() return nil end, From 57d19f123a7f16c867341aea33ae3df31d171ae2 Mon Sep 17 00:00:00 2001 From: daireb <58991301+daireb@users.noreply.github.com> Date: Sat, 27 Sep 2025 17:56:42 +0100 Subject: [PATCH 4/4] set messagingservice publishasync to happen in the background to prevent hanging for unpublished places --- src/init.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/init.lua b/src/init.lua index a2f6bd4..0c86320 100644 --- a/src/init.lua +++ b/src/init.lua @@ -404,13 +404,12 @@ function SheetValues.new(SpreadId: string, SheetId: string?) -- Send these values to all other servers if self.LastSource == "Google API" then - local msgSuccess, msgResponse = pcall( + task.spawn(pcall, MessagingService.PublishAsync, MessagingService, GUID, #json < 1000 and json or "TriggerStore" - ) - --if not msgSuccess then warn(msgResponse) end + ) end return true, "Values updated"