WML error about unstore_unit

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
Platinum
Posts: 6
Joined: August 18th, 2012, 3:58 am

WML error about unstore_unit

Post by Platinum »

Hello,

I have been not playing Wesnoth since at least 1.12 and the support for one of the useful addons I've used seems to be out, as the author of Soul Crystals: Leader Revival did not update it since 2014.

The addon's aim is to turn the starting faction leader from the gold-crowned leader into a silver-crowned hero unable to recruit, while spawning a (by default) 80 HP Soul Crystal, which takes 60 HP of damage whenever the "silver-crowned hero" dies, and respawns the hero back with full health.

I've tried to play with this modification, however to no avail as it gives an error related to the unstore_unit function not finding THISLEADER[] variable to target the stored leader (in order to transform it into a silver-crowned hero).

I've also tried to make some adjustments, however I've no experience on the behaviour of the store_unit and unstore_unit, and missed many updates. I've tried to search about this or similar kind of error, however it yielded only one result without any reply in its topic: viewtopic.php?t=48319

The exact function for unstore_unit is located at /utils/prepareSoulCrystals.cfg : line 97-100

Code: Select all

			[unstore_unit]
				variable=DK_ALLLEADERS[$THISLEADER|]
				find_vacant=yes
			[/unstore_unit]
The addon has been working for years after the last update 0.7.8, however at the present Wesnoth version 1.14.4 it does not work. I am attaching the Soul Crystals: Leader Revival's original package, as well as a screenshot of the WML error that occurs upon game launch.

Would it be possible to still return this addon back to its functionality, and if it's not a problem, I would like to learn how to deal with this kind of WML situation in the future. Thank you in advance!
Attachments
wesnoth_addon_wmlerror.png
DranKofSoulCrystals.tar.bz2
(238.89 KiB) Downloaded 186 times
User avatar
Pentarctagon
Project Manager
Posts: 5527
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: WML error about unstore_unit

Post by Pentarctagon »

Based on the error message it looks like $THISLEADER| doesn't have a value. In previous versions this would have meant it defaulted to [0], but was changed since it's fairly likely that trying to use a non-existent variable as an array index was not the intended behavior. I believe you could replace it with $THISLEADER?0| to get the same functionality, however.
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
Platinum
Posts: 6
Joined: August 18th, 2012, 3:58 am

Re: WML error about unstore_unit

Post by Platinum »

Pentarctagon wrote: August 4th, 2018, 7:54 pm Based on the error message it looks like $THISLEADER| doesn't have a value. In previous versions this would have meant it defaulted to [0], but was changed since it's fairly likely that trying to use a non-existent variable as an array index was not the intended behavior. I believe you could replace it with $THISLEADER?0| to get the same functionality, however.
Thank you for the quick response, it works flawlessly, and thank you for the explanation on how to solve that!
Post Reply