diff --git a/src/callContractors.lua b/src/callContractors.lua index d55da54..305d299 100644 --- a/src/callContractors.lua +++ b/src/callContractors.lua @@ -58,27 +58,6 @@ function CallContractors:initialize() self.gui = g_gui:loadGui(self.guiDirectory .. "ccGui.xml", "CallContractorsGui", CCGui:new()) end -function CallContractors:onMissionInitialize(baseDirectory, missionCollaborators) -end - -function CallContractors:onSetMissionInfo(missionInfo, missionDynamicInfo) -end - -function CallContractors:onLoad() -end - -function CallContractors:onPreLoadMap(mapFile) -end - -function CallContractors:onCreateStartPoint(startPointNode) -end - -function CallContractors:onLoadMap(mapNode, mapFile) -end - -function CallContractors:onPostLoadMap(mapNode, mapFile) -end - function CallContractors:onLoadSavegame(savegameDirectory, savegameIndex) local savegameFilename = Utils.getFilename(self.savegameFilename, savegameDirectory) if fileExists(savegameFilename) then @@ -88,56 +67,16 @@ function CallContractors:onLoadSavegame(savegameDirectory, savegameIndex) end end -function CallContractors:onPreLoadVehicles(xmlFile, resetVehicles) -end - -function CallContractors:onPreLoadItems(xmlFile) -end - -function CallContractors:onPreLoadOnCreateLoadedObjects(xmlFile) -end - -function CallContractors:onLoadFinished() -end - function CallContractors:onStartMission() - RequestContractsEvent.sendEvent() -end - -function CallContractors:onMissionStarted() -end - -function CallContractors:onWriteStream(streamId) -end - -function CallContractors:onReadStream(streamId) + if g_server == nil then + RequestContractsEvent.sendEvent() + end end function CallContractors:onUpdate(dt) self.contractsManager:update(dt) end -function CallContractors:onUpdateTick(dt) -end - -function CallContractors:onWriteUpdateStream(streamId, connection, dirtyMask) -end - -function CallContractors:onReadUpdateStream(streamId, timestamp, connection) -end - -function CallContractors:onMouseEvent(posX, posY, isDown, isUp, button) -end - -function CallContractors:onKeyEvent(unicode, sym, modifier, isDown) -end - -function CallContractors:onDraw() -end - -function CallContractors:onPreSaveSavegame(savegameDirectory, savegameIndex) -end - function CallContractors:onPostSaveSavegame(savegameDirectory, savegameIndex) local savegameFilename = Utils.getFilename(self.savegameFilename, savegameDirectory) local xmlFile = createXMLFile("CallContractorsXml", savegameFilename, "callContractors") @@ -146,16 +85,6 @@ function CallContractors:onPostSaveSavegame(savegameDirectory, savegameIndex) delete(xmlFile) end -function CallContractors:onPreDeleteMap() -end - -function CallContractors:onDeleteMap() -end - -function CallContractors:onLoadHelpLine() - --return self.directory .. "gui/helpLine.xml" -end - function CallContractors:openGui() if not self.gui.target:getIsOpen() then if g_currentMission:getFarmId() ~= 0 then diff --git a/src/utility/Array.lua b/src/utility/Array.lua index 821f854..2174e63 100644 --- a/src/utility/Array.lua +++ b/src/utility/Array.lua @@ -1,7 +1,7 @@ --- Royal Utility ---@author Royal Modding ----@version 2.0.5.0 +---@version 2.1.1.0 ---@date 26/02/2021 ---@alias Array table Table with numeric indexes only, always ordered and sequential diff --git a/src/utility/Debug.lua b/src/utility/Debug.lua index 6d7337b..27a8f19 100644 --- a/src/utility/Debug.lua +++ b/src/utility/Debug.lua @@ -1,7 +1,7 @@ --- Royal Utility ---@author Royal Modding ----@version 2.0.5.0 +---@version 2.1.1.0 ---@date 05/01/2021 ---@class DebugUtility diff --git a/src/utility/DelayedCallBack.lua b/src/utility/DelayedCallBack.lua index 67b5956..6353b9d 100644 --- a/src/utility/DelayedCallBack.lua +++ b/src/utility/DelayedCallBack.lua @@ -1,7 +1,7 @@ --- Royal Utility ---@author Royal Modding ----@version 2.0.5.0 +---@version 2.1.1.0 ---@date 08/03/17 ---@class DelayedCallBack diff --git a/src/utility/Entity.lua b/src/utility/Entity.lua index f34c899..66d7ca0 100644 --- a/src/utility/Entity.lua +++ b/src/utility/Entity.lua @@ -1,7 +1,7 @@ --- Royal Utility ---@author Royal Modding ----@version 2.0.5.0 +---@version 2.1.1.0 ---@date 05/01/2021 ---@class EntityUtility @@ -84,7 +84,7 @@ end --- Queries a node hierarchy ---@param inputNode integer ----@param func function | "function(node, name, depth) end" +---@param func fun(node: integer, name: string, depth: integer) function EntityUtility.queryNodeHierarchy(inputNode, func) if not type(inputNode) == "number" or not entityExists(inputNode) or func == nil then return diff --git a/src/utility/FadeEffect.lua b/src/utility/FadeEffect.lua index f202d8a..79cf574 100644 --- a/src/utility/FadeEffect.lua +++ b/src/utility/FadeEffect.lua @@ -1,7 +1,7 @@ --- Royal Utility ---@author Royal Modding ----@version 2.0.5.0 +---@version 2.1.1.0 ---@date 17/02/2017 ---@class FadeEffect diff --git a/src/utility/Gameplay.lua b/src/utility/Gameplay.lua index 23d6779..21fc540 100644 --- a/src/utility/Gameplay.lua +++ b/src/utility/Gameplay.lua @@ -1,7 +1,7 @@ --- Royal Utility ---@author Royal Modding ----@version 2.0.5.0 +---@version 2.1.1.0 ---@date 05/01/2021 ---@class GameplayUtility diff --git a/src/utility/Interpolator.lua b/src/utility/Interpolator.lua index 4c1443f..7a1923a 100644 --- a/src/utility/Interpolator.lua +++ b/src/utility/Interpolator.lua @@ -1,7 +1,7 @@ --- Royal Utility ---@author Royal Modding ----@version 2.0.5.0 +---@version 2.1.1.0 ---@date 11/01/2021 --- Interpolators utilities class diff --git a/src/utility/Main.lua b/src/utility/Main.lua index 345081f..4c58cc3 100644 --- a/src/utility/Main.lua +++ b/src/utility/Main.lua @@ -1,7 +1,7 @@ --- Royal Utility ---@author Royal Modding ----@version 2.0.5.0 +---@version 2.1.1.0 ---@date 21/11/2020 --- Initialize RoyalUtility diff --git a/src/utility/String.lua b/src/utility/String.lua index 29b37da..9fc16a9 100644 --- a/src/utility/String.lua +++ b/src/utility/String.lua @@ -1,7 +1,7 @@ --- Royal Utility ---@author Royal Modding ----@version 2.0.5.0 +---@version 2.1.1.0 ---@date 05/01/2021 --- String utilities class diff --git a/src/utility/Table.lua b/src/utility/Table.lua index 55db83c..dbdaad0 100644 --- a/src/utility/Table.lua +++ b/src/utility/Table.lua @@ -1,7 +1,7 @@ --- Royal Utility ---@author Royal Modding ----@version 2.0.5.0 +---@version 2.1.1.0 ---@date 05/01/2021 --- Table utilities class diff --git a/src/utility/Utility.lua b/src/utility/Utility.lua index 880b804..746db8f 100644 --- a/src/utility/Utility.lua +++ b/src/utility/Utility.lua @@ -1,7 +1,7 @@ --- Royal Utility ---@author Royal Modding ----@version 2.0.5.0 +---@version 2.1.1.0 ---@date 09/11/2020 ---@class RandomInterval @@ -97,6 +97,14 @@ end ---@param name string ---@param newFunc function function Utility.overwrittenFunction(target, name, newFunc) + if target == nil then + print("Error: " .. "overwrittenFunction 'target' cannot be nil") + printCallstack() + end + if newFunc == nil then + print("Error: " .. "overwrittenFunction 'newFunc' cannot be nil") + printCallstack() + end target[name] = Utils.overwrittenFunction(target[name], newFunc) end @@ -104,6 +112,14 @@ end ---@param name string ---@param newFunc function function Utility.overwrittenStaticFunction(target, name, newFunc) + if target == nil then + print("Error: " .. "overwrittenStaticFunction 'target' cannot be nil") + printCallstack() + end + if newFunc == nil then + print("Error: " .. "overwrittenStaticFunction 'newFunc' cannot be nil") + printCallstack() + end local oldFunc = target[name] target[name] = function(...) return newFunc(oldFunc, ...) @@ -114,6 +130,14 @@ end ---@param name string ---@param newFunc function function Utility.appendedFunction(target, name, newFunc) + if target == nil then + print("Error: " .. "appendedFunction 'target' cannot be nil") + printCallstack() + end + if newFunc == nil then + print("Error: " .. "appendedFunction 'newFunc' cannot be nil") + printCallstack() + end target[name] = Utils.appendedFunction(target[name], newFunc) end @@ -121,5 +145,38 @@ end ---@param name string ---@param newFunc function function Utility.prependedFunction(target, name, newFunc) + if target == nil then + print("Error: " .. "prependedFunction 'target' cannot be nil") + printCallstack() + end + if newFunc == nil then + print("Error: " .. "prependedFunction 'newFunc' cannot be nil") + printCallstack() + end target[name] = Utils.prependedFunction(target[name], newFunc) end +--- Get elapsed seconds between given date and FS19 release date +---@param year? integer +---@param month? integer +---@param day? integer +---@param hour? integer +---@param minute? integer +---@param second? integer +---@return integer +function Utility.getTimestampAt(year, month, day, hour, minute, second) + year = year or 0 + month = month or 0 + day = day or 0 + hour = hour or 0 + minute = minute or 0 + second = second or 0 + return getDateDiffSeconds(year, month, day, hour, minute, second, 2018, 11, 20, 0, 0, 0) +end + +--- Get elapsed seconds since FS19 release date +---@return integer +function Utility.getTimestamp() + local date = getDate("%Y-%m-%d_%H-%M-%S") + local year, month, day, hour, minute, second = date:match("(%d%d%d%d)-(%d%d)-(%d%d)_(%d%d)-(%d%d)-(%d%d)") + return Utility.getTimestampAt(tonumber(year), tonumber(month), tonumber(day), tonumber(hour), tonumber(minute), tonumber(second)) +end