Community Forum

Telemetry - fillable info

Forum Overview >> Scripting

CategoryScripting
Created01.07.2022 17:18


LOWEL97 01.07.2022 17:18
Hi, how can I get info about filltype, fillcapacity and fillvolume / filllevel?

I search a lot but nothing works :/

I can paste here my code if needed

Bilbo Beutlin (BBeutlin) 02.07.2022 14:28
All necessary infos you'll find in the gameSource.zip (FSuser:debugger or FSinstall:sdk/debugger).
For your concern begin with dataS/scripts/vehicles/specializations/FillUnit.lua

LOWEL97 03.07.2022 01:18
Thank you for your response ;)

I found what you say about but now I have this error:

Error: Running LUA method 'update'.
dataS/scripts/vehicles/specializations/FillUnit.lua(793) : attempt to index local 'spec' (a nil value)

This is the 793 line in FillUnit.lua:

-- Line790
function FillUnit:getFillUnitCapacity(fillUnitIndex)
local spec = self.spec_fillUnit
if spec.fillUnits[fillUnitIndex] ~= nil then -- here is the error
return spec.fillUnits[fillUnitIndex].capacity
end
return nil
end
-- Line 798


Here is my code

for _, implement in pairs(attachedImplements) do
local object = implement.object
if object ~= nil and object.schemaOverlay ~= nil then

local capacity = {};
capacity = object.getFillUnitCapacity ~= nil and FillUnit:getFillUnitCapacity(object.fillUnitIndex);

local fillLevel = {};
fillLevel = object.getFillUnitFillLevel ~= nil and FillUnit:getFillUnitFillLevel(object.fillUnitIndex);

local fillType = {};
fillType = object.getFillUnitFillType ~= nil and FillUnit:getFillUnitFillType(object.fillUnitIndex);

local jointDesc = vehicle.schemaOverlay.attacherJoints[implement.jointDescIndex];
if jointDesc ~= nil then
local invertX = invertX ~= jointDesc.invertX
local baseX
if invertX then
baseX = x - 1 + (1 - jointDesc.x)
else
baseX = x + jointDesc.x
end
baseX = math.ceil(baseX);

FSContext.Telemetry.AttachedImplementsFillCapacity[baseX] = capacity;
FSContext.Telemetry.AttachedImplementsFillLevel[baseX] = fillLevel;
FSContext.Telemetry.AttachedImplementsFillType[baseX] = fillType;


if FSContext.MaxDepthImplements > depth then
FSTelemetry:ProcessAttachedImplements(object, invertX, baseX, depth + 1)
end

end
end
end


I just need fillUnitIndex of the implement (like sprayer) and vehicle (like harvester).

LOWEL97 03.07.2022 01:31
Thank you for your response ;)

I found what you say about but now I have this error:

Error: Running LUA method 'update'.
dataS/scripts/vehicles/specializations/FillUnit.lua(793) : attempt to index local 'spec' (a nil value)

This is the 793 line in FillUnit.lua:

-- Line790
function FillUnit:getFillUnitCapacity(fillUnitIndex)
local spec = self.spec_fillUnit
if spec.fillUnits[fillUnitIndex] ~= nil then -- here is the error
return spec.fillUnits[fillUnitIndex].capacity
end
return nil
end
-- Line 798


Here is my code

for _, implement in pairs(attachedImplements) do
local object = implement.object
if object ~= nil and object.schemaOverlay ~= nil then

local capacity = {};
capacity = object.getFillUnitCapacity ~= nil and FillUnit:getFillUnitCapacity(object.fillUnitIndex);

local fillLevel = {};
fillLevel = object.getFillUnitFillLevel ~= nil and FillUnit:getFillUnitFillLevel(object.fillUnitIndex);

local fillType = {};
fillType = object.getFillUnitFillType ~= nil and FillUnit:getFillUnitFillType(object.fillUnitIndex);

local jointDesc = vehicle.schemaOverlay.attacherJoints[implement.jointDescIndex];
if jointDesc ~= nil then
local invertX = invertX ~= jointDesc.invertX
local baseX
if invertX then
baseX = x - 1 + (1 - jointDesc.x)
else
baseX = x + jointDesc.x
end
baseX = math.ceil(baseX);

FSContext.Telemetry.AttachedImplementsFillCapacity[baseX] = capacity;
FSContext.Telemetry.AttachedImplementsFillLevel[baseX] = fillLevel;
FSContext.Telemetry.AttachedImplementsFillType[baseX] = fillType;


if FSContext.MaxDepthImplements > depth then
FSTelemetry:ProcessAttachedImplements(object, invertX, baseX, depth + 1)
end

end
end
end


I just need fillUnitIndex of the implement (like sprayer) and vehicle (like harvester).

LOWEL97 03.07.2022 01:31
Thank you for your response ;)

I found what you say about but now I have this error:

Error: Running LUA method 'update'.
dataS/scripts/vehicles/specializations/FillUnit.lua(793) : attempt to index local 'spec' (a nil value)

This is the 793 line in FillUnit.lua:

-- Line790
function FillUnit:getFillUnitCapacity(fillUnitIndex)
local spec = self.spec_fillUnit
if spec.fillUnits[fillUnitIndex] ~= nil then -- here is the error
return spec.fillUnits[fillUnitIndex].capacity
end
return nil
end
-- Line 798


Here is my code

for _, implement in pairs(attachedImplements) do
local object = implement.object
if object ~= nil and object.schemaOverlay ~= nil then

local capacity = {};
capacity = object.getFillUnitCapacity ~= nil and FillUnit:getFillUnitCapacity(object.fillUnitIndex);

local fillLevel = {};
fillLevel = object.getFillUnitFillLevel ~= nil and FillUnit:getFillUnitFillLevel(object.fillUnitIndex);

local fillType = {};
fillType = object.getFillUnitFillType ~= nil and FillUnit:getFillUnitFillType(object.fillUnitIndex);

local jointDesc = vehicle.schemaOverlay.attacherJoints[implement.jointDescIndex];
if jointDesc ~= nil then
local invertX = invertX ~= jointDesc.invertX
local baseX
if invertX then
baseX = x - 1 + (1 - jointDesc.x)
else
baseX = x + jointDesc.x
end
baseX = math.ceil(baseX);

FSContext.Telemetry.AttachedImplementsFillCapacity[baseX] = capacity;
FSContext.Telemetry.AttachedImplementsFillLevel[baseX] = fillLevel;
FSContext.Telemetry.AttachedImplementsFillType[baseX] = fillType;


if FSContext.MaxDepthImplements > depth then
FSTelemetry:ProcessAttachedImplements(object, invertX, baseX, depth + 1)
end

end
end
end


I just need fillUnitIndex of the implement (like sprayer) and vehicle (like harvester).


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