Xudo questions about 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.
User avatar
Xudo
Posts: 563
Joined: April 3rd, 2009, 5:26 pm

Xudo questions about WML.

Post by Xudo »

When I check stderr.txt, I face strange error.
Spoiler:
All pieces of code, what can be linked to this problem:
Spoiler:
What can be a reason for this error?
Last edited by Xudo on September 17th, 2014, 2:56 pm, edited 4 times in total.
User avatar
SkyOne
Posts: 1310
Joined: January 3rd, 2009, 7:23 pm

Re: Something goes wrong, but I don't know what. Help, please.

Post by SkyOne »

To me, that error message usually appears when something is wrong on the unit type(s) in the [side] tag(s), but I am not really sure.
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Something goes wrong, but I don't know what. Help, please.

Post by zookeeper »

Unsurprisingly, it's this bit:

Code: Select all

variable=floor[6][1]
That's simply not valid syntax. There are no multi-dimensional arrays in WML. If you need a 2-dimensional array, then you need to use something like variable=floor[6].foo[1].

However, the last time I tried, it was impossible to store a unit into a sub-array in the first place. That is, variable=foo[1] simply won't work. I'm sure you can work around that by storing it into a regular variable/array first (variable=foo) and then using [set_variables] to copy it into whatever sub-array you want to place it in.
User avatar
Gambit
Loose Screw
Posts: 3266
Joined: August 13th, 2008, 3:00 pm
Location: Dynamica
Contact:

Re: Something goes wrong, but I don't know what. Help, please.

Post by Gambit »

It is also possible, though a bit complicated, to turn units into strings and rebuild them.
User avatar
Xudo
Posts: 563
Joined: April 3rd, 2009, 5:26 pm

Re: Something goes wrong, but I don't know what. Help, please.

Post by Xudo »

Today I found, what BfW don' want to store units to cells of array.

Code: Select all

[store_unit]
variable=foo[1]
...
[/store_unit]

Code: Select all

[store_unit]
variable=garbage
...
[/store_unit]
{VARIABLE foo[1] $garbage}
wrong syntax.(cause error)

Code: Select all

[store_unit]
variable=foo
...
[/store_unit]
right syntax.
It's good, what know what units will be stored and can create individual variables.

Thanks to all, who answered my post.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Something goes wrong, but I don't know what. Help, please.

Post by Sapient »

zookeeper wrote: However, the last time I tried, it was impossible to store a unit into a sub-array in the first place. That is, variable=foo[1] simply won't work. I'm sure you can work around that by storing it into a regular variable/array first (variable=foo) and then using [set_variables] to copy it into whatever sub-array you want to place it in.
It definitely should work. If not, please file a bug report.
FYI, some lesser used features of WML may have been broken by the extensive lua-related changes in 1.7 branch.
The sooner these bugs get reported, the better.
(So we can have a good stable 1.8)
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: Something goes wrong, but I don't know what. Help, please.

Post by silene »

Sapient wrote:It definitely should work. If not, please file a bug report.
FYI, some lesser used features of WML may have been broken by the extensive lua-related changes in 1.7 branch.
Come on, stop putting the blame of every WML failure on Lua...

How can you expect [store_unit] to store several units (!) into the single variable foo[1]? As zookeeper already explained, there are no multidimensional arrays in WML. So this can't work and this doesn't have anything to do Lua (and this is actually caused by your code written in 2007, e.g. commit 19367).
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Something goes wrong, but I don't know what. Help, please.

Post by Sapient »

silene wrote:
Sapient wrote:It definitely should work. If not, please file a bug report.
FYI, some lesser used features of WML may have been broken by the extensive lua-related changes in 1.7 branch.
Come on, stop putting the blame of every WML failure on Lua...

How can you expect [store_unit] to store several units (!) into the single variable foo[1]? As zookeeper already explained, there are no multidimensional arrays in WML. So this can't work and this doesn't have anything to do Lua (and this is actually caused by your code written in 2007, e.g. commit 19367).
It is counter-intuitive that [store_unit] cannot store a single unit to a single array position. I'd even consider it a bug. It needs to support more intelligent array operations, much like [set_variables].

