Community Forum

MixerWagon change

Forum Overview >> Scripting

CategoryScripting
Created23.01.2019 06:07


Antt Mountain (Unknown) 23.01.2019 06:07
Hi, Im learning to change the scripts, so i can alter effects on my mixerwagon mod, Currently trying to put grass back, like in FS17, but im having 0 luck!
Currently i think the issue lies in this section of the script:

--=====================================================================================
-- MIXER WAGON GRASS WINDROW
--
-- @For: TwistedGetsu/Animal Feed Edition
-- @Date: 2019-01-23
-- @Purpose: To allow grass_windrow fillType in the mixer wagon.
--=====================================================================================


local oldMixerWagonLoad = MixerWagon.load;
MixerWagon.load = function(self.xmlfile, savegame)
if oldMixerWagonLoad ~= nil then
oldMixerWagonLoad(self.xmlfile, savegame)
spec.mixerWagonFillTypes = nil
spec.fillTypeToMixerWagonFillType = nil
end

spec.activeTimerMax = 5000
spec.activeTimer = 0
spec.fillUnitIndex = Utils.getNoNil(getXMLInt(self.xmlFile, "vehicle.mixerWagon#fillUnitIndex"), 1)
-- remove grass_windrow from fillTypes, we do not want to support grass in mixer wagons becasue this would make hay "useless"
local fillUnit = self:getFillUnitByIndex(spec.fillUnitIndex)
if fillUnit ~= nil then
fillUnit.needsSaving = false
if fillUnit.supportedFillTypes[FillType.GRASS_WINDROW] then
fillUnit.needsSaving = false
end
end

I know someone with more knowledge will be able to make sense of this easily but im very confused because ive tried many alterations with no results, and no real way of knowing if im any closer >.< please help if u can! There is more to the script but im almost 100% that its this bit thats wrong.. :( Also that mis spelling of because is on their script on this site.. soooo xD

Bilbo Beutlin (BBeutlin) 23.01.2019 11:38
Directly (hard-) overwriting a default function is never a good idea. The function might be used by game engine itself or by another mod.
Instead use
thisFunction = Utils.xyzFunction(originalFunction, myFunction)
where 'xyz' can be 'appended' or 'prepended' or 'overwritten'.

For your issue it's necessary to copy the complete orig. function and modify it according your desires.

You must also regard a necessary basic structure for a script mod. Take existing mods as examples.

Antt Mountain (Unknown) 23.01.2019 14:46
After checking more i further understand, i have started the custom spec and believe it is much more inline with what i should do and what works best!
Thanks for info!



Note: Log in to post. Create a new account here.