current implementation: refreshingFormSpecs.open = function (formSpecMaster, formSpecName, playerName, isRecursiveCall)
formSpecMaster is the instance of a nodes data model (e.g. "Barrel") and MUST implement a public function getFormSpec().
First of all that's not very intuitive. More natural way is providing formSpec itself. Second is that it might be confusing because you need to know about data models inner structure.
Better way: having a model class "RefreshableFormSpec".
`
---@class RefreshableFormSpec
local refreshableFormSpec = {}
refreshableFormSpec.new = function (pos)
local self = {}
self.getFormSpec() = function()
meta = minetest.get_meta(pos)
return meta::get_string("formSpec")
end
---other fancy stuff
return self
end
`
in nodes datamodel you now can implement getFormSpec():
`
self.getFormSpec() = function ()
return RefreshableFormSpec.new(pos)
end
`
Former "refreshingFormSpecs" then has to be renamed to "refreshingFormSpecHandler" or sth like this.
it's important you pass the refreshableFormSpec object to handler and NOT the return of its getFormSpec()
current implementation: refreshingFormSpecs.open = function (formSpecMaster, formSpecName, playerName, isRecursiveCall)
formSpecMaster is the instance of a nodes data model (e.g. "Barrel") and MUST implement a public function getFormSpec().
First of all that's not very intuitive. More natural way is providing formSpec itself. Second is that it might be confusing because you need to know about data models inner structure.
Better way: having a model class "RefreshableFormSpec". ` ---@class RefreshableFormSpec local refreshableFormSpec = {}
refreshableFormSpec.new = function (pos)
local self = {}
self.getFormSpec() = function()
end
---other fancy stuff
return self
end `
in nodes datamodel you now can implement getFormSpec(): ` self.getFormSpec() = function ()
return RefreshableFormSpec.new(pos)
end `
Former "refreshingFormSpecs" then has to be renamed to "refreshingFormSpecHandler" or sth like this. it's important you pass the refreshableFormSpec object to handler and NOT the return of its getFormSpec()