While Lua can't be blamed for everything of course, it was a HUGE RECENT CHANGE and therefore I expect it introduced a fair number of bugs. If it did not, then I will be pleasantly surprised. However, it already has introduced bugs which were detected and presumably fixed, if I recall correctly. My nervousness as we approach 1.8 is nothing personal against you, I promise! I'm just scared of big changes and that is my nature I guess.

In this case, the bug is due to my failure to anticipate this particular usage.

However, I feel that storing to subarrays such as variable=foo1.foo2 should work in the current stable and dev versions. And this was something that did not work before my changes to [store_unit] in 2007. So that is mainly what I wanted to respond to, where zookeeper wrote it would not work, and I say yes it should. ;) Going back over his words now, it seems that by "sub-array" he meant an explicit index of an array, so perhaps I misunderstood him.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: Something goes wrong, but I don't know what. Help, please.

Post by silene »

Sapient wrote:While Lua can't be blamed for everything of course, it was a HUGE RECENT CHANGE and therefore I expect it introduced a fair number of bugs. If it did not, then I will be pleasantly surprised. However, it already has introduced bugs which were detected and presumably fixed, if I recall correctly.
Let's put things into perspective a bit. Lua support is just 2'000 lines isolated in two C++ files. If you want "huge recent change", look at the AI instead, which went from 6'000 lines to 20'000 lines during the 1.7 cycle and which now spans 84 files. Now, what about bugs? On the top of my head, I can think of only two noticeable ones that were caused by the Lua support (dwarf leaders having 1hp and some menu options behaving badly). I don't doubt that other bugs will appear, but for now it is presumably one of the "huge changes" of Wesnoth that has experienced the lowest amount of bugs.
User avatar
Xudo
Posts: 563
Joined: April 3rd, 2009, 5:26 pm

Re: Something goes wrong, but I don't know what. Continued.

Post by Xudo »

I don't know exactly, but Lua is a interface between developer and Game. WML too.
Lua can have influence on WML, just because it can call to some WML functions/variables/libraries... with new commands. here can be conflict between them. AI just became larger. I don't say, what he haven't bugs, but storing units and choosing target for attack have difference. [acronym="It's my opinion"]IMO[/acronym]

Also want to know bug or not.
I think, what this code
Spoiler:
same as
Spoiler:
But WML think not. Who right?
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: Something goes wrong, but I don't know what. Continued.

Post by silene »

xudojnik wrote:But WML think not. Who right?
WML is right. Fill the truth table of your logical condition if you are not convinced.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Something goes wrong, but I don't know what. Continued.

Post by Anonymissimus »

@xudojnik
Note that what you want can probably be achieved more easily by simply filtering with a comma separated list (which also creates the or-condition that you need):

Code: Select all

[event]
	name=moveto
	[filter]
		x=18,19,20
		y=17,18,18
	[/filter]
	#...
[/event]
@(somehow) topic:
However, I know that in 1.6, storing a unit to the variables of another unit works:
[store_unit]variable=unit_var
...
[store_unit]variable=unit_var.variables.another_unit_var
...

This should be the same like unit_var[0].variables.another_unit_var, although in my actual code the filter for the second store_unit is built in such a way that there can be only a single matching unit (filtering by id).
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: Something goes wrong, but I don't know what. Continued.

Post by silene »

Anonymissimus wrote:@(somehow) topic:
However, I know that in 1.6, storing a unit to the variables of another unit works:
[store_unit]variable=unit_var.variables.another_unit_var
Yes, the code above is supposed to work, even in 1.8. What doesn't work is unit_var.variables.another_unit_var[17] (notice the index at the end).
User avatar
Xudo
Posts: 563
Joined: April 3rd, 2009, 5:26 pm

Re: Something goes wrong, but I don't know what. Continued.

Post by Xudo »

I check conditional variable before "filtering", but you give me nice idea... Now I make my code more simple to read.
User avatar
Xudo
Posts: 563
Joined: April 3rd, 2009, 5:26 pm

Re: Something goes wrong, but I don't know what. Continued.

Post by Xudo »

Now I face "20091213 20:34:37 error engine: failed to auto-store $unit at (-999,-999)" in stderr.txt (65MB of this strings)
I think, what this message appear, because some event haven't attributes x and y. But I have no idea where and what can be broken. Or there are some infinity cycle with broken action.
Someone face this error before? If you solve this problem, tell me where can I search my mistake, or tell me how do you fix this.
Post Reply