Samonella's questions: currently unsolved

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.
User avatar
Samonella
Posts: 382
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: move_unit question

Post by Samonella »

Sapient wrote: taking a few peeks into that array should be very speedy, especially when compared to the far greater expense of the initial pathfinding.
That makes sense. Thanks
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Adding events mid-scenario

Post by mattsc »

Samonella wrote:So apparently goto micro_ais don't work if there is shroud blocking the path?
Hey — I don't know if you still care, but this is fixed now. From the Micro AI wiki page:
Wesnoth wiki wrote:Before Wesnoth 1.13.7, the Micro AIs did not all work reliably when the AI side is under shroud and it may have been necessary to turn shroud off for the side when using a Micro AI. (Version 1.13.7 and later only) The Micro AIs now all work for sides under shroud. They do this by disregarding shroud for terrain purposes when path finding, consistent with default Wesnoth AI behavior, while still ignoring hidden units (including those hidden under shroud) correctly.
Of course, 1.13.7 is not quite out yet, but hopefully it won't be too long ...
User avatar
Samonella
Posts: 382
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: Samonella's questions: currently unsolved

Post by Samonella »

New question: my goal is to make a sort of hand-crafted animation that works independently from preferences->accelerated speed. Basically I want to make the animation always play at the same speed, regardless of the player's set preference.
Why I would want to do such a thing:
I do this by using {PLACE_ITEM} to make the frames, with the unit's attack sprites BLIT-ed onto a blank image that's large enough to cover all six hexes he might attack (see the code below). Of course I was initially using [delay] in between each frame, but as I kept removing time between frames, trying to get the right animation speed, I eventually ended up completely removing the [delay]. The code below (without any [delay] at all) actually results in about the speed I want.

(Technically I'm not using {PLACE_ITEM}, instead it's {VOADAR_PLACE_ITEM} which just uses halo= instead of image= so that the image can display over more than one hex. VoaDaR is the acronym of my campaign.)

Code: Select all

	{REMOVE_IMAGE 12 29}
	{VOADAR_PLACE_IMAGE "blank-big.png~BLIT(units/human-peasants/carpenter.png~FL()~RC(magenta>cyan),54,36)" 12 29}
	
	{REMOVE_IMAGE 12 29}
	{VOADAR_PLACE_IMAGE "blank-big.png~BLIT(units/human-peasants/carpenter-melee-1.png~FL()~RC(magenta>cyan),43,30)" 12 29}

	{REMOVE_IMAGE 12 29}
	{VOADAR_PLACE_IMAGE "blank-big.png~BLIT(units/human-peasants/carpenter-melee-2.png~FL()~RC(magenta>cyan),31,24)" 12 29}

	{REMOVE_IMAGE 12 29}
	{VOADAR_PLACE_IMAGE "blank-big.png~BLIT(units/human-peasants/carpenter-melee-3.png~FL()~RC(magenta>cyan),20,18)" 12 29}
	[sound]
		name=axe.ogg
	[/sound]

	{REMOVE_IMAGE 12 29}
	{VOADAR_PLACE_IMAGE "blank-big.png~BLIT(units/human-peasants/carpenter-melee-4.png~FL()~RC(magenta>cyan),8,12)" 12 29}
	
	{REMOVE_IMAGE 12 29}
	{VOADAR_PLACE_IMAGE "blank-big.png~BLIT(units/human-peasants/carpenter-melee-5.png~FL()~RC(magenta>cyan),20,18)" 12 29}

	{REMOVE_IMAGE 12 29}
	{VOADAR_PLACE_IMAGE "blank-big.png~BLIT(units/human-peasants/carpenter-melee-5.png~FL()~RC(magenta>cyan),31,24)" 12 29}

	{REMOVE_IMAGE 12 29}
	{VOADAR_PLACE_IMAGE "blank-big.png~BLIT(units/human-peasants/carpenter-melee-6.png~FL()~RC(magenta>cyan),43,30)" 12 29}

	{REMOVE_IMAGE 12 29}
	{VOADAR_PLACE_IMAGE "blank-big.png~BLIT(units/human-peasants/carpenter.png~FL()~RC(magenta>cyan),54,36)" 12 29}
So my question is why? I'd think that without a [delay] it would cycle through the images invisibly quickly, but a delay is coming from somewhere. Is this just the time it takes my computer to process the IPFs and display the image? In other words, should I be worried about the animation playing faster for someone playing on a faster computer? Or is there some delay built into the redraw that automatically happens?
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
User avatar
Samonella
Posts: 382
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: Samonella's questions: currently unsolved

Post by Samonella »

Hello again.

Could someone please explain exactly what [variable]contains= does? The wiki says it checks that $name contains the given string value, but does it iterate through $name as an array, to see if any entry is identical to the given string? Or does it check whether the given value is a substring of $name? It doesn't seem to work either way for me, it's just always false.
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
User avatar
Ravana
Forum Moderator
Posts: 2950
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Samonella's questions: currently unsolved

Post by Ravana »

I have used it as substring check and it has worked.
User avatar
Samonella
Posts: 382
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: Samonella's questions: currently unsolved

Post by Samonella »

Thanks for pointing me in the right direction. Turns out I just had a $ where it didn't belong. :roll:

