Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to define an oldValue parameter?

Asked by 4 years ago
Edited 4 years ago

I want to add an oldValue parameter to DataStore2's ":Update()" method. This is what I currently have now:

function DataStore:Update(updateFunc)
    updateFunc(DataStore:Get(0))
    self.value = updateFunc(self.value)
    self:_Update()
end

But it's still nil (printed). Help?

How i print it:

datastore:Update(function(oldVal)
    print(oldVal)
end)

:_Update() function which is used for setting data in DS2 (Used by datastore:Set() and datastore:Update() in DS2):

function DataStore:_Update(dontCallOnUpdate)
    if not dontCallOnUpdate then
        for _,callback in pairs(self.callbacks) do
            callback(self.value, self)
        end
    end

    self.haveValue = true
    self.valueUpdated = true
end
0
Can you post full script so I can see what were dealing with here? SharkOwen_dev 69 — 4y
1
this part i showed is a part of DS2's MainModule, but when i do `datastore:Update(function(oldVal)` oldVal is nil krowten024nabrU 463 — 4y

Answer this question