WML questions: invalid wml

The place to post your WML questions and answers.

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.
Post Reply
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: Question: halo and item images, undo ai?

Post by battlestar »

Spoiler:
New question: Could a unit display custom status icons similar to "petrified" etc.?

Thanks.
LUA: Llama Under Apprenticeship
Hell faction: completed
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Question: halo and item images, undo ai?

Post by Sapient »

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."
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: Question: halo and item images, undo ai?

Post by battlestar »

Didn't realize that's there, I've been looking at the WML wiki. Thanks.
LUA: Llama Under Apprenticeship
Hell faction: completed
User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm
Location: The past

Re: Question: halo and item images, undo ai?

Post by 8680 »

Stick that Lua snippet, appropriately modified, in the file with the other one, if you haven’t already.
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: Question: halo and item images, undo ai?

Post by battlestar »

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
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: Question: halo and item images, undo ai?

Post by battlestar »

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,
LUA: Llama Under Apprenticeship
Hell faction: completed
User avatar
Elvish_Hunter
Posts: 1600
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Question: halo and item images, undo ai?

Post by Elvish_Hunter »

battlestar wrote:Is there a way to modify all variables within a tag without doing each one individually?
You need to use a FOREACH ... NEXT cycle for that purpose. And about your two examples, also EffectWML is a solution.
Last edited by Elvish_Hunter on September 28th, 2012, 1:55 pm, edited 1 time in total.
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)
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: Question: halo and item images, undo ai?

Post by battlestar »

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
User avatar
Elvish_Hunter
Posts: 1600
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Question: halo and item images, undo ai?

Post by Elvish_Hunter »

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:

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]
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.
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)
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: Question: halo and item images, undo ai?

Post by battlestar »

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,
LUA: Llama Under Apprenticeship
Hell faction: completed
User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm
Location: The past

Re: Question: halo and item images, undo ai?

Post by 8680 »

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.
Would this work? It seems the obvious solution, so I suppose there’s something I’m missing.
Spoiler:
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: Question: halo and item images, undo ai?

Post by battlestar »

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]?

Code: Select all

		[effect]
			apply_to=attack
			increase_damage=1
		[/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.
LUA: Llama Under Apprenticeship
Hell faction: completed
User avatar
Crendgrim
Moderator Emeritus
Posts: 1328
Joined: October 15th, 2010, 10:39 am
Location: Germany

Re: Question: halo and item images, undo ai?

Post by Crendgrim »

Yes, in certain events. See VariablesWML#Automatically_Stored_Variables for more information.
UMC Story Images — Story images for your campaign!
User avatar
battlestar
Posts: 690
Joined: January 1st, 2007, 7:12 am

Re: Question: halo and item images, undo ai?

Post by battlestar »

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.
LUA: Llama Under Apprenticeship
Hell faction: completed
User avatar
pyrophorus
Posts: 533
Joined: December 1st, 2010, 12:54 pm

Re: Question: halo and item images, undo ai?

Post by pyrophorus »

Hi !
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?
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: 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 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: 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.
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.
Friendly,
Post Reply