Heya,
The shot events seems to not be registering at all. I'm no rust or lua expert but I've tried to debug this as best as I can.
From the logs I can see that the event is being handled by the eventHandler however it does give the following error:
ERROR dcs_grpc: failed to deserialize event: deserialize error: missing field `id`
If I print the weapon.id and weapon.type fields in the debug log by modifying the event function as such:
elseif event.id == world.event.S_EVENT_SHOT then
GRPC.logDebug("Shot event")
weapon_test = exporter(event.weapon)
GRPC.logDebug("Weapon ID: " .. tostring(weapon_test.id))
GRPC.logDebug("Weapon Type: " .. tostring(weapon_test.type))
return {
time = event.time,
event = {
type = "shot",
initiator = {initiator = typed_exporter(event.initiator)},
weapon = exporter(event.weapon)
},
}
The logs will confirm that the id is in fact nil or missing:
2024-05-22 15:32:47.714 DEBUG dcs_grpc: Weapon ID: nil
2024-05-22 15:32:47.714 DEBUG dcs_grpc: Weapon Type: SA2V755
the exporter(event.weapon) should to my understanding reach the following code:
|
GRPC.exporters.weapon = function(weapon) |
What I don't understand is why tonumber is used for the id at:
|
id = tonumber(weapon:getName()), |
The documentation for weapon:getName() returns a string and not an int according to https://wiki.hoggitworld.com/view/DCS_func_getName. So to me it seems like this will always return nil or an empty id unless there's something else going on that I can't figure out.
For testing I've tried to just set the id to 1 which seems to work (I'm mostly interested in the type anyway).
Anyway if someone could either explain to me a bit more about the reasoning for using tonumber and/or explain what I'm missunderstanding here it would be greatly appreciated:) I'm sure there might be other instances where the tonumber for id is causing issues since I see it used for IDs in other places then the weapon.
Thanks
Heya,
The shot events seems to not be registering at all. I'm no rust or lua expert but I've tried to debug this as best as I can.
From the logs I can see that the event is being handled by the eventHandler however it does give the following error:
If I print the weapon.id and weapon.type fields in the debug log by modifying the event function as such:
The logs will confirm that the id is in fact nil or missing:
the exporter(event.weapon) should to my understanding reach the following code:
rust-server/lua/DCS-gRPC/exporters/object.lua
Line 56 in 6621b6d
What I don't understand is why tonumber is used for the id at:
rust-server/lua/DCS-gRPC/exporters/object.lua
Line 58 in 6621b6d
The documentation for weapon:getName() returns a string and not an int according to https://wiki.hoggitworld.com/view/DCS_func_getName. So to me it seems like this will always return nil or an empty id unless there's something else going on that I can't figure out.
For testing I've tried to just set the id to 1 which seems to work (I'm mostly interested in the type anyway).
Anyway if someone could either explain to me a bit more about the reasoning for using tonumber and/or explain what I'm missunderstanding here it would be greatly appreciated:) I'm sure there might be other instances where the tonumber for id is causing issues since I see it used for IDs in other places then the weapon.
Thanks