Category | Scripting |
Created | 06.08.2021 04:09 |
Jan Krüger (flusinerd) | 06.08.2021 04:09 |
---|---|
Hello, I want to fetch the fillLevels of the players farm. The reason is: I want to know how much Wheat, Barley etc. is in all Silos that the player owns. I am only caring about the amount that is also displayed in the "Map Menu" under the fruit type. |
Bilbo Beutlin (BBeutlin) | 06.08.2021 06:29 |
---|---|
You must scan the 'g_currentMission.storageSystem' tables. This has the subtables storages, loadingStations, unloadingStations. For reference see in LUADOC/script/objects the related sources. -- example to get the sum of all storage fillLevels of player local allFillLevels = {}; for _,storage in pairs(g_currentMission.storageSystem.storages) do if storage:getOwnerFarmId() == g_currentMission.player.farmId then for fillType, fillLevel in pairs(storage.fillLevels) do allFillLevels[fillType] = (allFillLevels[fillType] or 0) + fillLevel; end; end; end; -- simple console 'print()' the list for fillType, fillLevel in pairs(allFillLevels) do print( g_fillTypeManager.fillTypes[fillType].title .. " : " .. g_i18n:formatNumber(fillLevel, 0, true) ); end; |
Jan Krüger (flusinerd) | 06.08.2021 12:52 |
---|---|
Ty very much :) |
Note: Log in to post. Create a new account here.