Courseplay: FabrikScript Suggestion

Created on 31 Dec 2016  路  4Comments  路  Source: Courseplay/courseplay

When No Mod phase is over would you add support for FabrikScript

Taken from log:

Error: Running LUA method 'update'.
.../FarmingSimulator2017/mods/Fermenter_placeable/FabrikScript.lua:1202: attempt to compare number with table

it happens every time i use CP to unload at trigger and the game crash. if i dont use CP to unload at trigger it works.

Most helpful comment

i have a solution for you.
this function is passed the wrong input params
it seems like before the trailer param there is another param. so everything is shifted by one.

if you replace the function with this version below it should work

function FabrikScript:addFillLevelFromTool(trailer, fillDelta, fillType, toolType)
    if DebugEbene > 1 then
        print("trailer: " .. tostring(trailer))
        print("fillDelta: " .. tostring(fillDelta))
        print("fillType: " .. tostring(fillType))
        print("toolType: " .. tostring(toolType))
    end
    if type(fillDelta) == "table" then
        Debug(10, "addFillLevelFromTool filldelta is table")
        trailer = fillDelta
        fillDelta = fillType
        fillType = toolType
        toolType = nil
    end
    local trigger = self.trailerTipTrigger[trailer]
    Debug(10, "addFillLevelFromTool fillDelta %s fillType %d", fillDelta, fillType);
    if fillDelta ~= nil and fillDelta > 0 and trigger ~= nil then
        if trigger.fillLevel ~= nil then
            local name = trigger.TipTrigger.Rohstoffname;
            trigger.fillLevel = self:getFillLevel(name, true);
            local maxFillDelta = math.min(fillDelta, trigger.capacity - trigger.fillLevel)
            self:setFillLevel(trigger, trigger.fillLevel + maxFillDelta, fillType, true, name);
            Debug(10, "addFillLevelFromTool maxFillDelta %d", maxFillDelta);
            return maxFillDelta;
        else
            return 0;
        end;
    else
        return 0;
    end;

end;

FabrikScript.lua.txt

All 4 comments

i have a solution for you.
this function is passed the wrong input params
it seems like before the trailer param there is another param. so everything is shifted by one.

if you replace the function with this version below it should work

function FabrikScript:addFillLevelFromTool(trailer, fillDelta, fillType, toolType)
    if DebugEbene > 1 then
        print("trailer: " .. tostring(trailer))
        print("fillDelta: " .. tostring(fillDelta))
        print("fillType: " .. tostring(fillType))
        print("toolType: " .. tostring(toolType))
    end
    if type(fillDelta) == "table" then
        Debug(10, "addFillLevelFromTool filldelta is table")
        trailer = fillDelta
        fillDelta = fillType
        fillType = toolType
        toolType = nil
    end
    local trigger = self.trailerTipTrigger[trailer]
    Debug(10, "addFillLevelFromTool fillDelta %s fillType %d", fillDelta, fillType);
    if fillDelta ~= nil and fillDelta > 0 and trigger ~= nil then
        if trigger.fillLevel ~= nil then
            local name = trigger.TipTrigger.Rohstoffname;
            trigger.fillLevel = self:getFillLevel(name, true);
            local maxFillDelta = math.min(fillDelta, trigger.capacity - trigger.fillLevel)
            self:setFillLevel(trigger, trigger.fillLevel + maxFillDelta, fillType, true, name);
            Debug(10, "addFillLevelFromTool maxFillDelta %d", maxFillDelta);
            return maxFillDelta;
        else
            return 0;
        end;
    else
        return 0;
    end;

end;

FabrikScript.lua.txt

you can follow the german disccusion with the fabrikscript modder here: http://marhu.net/phpBB3/viewtopic.php?f=204&t=5236&start=150

can we close here ?

Yes you may close the topic

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MicaelJarniac picture MicaelJarniac  路  4Comments

MicaelJarniac picture MicaelJarniac  路  4Comments

mawie picture mawie  路  5Comments

huseyinsayar picture huseyinsayar  路  3Comments

VatriXxX picture VatriXxX  路  3Comments