I thought I would share, I mod'd ur code to sort the recipes, this is the code for it.
`local elementTable = {}
for i, element in pairs(elements) do
local elementData = {}
local statusData = json.decode(core.getElementIndustryStatus(element.id))
local recipeName = "-"
if not (element.type:lower() == 'transfer unit') then
if loadedRecipes[statusData.schematicId] then
recipeName = loadedRecipes[statusData.schematicId]
else
if has_value(recipeToLoad,statusData.schematicId) == false then
table.insert(recipeToLoad, statusData.schematicId)
end
end
end
local remainingTime = 0
if (statusData) and (statusData.remainingTime) and (statusData.remainingTime <= (3600*24*365)) then
remainingTime = statusData.remainingTime
end
element.recipeName = recipeName
element.remainingTime = remainingTime
element.status = statusData.state
element.unitsProduced = statusData.unitsProduced
local mode = ""
element.maintainProductAmount = statusData.maintainProductAmount
element.batchesRequested = statusData.batchesRequested
if statusData.maintainProductAmount > 0 then
mode = "Maintain " .. math.floor(statusData.maintainProductAmount)
elseif statusData.batchesRequested > 0 and statusData.batchesRequested <= 99999999 then
mode = "Produce " .. math.floor(statusData.batchesRequested)
end
local status = "-"
if element.status then status = element.status end
local status_class = ""
if status:lower():find("running") then status_class = "text-success" end
if status:lower():find("stopped") then status_class = "text-info" end
if status:lower():find("jammed") then status_class = "text-danger" end
if status:lower():find("pending") then status_class = "text-primary" end
status = status:gsub("JAMMED_", ""):gsub("_", " ")
hud_machines = hud_machines .. [[<tr]]
if selected_machine_index == i then
hud_machines = hud_machines .. [[ class="selected"]]
end
local machine_id = "-"
if element.id then machine_id = element.id end
local unitsProduced = 0
if element.unitsProduced then unitsProduced = element.unitsProduced end
elementData.Machine_id = machine_id
elementData.Status_Class = status_class
elementData.ElementName = element.name
elementData.recipeName = recipeName
elementData.unitsProduced = unitsProduced
elementData.status_class =status_class
elementData.status=status
elementData.mode=mode
elementData.status_class = status_class
elementData.TimeRemaining = SecondsToClockString(element.remainingTime)
table.insert(elementTable,0,elementData)
end
table.sort(elementTable, function(a,b) return a.recipeName:lower() < b.recipeName:lower() end)
for i, element in pairs(elements) do
hud_machines = hud_machines .. [[>
<th>]] .. element.Machine_id .. [[</th>
<th class="]] .. element.Status_Class .. [[">]] .. element.ElementName .. [[</th>
<th>]] .. element.recipeName .. [[</th>
<td>]] .. element.unitsProduced .. [[</td>
<th class="]] .. element.status_class .. [[">]] .. element.status .. [[</th>
<th>]] .. element.mode .. [[</th>
<td class="]] .. element.status_class .. [[">]] .. element.TimeRemaining .. [[</td>
</tr>
]]
end`