WML questions: invalid wml
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: Question: halo and item images, undo ai?
Spoiler:
Thanks.
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
Re: Question: halo and item images, undo ai?
You did see the sticky thread for "Creating new unit statuses and getting them to show," didn't you?
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: Question: halo and item images, undo ai?
Didn't realize that's there, I've been looking at the WML wiki. Thanks.
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
Re: Question: halo and item images, undo ai?
Stick that Lua snippet, appropriately modified, in the file with the other one, if you haven’t already.
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: Question: halo and item images, undo ai?
Yeah, I'm planning to stick it with the other one, when Ceres gets back to me on it. He is doing the spells, which this snippet is for.
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: Question: halo and item images, undo ai?
Is there a way to modify all variables within a tag without doing each one individually? For example, adding 5 to all defense values in a unit variable, or -20 in all resistance.
Thanks,
Thanks,
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
- Elvish_Hunter
- Posts: 1600
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: Question: halo and item images, undo ai?
You need to use a FOREACH ... NEXT cycle for that purpose. And about your two examples, also EffectWML is a solution.battlestar wrote:Is there a way to modify all variables within a tag without doing each one individually?
Last edited by Elvish_Hunter on September 28th, 2012, 1:55 pm, edited 1 time in total.
Reason: Fixed BBCode [ url ] tag
Reason: Fixed BBCode [ url ] tag
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: Question: halo and item images, undo ai?
Thanks, and what would you put in the FOREACH...NEXT cycle to cover for variables with different names?
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
- Elvish_Hunter
- Posts: 1600
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: Question: halo and item images, undo ai?
That's a bit tricky. You need to know the variable names anyway. For example, I used [set_variables] to modify the resistances of all the units:
Otherwise, you should be able to do something to that effect using Lua, accessing the unit's .__cfg.__literal field, then using helper.get_child (or helper.child_range), and then using the pairs function on that child (pairs returns key-value pairs, while ipairs returns index-value pairs).
Also, don't forget that, for units, [modify_unit] usually is a better option.
Code: Select all
[event]
name=start
[store_unit]
[filter]
# all
[/filter]
variable=stored_units
kill=no
[/store_unit]
{FOREACH stored_units i}
[set_variables]
name=stored_units[$i].resistance
mode=replace
[value]
arcane="$($stored_units[$i].resistance.arcane+5)"
cold="$($stored_units[$i].resistance.cold+5)"
fire="$($stored_units[$i].resistance.fire+5)"
pierce="$($stored_units[$i].resistance.pierce+5)"
impact="$($stored_units[$i].resistance.impact+5)"
blade="$($stored_units[$i].resistance.blade+5)"
[/value]
[/set_variables]
[unstore_unit]
variable=stored_units[$i]
find_vacant=no
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE stored_units}
[/event]
Also, don't forget that, for units, [modify_unit] usually is a better option.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: Question: halo and item images, undo ai?
Thanks Elvish Hunter.
Answer found: Could a single unit own both Regeneration +2 and Regeneration +4 skills? If so, would that unit recover 6 hp a turn? --- yes, and no.
New question:
Are there any consequences to having negative resistance values? So far it seems to me that it behaves as if 1 was the value for negative and 0 values. In other words, is there any reason to intentionally keep the value above 0?
On the other hand, defense seems to take the absolute value of the stored variable so it behaves strangely with a negative value.
Another question:
How do I filter for the newest recruited unit? ie. In the context of modifying every new unit with extra hp as they are recruited.
Thanks,
Answer found: Could a single unit own both Regeneration +2 and Regeneration +4 skills? If so, would that unit recover 6 hp a turn? --- yes, and no.
New question:
Are there any consequences to having negative resistance values? So far it seems to me that it behaves as if 1 was the value for negative and 0 values. In other words, is there any reason to intentionally keep the value above 0?
On the other hand, defense seems to take the absolute value of the stored variable so it behaves strangely with a negative value.
Another question:
How do I filter for the newest recruited unit? ie. In the context of modifying every new unit with extra hp as they are recruited.
Thanks,
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
Re: Question: halo and item images, undo ai?
Would this work? It seems the obvious solution, so I suppose there’s something I’m missing.battlestar wrote:How do I filter for the newest recruited unit? ie. In the context of modifying every new unit with extra hp as they are recruited.
Spoiler:
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: Question: halo and item images, undo ai?
Thanks, that worked well.
Previous question:
Are there any consequences to having negative resistance values? So far it seems to me that it behaves as if 1 was the value for negative and 0 values. In other words, is there any reason to intentionally keep the value above 0?
New question:
Can [modify_unit] modify all of a unit's attack values, as could be done with [effect]?
Another question:
Is there a variable where the attack weapon from most recent attack is automatically stored? ie. harming a victim for the damage (with correct alignment value and damage_type if necessary) it just received with [harm_unit] in a name=attacker hits [event], where the damage depended on player's choice of attack weapon.
Previous question:
Are there any consequences to having negative resistance values? So far it seems to me that it behaves as if 1 was the value for negative and 0 values. In other words, is there any reason to intentionally keep the value above 0?
New question:
Can [modify_unit] modify all of a unit's attack values, as could be done with [effect]?
Code: Select all
[effect]
apply_to=attack
increase_damage=1
[/effect]
Is there a variable where the attack weapon from most recent attack is automatically stored? ie. harming a victim for the damage (with correct alignment value and damage_type if necessary) it just received with [harm_unit] in a name=attacker hits [event], where the damage depended on player's choice of attack weapon.
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
Re: Question: halo and item images, undo ai?
Yes, in certain events. See VariablesWML#Automatically_Stored_Variables for more information.
UMC Story Images — Story images for your campaign!
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: Question: halo and item images, undo ai?
Thanks, I've been looking for those.
Question remains:
Are there any consequences to having negative resistance values? So far it seems to me that it behaves as if 1 was the value for negative and 0 values. In other words, is there any reason to intentionally keep the value above 0?
Much appreciated if someone could shed some light on this, it's very important to how some of my intended codes would interact with each other.
Question remains:
Are there any consequences to having negative resistance values? So far it seems to me that it behaves as if 1 was the value for negative and 0 values. In other words, is there any reason to intentionally keep the value above 0?
Much appreciated if someone could shed some light on this, it's very important to how some of my intended codes would interact with each other.
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
- pyrophorus
- Posts: 533
- Joined: December 1st, 2010, 12:54 pm
Re: Question: halo and item images, undo ai?
Hi !
Friendly,
Resistances are percentages, so negative values are meaningless and probably filtered and replaced to avoid errors (I don't checked Wesnoth code: just my two cents).battlestar wrote:Thanks, that worked well.
Previous question:
Are there any consequences to having negative resistance values? So far it seems to me that it behaves as if 1 was the value for negative and 0 values. In other words, is there any reason to intentionally keep the value above 0?
I never found a way to do this with [modify_unit], AFAICS one must use an [object] tag instead, but you probably know that.battlestar wrote: New question:
Can [modify_unit] modify all of a unit's attack values, as could be done with [effect]?Code: Select all
[effect] apply_to=attack increase_damage=1 [/effect]
I must admit I don't clearly see what you intend to do (except finding which weapon is actually used in an attack). Maybe more informations could be found using Lua interface.battlestar wrote: Another question:
Is there a variable where the attack weapon from most recent attack is automatically stored? ie. harming a victim for the damage (with correct alignment value and damage_type if necessary) it just received with [harm_unit] in a name=attacker hits [event], where the damage depended on player's choice of attack weapon.
Friendly,
HowTos: WML filtering, WML variables