Though I think it would be good to clarify that on the wiki.
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
User avatar
Samonella
Posts: 382
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: Samonella's questions: currently unsolved

Post by Samonella »

I have a question about [return].
The wiki wrote:[return]: Control immediately returns to the Wesnoth engine. No further WML actions are executed in this context. If there was another event queued, that event will be run as usual.
Although I'm not completely clear what the intended behavior is, it seems like the message in the following code should definitely display:

Code: Select all

[event]
	name=moveto
	[fire_event]
		name=return_pls
	[/fire_event]
	{DEBUG_MSG "Made it back"}
[/event]
[event]
	name=return_pls
	[return]
	[/return]
[/event]
But it does not. Which seems like undesirable behavior, yes? Is there a way to return without flushing the current event stack down the toilet?
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Samonella's questions: currently unsolved

Post by Tad_Carlucci »

The intention of [return] is that you'd use it in the midst of a long event inside some [if] or loop structure. The idea is to get out of that [event] block without executing anything else.

In your example, you have an [event] which contains just [return]; which is meaningless.

I would admit that "to the Wesnoth engine" is a bit unclear and should be expanded to explain that *all* [event] blocks terminate.
I forked real life and now I'm getting merge conflicts.
User avatar
doofus-01
Art Director
Posts: 4122
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: Samonella's questions: currently unsolved

Post by doofus-01 »

Tad_Carlucci wrote:The intention of [return] is that you'd use it in the midst of a long event inside some [if] or loop structure. The idea is to get out of that [event] block without executing anything else.

In your example, you have an [event] which contains just [return]; which is meaningless.
I'll just point out that there was no way to know that, just from reading the wiki. It's not mentioned at [return], it's not mentioned at [if]/[switch]/[while] etc. Cross-references and clear explanations may be difficult, but wouldn't concrete examples be possible and easy for whoever implemented whatever feature?
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
User avatar
Pentarctagon
Project Manager
Posts: 5531
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Samonella's questions: currently unsolved

Post by Pentarctagon »

I've updated the wiki, in any case.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Samonella
Posts: 382
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: Samonella's questions: currently solved

Post by Samonella »

Pentarctagon wrote:I've updated the wiki, in any case.
Looks good, thanks! Though I probably would have written "please" instead of "pls" if I had known it would end up on the wiki.
Tad_Carlucci wrote:The intention of [return] is that you'd use it in the midst of a long event inside some [if] or loop structure. The idea is to get out of that [event] block without executing anything else.

In your example, you have an [event] which contains just [return]; which is meaningless.
Right, that was just a silly example for making a concise point. Posting my actual code, two events around 100 lines each, would have been pointless. One calls the other, and of course it expects the remainder of itself to be executed regardless of which code paths are taken in the other. Now that I know that's the intended behavior for [return] I guess I'll have to do something messy like wrapping the entire remainder of the second event in an [if].

Kind of defeats the point of [return] if you rarely can use it for fear of messing up other events, doesn't it? It's only useful in very simple situations, when you're not as likely to need it anyway.
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
User avatar
Pentarctagon
Project Manager
Posts: 5531
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Samonella's questions: currently solved

Post by Pentarctagon »

Samonella wrote:
Pentarctagon wrote:I've updated the wiki, in any case.
Looks good, thanks! Though I probably would have written "please" instead of "pls" if I had known it would end up on the wiki.
Fixed :)
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
doofus-01
Art Director
Posts: 4122
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: Samonella's questions: currently solved

Post by doofus-01 »

Samonella wrote:Kind of defeats the point of [return] if you rarely can use it for fear of messing up other events, doesn't it? It's only useful in very simple situations, when you're not as likely to need it anyway.
That's not the conclusion I would draw. No offense to anyone here, but the fact that there is still some confusion illustrates that the example Pentarctagon lifted from Samonella was not helpful and not the kind of example I had in mind.

How about a non-trivial example that shows how to use the feature? (Surely the developer who implemented it had a reason to do so, right?)
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Samonella's questions: currently solved

Post by Tad_Carlucci »

Nor I.

If it were a new tag, I'd quibble over the name: [return] is unfortunate because it has semantics from other programming languages. It means if we ever do add a [function] tag so WML can have true functions, we will either overload the tag with another semantic meaning or we'll need to come up with another tag to do what a function return would do.
I forked real life and now I'm getting merge conflicts.
User avatar
Samonella
Posts: 382
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: Samonella's questions: currently solved

Post by Samonella »

I guess I just don't see the point of the way the [return] tag works right now, why wouldn't you want it to act like return; in any programming language? The only reason you'd want to flush the entire event stack would be if you know precisely which events are on it... and if that's the case, why are they separate events? If the only way the code in event 2 should execute is if event 1 called it in a particular way, doesn't that code belong in event 1?
doofus-01 wrote:How about a non-trivial example that shows how to use the feature? (Surely the developer who implemented it had a reason to do so, right?)
Yeah, this would be nice. Like I said, I'm just not convinced that you'd need, let alone want, a tag that dumps all stacked events. I could post my non-trivial example for wanting to return without said dump, but I think everyone already appreciates this typical (non wml) use of the 'return' keyword.
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
Post Reply