Skip to content

Commit

Permalink
Prevent errors when unloading to animal husbandaries
Browse files Browse the repository at this point in the history
Issue  #4
  • Loading branch information
schliesser committed Sep 20, 2024
1 parent 7b42bbf commit bae00b1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scripts/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function TargetFillLevel:hasDischargeTarget(vehicle, display)

-- Show target fill level for shovels, unload triggers,...
local dischargeable = vehicle.spec_dischargeable
local dischargeNode = dischargeable.currentDischargeNode
local dischargeNode = dischargeable:getCurrentDischargeNode()
tflPrint('I\'m a vehicle with a Dischargeable!')

-- Show only discharges to objects. There is no level when dumping on the ground
Expand All @@ -87,13 +87,13 @@ function TargetFillLevel:hasDischargeTarget(vehicle, display)
end

-- Get discharge target object
local target = dischargeNode.dischargeObject
local target = dischargeable:getCurrentDischargeObject(dischargeNode)
if target == nil then
tflPrint('No discharge object in trigger!')
return false
end

if target.getFillUnitFillLevelTFL ~= nil and target.getFillUnitCapacityTFL then
if target.getFillUnitFillLevelTFL ~= nil and target.getFillUnitCapacityTFL ~= nil then
-- Calculate fill level for storages / productions
local fillLevel = target:getFillUnitFillLevelTFL(dischargeNode.dischargeFillUnitIndex, dischargeable:getDischargeFillType(dischargeNode), dischargeable:getActiveFarm())
local capacity = target:getFillUnitCapacityTFL(dischargeNode.dischargeFillUnitIndex, dischargeable:getDischargeFillType(dischargeNode), dischargeable:getActiveFarm())
Expand Down Expand Up @@ -203,7 +203,7 @@ end

-- Add helper functions to UnloadTrigger objects
function UnloadTrigger:getFillUnitFillLevelTFL(fillUnitIndex, fillTypeIndex, farmId)
if self.target.getFreeCapacity ~= nil then
if self.target.getFillLevel ~= nil then
local conversion = self.fillTypeConversions[fillTypeIndex]

if conversion ~= nil then
Expand All @@ -217,7 +217,7 @@ function UnloadTrigger:getFillUnitFillLevelTFL(fillUnitIndex, fillTypeIndex, far
end

function UnloadTrigger:getFillUnitCapacityTFL(fillUnitIndex, fillTypeIndex, farmId)
if self.target.getFreeCapacity ~= nil then
if self.target.getCapacity ~= nil then
local conversion = self.fillTypeConversions[fillTypeIndex]

if conversion ~= nil then
Expand Down

0 comments on commit bae00b1

Please sign in to comment.