Open IOExceptional opened 1 month ago
Hello @IOExceptional, thanks for your report! I fixed field name in the error, however you still can't access arrays and vectors directly, only their elements.
What you can do now is:
for i in 0..4 {
let bits: u8 = entity
.get_property_by_name(&format!("m_nHeroAbilityUpgradeBits.{:04}", i))?
.try_into()?;
...
}
Or use macro:
for i in 0..4 {
let bits: u8 = property!(entity, "m_nHeroAbilityUpgradeBits.{:04}", i);
...
}
I don't really like it, so I think I'll open a PR and try to make a more flexible way to access fields, something like that:
for x in entity.get_field("m_nHeroAbilityUpgradeBits")?.iter() {
let bits: u8 = x.value()?.try_into()?;
...
}
and
let bits: u8 = entity.get_field("m_nHeroAbilityUpgradeBits.0000")?.value()?.try_into()?;
That's super helpful, thanks a lot!
I actually hadn't even realised it was an array value, but that makes sense why it worked with a lot of other properties
Added the above as a new example in the dl-examples and it prints out;
Hero upgrade bits: Err(PropertyNameNotFound("m_nHeroAbilityUpgradeBitsm_flSimulationTime", "CCitadelPlayerController", "74"))