Possible [for] bug, 1.13.8

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

Possible [for] bug, 1.13.8

Post by Samonella »

If I understand it right from the wiki, this should be perfectly valid code, iterating from 0 to 3:

Code: Select all

	[for]
		end=3
		[do]
			< stuff >
		[/do]
	[/for]
But it results in this error:

Code: Select all

error scripting/lua: lua/wml-flow.lua:149: attempt to perform arithmetic on a nil value (field 'step')
stack traceback:
	lua/wml-flow.lua:149: in local 'cmd'
	lua/wml-utils.lua:145: in field 'handle_event_commands'
	lua/wml-flow.lua:6: in function <lua/wml-flow.lua:5>
	[C]: in field 'fire_event'
	lua/wml-tags.lua:146: in local 'cmd'
	lua/wml-utils.lua:145: in field 'handle_event_commands'
	lua/wml-flow.lua:6: in function <lua/wml-flow.lua:5>
So I tried adding step=1 in the code, and then it worked fine. According to the wiki, 'step' should default to 1 (or -1, based on 'start' and 'end') so this is a bug?
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: Possible [for] bug, 1.13.8

Post by Tad_Carlucci »

Try this:

In wesnoth's data/lua/wml-flow.lua change line 102 from

Code: Select all

		if cfg.step then loop_lim.step = cfg_lit.step end
to

Code: Select all

		if cfg.step then loop_lim.step = cfg_lit.step else loop_lim.step = 1 end
and retest.
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: Possible [for] bug, 1.13.8

Post by Samonella »

That seems to have fixed it, at least for end>start. 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
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Possible [for] bug, 1.13.8

Post by Tad_Carlucci »

OK. If Celtic Minstrel doesn't beat me to it, I'll put together a PR with a more-complete solution.
I forked real life and now I'm getting merge conflicts.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Possible [for] bug, 1.13.8

Post by zookeeper »

5fdb73b9 was supposed to fix this exact issue, but I guess he didn't test it? :whistle:
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Possible [for] bug, 1.13.8

Post by Tad_Carlucci »

PR #1812 is the fix above. On reading the code, the case where 'end=-3' should do nothing with the wiki-specified default of 'step=1' so no additional checks seemed to be needed.
I forked real life and now I'm getting merge conflicts.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Possible [for] bug, 1.13.8

Post by WhiteWolf »

original post:
EDIT: Sorry, it was my bad. One of the macros inside the [do] also used a variable named i and that caused the conflict.
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