I'm trying to dynamically determine the "damage-type" of the cursor's item stack. For example, if holding a "poison-capsule", I want to find the damage-type "poison".
However, for poison capsules, the damage isn't done by the thrown attack_parameters, but rather from a smoke-with-trigger that has an `action` that deals poison. I am unable to get access to the `smoke-with-trigger` action.
I'm also having a similar difficulty accessing the `land-mine` action and the `artillery-projectile` action.
Access to entity prototype's "action" field
Re: Access to entity prototype's "action" field
I was able to create a workaround where I create an `ammo-type` for the action.
However, this had a different problem where the "nested-result" effect had a type of "nil", and I couldn't retrieve the underlying action.
However, this had a different problem where the "nested-result" effect had a type of "nil", and I couldn't retrieve the underlying action.
Re: Access to entity prototype's "action" field
All of this is readable from the prototypes already.
If you want to get ahold of me I'm almost always on Discord.
Re: Access to entity prototype's "action" field
To give more info, LuaEntityPrototype::attack_result provides the action of the smoke-with-trigger, landmine and artillery-projectile (and more).
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: Access to entity prototype's "action" field
Thank you. The issue seems to be that the "nested-result" TriggerEffectItem has a type of nil. This code logs the nil type:
I can access the `action` field, so my original issue is resolved. However, the missing type should be still fixed to avoid future confusion.
Code: Select all
for _,prototype in pairs({game.entity_prototypes["land-mine"]}) do
for a_index,trigger_item in pairs(prototype.attack_result or {}) do
for d_index,trigger_delivery in pairs(trigger_item.action_delivery or {}) do
for _, effects_key in pairs({"source_effects", "target_effects"}) do
for e_index, trigger_effect_item in pairs(trigger_delivery[effects_key] or {}) do
log("game.entity_prototypes[" .. prototype.name .. "]"
.. ".attack_result[" .. a_index .. "]"
.. ".action_delivery[" .. d_index .. "]"
.. "." .. effects_key .. "[" .. e_index .. "].type=" .. serpent.line(trigger_effect_item.type) )
end
end
end
end
end
Re: Access to entity prototype's "action" field
Seems like there are more nuances with `nested_result`. Sometimes it has an `action` and sometimes it's just an array of TriggerEffectItem.