Jump to content
MrSledgeGaming

Etiquette for compatible mods

Recommended Posts

Hello, thanks to all that reply

 

My mod requires me to edit a core function in the ISReadABook.lua file. Currently, I am doing this by overwriting the function. However, I am also trying to make the mod as compatible as possible with other mods, so if a mod also needs to update or change the files, both may cause unexpected behavior.

 

Here is my code block

 

require "TimedActions/ISBaseTimedAction"
require "TimedActions/ISReadABook.lua"

 

local validOverride = function(self)
    local vehicle = self.character:getVehicle()
    if vehicle and vehicle:isDriver(self.character) then
         --return not vehicle:isEngineRunning()                                              <-- My edit
    end
    return self.character:getInventory():contains(self.item) and ((self.item:getNumberOfPages() > 0 and self.item:getAlreadyReadPages() <= self.item:getNumberOfPages()) or self.item:getNumberOfPages() < 0);
end


local finishReading = function(self)

    local vehicle = self.character:getVehicle()
    if vehicle and vehicle:isDriver(self.character) then
         --return not vehicle:isEngineRunning()                                                  <-- My edit
         getPlayer():getStats():setDrunkenness(0);                                               <-- My edit
    end
    
    if self.item:getNumberOfPages() > 0 and self.item:getAlreadyReadPages() >= self.item:getNumberOfPages() then
        self.item:setAlreadyReadPages(self.item:getNumberOfPages());
    end
    self.character:setReading(false);
    self.item:setJobDelta(0.0);
    if SkillBook[self.item:getSkillTrained()] then
        self.character:playSound("CloseBook")
    else
        self.character:playSound("CloseMagazine")
    end
    ISBaseTimedAction.stop(self);
end

 

 

//OVERRIDES

Events.OnGameStart.Add(
    function()
        ISReadABook.isValid = validOverride
        ISReadABook.stop = finishReading
    end
)

 

Is this the proper etiquette in ensuring that mods are compatible as possible?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...