Display variables dynamically in objectives

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
Samaximus
Posts: 2
Joined: September 8th, 2023, 1:53 pm

Display variables dynamically in objectives

Post by Samaximus »

Hello,

I have the following objective which initially displays what I want, "(0/10)":

Code: Select all

	[objective]
		description="Destroy every naga village ($destroyed_village/10)."
		condition=win
	[/objective]
However when I update the variable the text remains the same. I already checked the variable with the inspect command, it changed.
Here is my event with which I update the variable:

Code: Select all

[event]
	name=capture
	first_time_only=no
	[filter]
		side=1
	[/filter]

	[sound]
		name=torch.ogg
	[/sound]

	{VARIABLE_OP random_string value "scenery/rubble.png"}
	{RANDOM $random_string}

	{PLACE_IMAGE $random $x1 $y1}
	{CLEAR_VARIABLE random,random_string}

	{MODIFY_TERRAIN Ss $x1 $y1}

	[set_variable]
		name=destroyed_village
		add=1
	[/set_variable]
	[redraw]
		side=1
	[/redraw]
[/event]
I would appreciate any idea how can I update my objective after the event was fired.
gnombat
Posts: 722
Joined: June 10th, 2010, 8:49 pm

Re: Display variables dynamically in objectives

Post by gnombat »

There's an example of how to do this in the scenario "Test of the Clans". (I think you just need to change $destroyed_village to $|destroyed_village.)
Samaximus
Posts: 2
Joined: September 8th, 2023, 1:53 pm

Re: Display variables dynamically in objectives

Post by Samaximus »

Thanks a lot for the quick reply. It solved my problem. :)
Post Reply