[solved] attacker_weapon_index
Moderator: Forum Moderators
- Celtic_Minstrel
- Developer
- Posts: 2371
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: [solved] attacker_weapon_index
A for loop to get the index is probably best in any case, as it means you can loop over
unit.attacks
(using ipairs()
) instead of wml.child_range(unit.__cfg, "attack")
.-
- Posts: 1456
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: [solved] attacker_weapon_index
This has always bugged me (attacks vs [attack]+), though I can't quite put a finger on it. It's just [attack] in [unit] or the gamestate_inspector, so if I didn't know any better, where would I come up with unit.attacks[x] ? I mean, it's kind of sort of maybe intuitive, at least in English, but it seems to me like something you'd hit upon by accident (or example) and then just "go with" because you've seen it before.Celtic_Minstrel wrote: ↑June 27th, 2024, 12:37 pm A for loop to get the index is probably best in any case, as it means you can loop overunit.attacks
(usingipairs()
) instead ofwml.child_range(unit.__cfg, "attack")
.
And then there's the use of "weapon" in places like attacker_hits, where it's really referring to the attack?
Speak softly, and carry Doombringer.
Re: [solved] attacker_weapon_index
It looks like the official documentation for it is here:white_haired_uncle wrote: ↑June 27th, 2024, 3:23 pm This has always bugged me (attacks vs [attack]+), though I can't quite put a finger on it. It's just [attack] in [unit] or the gamestate_inspector, so if I didn't know any better, where would I come up with unit.attacks[x] ?
https://wiki.wesnoth.org/LuaAPI/types/unit#Unit_sub-tables