Project Zomboid

Project Zomboid

快速打开汽车引擎盖 [B42]
Cumulative speed FIX
As I wrote in the comments , the speed currently is inconsistent as it is cumulatively dividing the already modified value each time you change the speed.

I think I fixed it by storing the original speed value at the start and using that in the part where the speed is applied. It seems to work, but it needs more testing. I'm just an amateur.

Because it's using the original value, which is really slow , I had to adjust the slider as the speed increase is not as drastic. I suggest changing the speed calculation; maybe if the sliderOption is above one, then multiply the sliderOption in the speed calculation by 2?

The code: (ISOpenMechanicsUIAction_FastHoodOpenMod.lua)


-- Add to the mod settings, your own section
local fhomOptions_Options = PZAPI.ModOptions:create("fhomOptions_ID", getText("UI_fhom_OptionsTitle"))

-- Adding a slider for speed control
fhomOptions_Options:addSlider("fhomOptions_Option_speedSlider", getText("UI_fhom_OptionsSliderText"), 0.2, 8, 0.1, 1, getText("UI_fhom_OptionsSliderTooltip"))

-----------------------------------------------------------------------


-- Store the original hood opening time
local OriginalMaxTime = nil

function reSpeedHoodOpenFunc()

-- Inherit the old class
local old_class_to_new = ISOpenMechanicsUIAction.new

-- Take out of it the function of opening UI mechanics (action when opening the hood)
function ISOpenMechanicsUIAction:new(character, vehicle, usedHood)

-- Create an instance of the class
local o = old_class_to_new(self, character, vehicle, usedHood)

-- Store the original maxTime once
if not OriginalMaxTime then
OriginalMaxTime = o.maxTime
end

-- Getting the value from Slider in the settings
local options = PZAPI.ModOptions:getOptions("fhomOptions_ID")
local sliderOption = options and options:getOption("fhomOptions_Option_speedSlider")

-- Change its speed, the higher the number the faster the action will happen
o.maxTime = OriginalMaxTime / sliderOption:getValue()

-- Bringing back to the game a class with a modified hood opening time
return o
end

end

-----------------------------------------------------------------------

-- If the mod settings have been applied (i.e. changed)
fhomOptions_Options.apply = function(self)
-- Change the hood opening speed at game startup
reSpeedHoodOpenFunc()
end

-- When the game starts
Events.OnGameBoot.Add(function()
-- Change the hood opening speed at game startup
reSpeedHoodOpenFunc()
end)
最后由 Karbantms 编辑于; 10 月 6 日 下午 5:33