mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
latest changes for descriptors.
This commit is contained in:
@@ -2,7 +2,7 @@ Olympus.unitCounter = 1
|
||||
Olympus.payloadRegistry = {}
|
||||
|
||||
function Olympus.notify(message, displayFor)
|
||||
trigger.action.outText(message, displayFor)
|
||||
-- trigger.action.outText(message, displayFor)
|
||||
end
|
||||
|
||||
-- Gets a unit class reference from a given ObjectID (the ID used by Olympus for unit referencing)
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
|
||||
Olympus = {}
|
||||
Olympus.groupIndex = 0
|
||||
Olympus.groupStep = 40
|
||||
|
||||
function Olympus.notify(message, displayFor)
|
||||
trigger.action.outText(message, displayFor)
|
||||
end
|
||||
@@ -18,30 +21,44 @@ function Olympus.setMissionData(arg, time)
|
||||
end
|
||||
|
||||
-- Units tactical data
|
||||
-- TODO find some way to spread the load of getting this data (split)
|
||||
local unitsData = {}
|
||||
|
||||
local startIndex = Olympus.groupIndex
|
||||
local endIndex = startIndex + Olympus.groupStep
|
||||
local index = 0
|
||||
for groupName, gp in pairs(mist.DBs.groupsByName) do
|
||||
if groupName ~= nil then
|
||||
local group = Group.getByName(groupName)
|
||||
if group ~= nil then
|
||||
local controller = group:getController()
|
||||
for index, unit in pairs(group:getUnits()) do
|
||||
local table = {}
|
||||
table["targets"] = {}
|
||||
table["targets"]["visual"] = controller:getDetectedTargets(1)
|
||||
table["targets"]["radar"] = controller:getDetectedTargets(4)
|
||||
table["targets"]["rwr"] = controller:getDetectedTargets(16)
|
||||
table["targets"]["other"] = controller:getDetectedTargets(2, 8, 32)
|
||||
index = index + 1
|
||||
if index > startIndex then
|
||||
if groupName ~= nil then
|
||||
local group = Group.getByName(groupName)
|
||||
if group ~= nil then
|
||||
local controller = group:getController()
|
||||
for index, unit in pairs(group:getUnits()) do
|
||||
local table = {}
|
||||
table["targets"] = {}
|
||||
table["targets"]["visual"] = controller:getDetectedTargets(1)
|
||||
table["targets"]["radar"] = controller:getDetectedTargets(4)
|
||||
table["targets"]["rwr"] = controller:getDetectedTargets(16)
|
||||
table["targets"]["other"] = controller:getDetectedTargets(2, 8, 32)
|
||||
|
||||
table["hasTask"] = controller:hasTask()
|
||||
|
||||
table["ammo"] = unit:getAmmo()
|
||||
table["fuel"] = unit:getFuel()
|
||||
table["life"] = unit:getLife() / unit:getLife0()
|
||||
unitsData[unit:getObjectID()] = table
|
||||
table["hasTask"] = controller:hasTask()
|
||||
|
||||
table["ammo"] = unit:getAmmo()
|
||||
table["fuel"] = unit:getFuel()
|
||||
table["life"] = unit:getLife() / unit:getLife0()
|
||||
unitsData[unit:getObjectID()] = table
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if index == endIndex then
|
||||
break
|
||||
end
|
||||
end
|
||||
if index ~= endIndex then
|
||||
Olympus.groupIndex = 0
|
||||
else
|
||||
Olympus.groupIndex = endIndex
|
||||
end
|
||||
|
||||
-- Airbases data
|
||||
@@ -69,7 +86,7 @@ function Olympus.setMissionData(arg, time)
|
||||
|
||||
local command = "Olympus.missionData = " .. Olympus.serializeTable(missionData) .. "\n" .. "Olympus.OlympusDLL.setMissionData()"
|
||||
net.dostring_in("export", command)
|
||||
return time + 5
|
||||
return time + 1
|
||||
end
|
||||
|
||||
function Olympus.serializeTable(val, name, skipnewlines, depth)
|
||||
|
||||
61
scripts/payLoadConverter.py
Normal file
61
scripts/payLoadConverter.py
Normal file
@@ -0,0 +1,61 @@
|
||||
import pandas as pd
|
||||
import json
|
||||
|
||||
# Load data from an Excel file
|
||||
df = pd.read_excel('data.xlsx')
|
||||
|
||||
# Group by 'Name', 'Fuel', 'Loadout Name', 'Role', and 'Code' and aggregate 'Items - Name' and 'Items - Quantity'
|
||||
grouped = df.groupby(['Name', 'Fuel', 'Loadout Name', 'Role', 'Code'])['Items - Name', 'Items - Quantity'].agg(lambda x: list(x)).reset_index()
|
||||
|
||||
# Convert the grouped data into the desired format
|
||||
result = {}
|
||||
for index, row in grouped.iterrows():
|
||||
name = row['Name']
|
||||
if name not in result:
|
||||
result[name] = {
|
||||
"name": row['Name'],
|
||||
"label": row['Name'],
|
||||
"loadouts": [
|
||||
{
|
||||
"fuel": row['Fuel'],
|
||||
"items": [
|
||||
{
|
||||
"name": item,
|
||||
"quantity": quantity
|
||||
} for item, quantity in zip(row['Items - Name'], row['Items - Quantity'])
|
||||
],
|
||||
"roles": [row['Role']],
|
||||
"code": row['Code'],
|
||||
"loadout_name": row['Loadout Name']
|
||||
}
|
||||
]
|
||||
}
|
||||
else:
|
||||
found = False
|
||||
for loadout in result[name]["loadouts"]:
|
||||
if loadout["fuel"] == row['Fuel'] and loadout["code"] == row['Code'] and loadout["loadout_name"] == row['Loadout Name']:
|
||||
loadout["items"].extend([
|
||||
{
|
||||
"name": item,
|
||||
"quantity": quantity
|
||||
} for item, quantity in zip(row['Items - Name'], row['Items - Quantity'])
|
||||
])
|
||||
loadout["roles"].append(row['Role'])
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
result[name]["loadouts"].append({
|
||||
"fuel": row['Fuel'],
|
||||
"items": [
|
||||
{
|
||||
"name": item,
|
||||
"quantity": quantity
|
||||
} for item, quantity in zip(row['Items - Name'], row['Items - Quantity'])
|
||||
],
|
||||
"roles": [row['Role']],
|
||||
"code": row['Code'],
|
||||
"loadout_name": row['Loadout Name']
|
||||
})
|
||||
|
||||
# Print the result with the correct indents
|
||||
print(json.dumps(result, indent=2))
|
||||
File diff suppressed because it is too large
Load Diff
12593
scripts/unitPayloads.lua
12593
scripts/unitPayloads.lua
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user