Project Zomboid

Project Zomboid

Rick's MLC Pay & Pump
RicksMLC  [developer] 13 hours ago
How to add compatibility to your mod for "Pay and Pump"
These are the instructions for how to make a mod compatible with this "Pay and Pump" mod: RicksMLC_PayAtThePump\common\media\lua\client\RicksMLC_PayAtThePump.lua

The lua code below is the code from the mod for overriding the behaviour of the vanilla ISRefuelFromGasPump:

-----------------------------------------
-- Note for modders: To add mod support for your fuel handling there are three API methods to call:
-- RicksMLC_PayAtPumpAPI.initPurchaseFuel(this)
-- Call in :new(). Checks the source is a fuel pump and initialise the pay amounts.
-- RicksMLC_PayAtPumpAPI.updateFuelPurchase(self, self.tankStart, self.tankTarget)
-- Call in :update(). Checks the funds balance and reduce any credit card funds by the delta fuel amount.
-- Note that the :perform() is not needed as the funds balance checking and reducing is handled in updateFuelPurchase.
-- RicksMLC_PayAtPumpAPI.handleEmergencyStop(self)
-- Call in :stop(). Handles the take fuel action abort state by finishing the payment of the final amount.
-----------------------------------------
require "Vehicles/TimedActions/ISRefuelFromGasPump"

local overrideISRefuelFromGasPumpNew = ISRefuelFromGasPump.new
function ISRefuelFromGasPump:new(character, part, fuelStation, time)
local this = overrideISRefuelFromGasPumpNew(self, character, part, fuelStation, time)
RicksMLC_PayAtPumpAPI.initPurchaseFuel(this)
return this
end

local overrideISRefuelFromGasPumpUpdate = ISRefuelFromGasPump.update
function ISRefuelFromGasPump.update(self)
overrideISRefuelFromGasPumpUpdate(self)
RicksMLC_PayAtPumpAPI.updateFuelPurchase(self, self.tankStart, self.tankTarget)
end

local overrideStop = ISRefuelFromGasPump.stop
function ISRefuelFromGasPump.stop(self)
RicksMLC_PayAtPumpAPI.handleEmergencyStop(self)
overrideStop(self)
end