Enter hex event and allow undo

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
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Enter hex event and allow undo

Post by WhiteWolf »

Hi,

I've been trying to debug this, but I've given up, I need help.
This code:

Code: Select all

[event]
	name=enter hex
	first_time_only=no
	[filter]
		side=1
		[not]
			race=bat,drake
		[/not]
		[filter_location]
			[not]
				terrain=W*,Ss
			[/not]
		[/filter_location]
	[/filter]
	[filter_condition]
		[variable]
			name=global_soldier_sounds
			equals=enabled
		[/variable]
	[/filter_condition]

	{RANDOM_VARIABLE footstep (00,01,02,03,04,05,06,07,08,09)}
	[sound]
		name=footsteps/Footstep_Dirt_$footstep|.ogg
	[/sound]
	{CLEAR_VARIABLE footstep}
	[allow_undo]
	[/allow_undo]
[/event]
Is a fragment of a larder util, which allows soldiers to speak when selected, moved, and make footstep sounds.
The problem is, that this piece of code always cancels any ability to undo a move. And I don't get it why.
If global_soldier_sounds is disabled through a menu item, then the undo works. If it's enabled and this event fires, no undo can be done.

Is this a wesnoth bug, or am I missing something?
I'm using wesnoth 1.12.6

Thanks for your help,
WhiteWolf
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Enter hex event and allow undo

Post by Ravana »

WML random invalidates undo.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Enter hex event and allow undo

Post by WhiteWolf »

So I see.
What would then be a workaround? Can [sound]name= take a comma separated list from which it can choose one random sound? (it's not detailed in the wiki what a comma-separated list would mean)
Or is the only way to somehow write a "custom random generator", that yields a number for example from $x1 and $y1 with a tricky formula? And then [switch] on this number to determine the sound.
Any other ways?
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Enter hex event and allow undo

Post by Ravana »

I guess formula could work, but easier to just use lua.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Enter hex event and allow undo

Post by zookeeper »

WhiteWolf wrote:Can [sound]name= take a comma separated list from which it can choose one random sound?
Yes.

name=footsteps/Footstep_Dirt_00.ogg,footsteps/Footstep_Dirt_01.ogg,footsteps/Footstep_Dirt_02.ogg,footsteps/Footstep_Dirt_03.ogg
WhiteWolf wrote:(it's not detailed in the wiki what a comma-separated list would mean)
If you don't know what it means, how did you think to ask if it can be used here?
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Enter hex event and allow undo

Post by WhiteWolf »

Thanks.
What I meant was that here it doesn't say what it does. Without having tried it, I guessed it could mean playing all of the list elements in the specified order (since there is also a repeat attribute to make loops), which is not what I wanted... sorry if the question was obviously stupid...
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Post Reply