Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggestion #25

Closed
HeadyCS opened this issue Nov 6, 2017 · 2 comments
Closed

suggestion #25

HeadyCS opened this issue Nov 6, 2017 · 2 comments

Comments

@HeadyCS
Copy link

HeadyCS commented Nov 6, 2017

I have a suggestion to change the script HoseSystemRegister.lua:


function HoseSystemRegistrationHelper.loadVehicle(super, vehicleData, asyncCallbackFunction, asyncCallbackObject, asyncCallbackArguments)
    local customEnvironment, _ = Utils.getModNameAndBaseDirectory(vehicleData.filename)

    --if customEnvironment ~= nil then
        local typeDef = VehicleTypeUtil.vehicleTypes[vehicleData.typeName]
        local specializations = typeDef.specializations
        local specializationNames = typeDef.specializationNames

        for i = 1, #specializations do
            local specializationName = specializationNames[i]

            --if specializationName ~= nil and specializationName:lower() == string.format('%s.%s', customEnvironment, HoseSystemRegistrationHelper.HOSE_SYSTEM_SPEC_KEY):lower() then
                local specialization = specializations[i]

                if specialization.preLoadHoseSystem ~= nil then
                    super.xmlFile = loadXMLFile('TempConfig', vehicleData.filename)

                    local vehicleLoadState = specializations[i].preLoadHoseSystem(super, vehicleData.savegame)

                    if vehicleLoadState ~= nil and vehicleLoadState ~= BaseMission.VEHICLE_LOAD_OK then
                        HoseSystemUtil:log(HoseSystemUtil.ERROR, specializationName .. "-specialization 'preLoadHoseSystem' failed!")

                        if asyncCallbackFunction ~= nil then
                            asyncCallbackFunction(asyncCallbackObject, nil, vehicleLoadState, asyncCallbackArguments)
                        end

                        return vehicleLoadState
                    end

                    if not super.hoseSystemLoaded then
                        HoseSystemRegistrationHelper:register(super, typeDef.specializations, vehicleData.filename)
                    end

                    delete(super.xmlFile)
                    super.xmlFile = nil
                end
            --end
        end
    --end
end

To support Mods / Scripts like this:
zzz_ExtendStdVeh_HoseSystem.zip

  • This mod adds to the Kotte TSA Hose System Connectors and Park positions by script.
  • do not need to create an extra zip file with i3d, xml and other files
  • ingame do not need to sell the std vehicle and buy the std mod vehicle
@stijnwop
Copy link
Owner

stijnwop commented Nov 6, 2017

Hey there are reasons why i check on those fields. I don't want to hook into every vehicle.

Also the fact by just deleting the check on nil values which uses a different index to iterate isn't going to be 'safe', if we talk about the range of scripts we currently have available in the modding scene.

Really cool that you want to make a script extension for inserting the functionality into the default vehicles.. but that can be done without touching the main script.

Think about mocking the HoseSystemVehicle.lua and insert that after you did the xml related stuff.

@stijnwop stijnwop self-assigned this Nov 6, 2017
@stijnwop stijnwop removed their assignment Nov 6, 2017
@stijnwop
Copy link
Owner

Added suggestion, but no response to be seen anywhere. ✌️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants