Can plugins currently create classes instead of simple tables for multi callbacks like the network callbacks. An example is the nether portal scanner in the source code (though currently chunkstay doesn't use a table, but simply a parameter for each callback). If we'd want the same the callbacks would have to give their own table as a parameter I believe.
After creating the class you could simply give the object as a parameter for a function.
I'll describe a use-case. Currently when doing network request where you need to have the complete return body you append the data to a variable. Take for example the WorldEdit update class. (local variable, append data). This means you can't do multiple requests at once as the from multiple requests would be mixed together in some Frankensteins monster.
If instead you could have a class with a member variable that would make this allot easier. The updater callbacks from WorldEdit would look a little like this:
After creating the class you could simply give the object as a parameter for a function.
I'll describe a use-case. Currently when doing network request where you need to have the complete return body you append the data to a variable. Take for example the WorldEdit update class. (local variable, append data). This means you can't do multiple requests at once as the from multiple requests would be mixed together in some Frankensteins monster.
If instead you could have a class with a member variable that would make this allot easier. The updater callbacks from WorldEdit would look a little like this:
local CheckForNewerVersionCallbacks = {} function CheckForNewerVersionCallbacks:new() local obj = {} setmetatable(obj, CheckForNewerVersionCallbacks) self.__index = self -- Member variable containing all the received data obj.m_ReceivedPluginInfo = "" return obj end function CheckForNewerVersionCallbacks:OnConnected(a_TCPLink) local res, msg = a_TCPLink:StartTLSClient() a_TCPLink:Send("GET /cuberite/WorldEdit/master/Info.lua HTTP/1.0\r\nHost: raw.githubusercontent.com\r\n\r\n") end function CheckForNewerVersionCallbacks:OnError(a_TCPLink, a_ErrorCode, a_ErrorMsg) LOGWARNING("Error while checking for newer WorldEdit version: " .. a_ErrorMsg) end function CheckForNewerVersionCallbacks:OnReceivedData(a_TCPLink, a_Data) self.m_ReceivedPluginInfo = self.m_ReceivedPluginInfo .. a_Data end function CheckForNewerVersionCallbacks:OnRemoteClosed(a_TCPLink) -- Do something with the data now that we've received everything. cUpdater:ParseResults(self.m_ReceivedPluginInfo) end -- Start a network request cNetwork:Connect("raw.githubusercontent.com", 443, CheckForNewerVersionCallbacks:new())