Let the gold rain down!

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
malthaussen
Posts: 36
Joined: April 6th, 2024, 11:05 pm

Let the gold rain down!

Post by malthaussen »

I want to give Side 2 a one-time infusion of 100 gold on Turn 20. Not finding any simple syntax to accomplish this, and everything I search just takes me farther down a rabbit hole.

Any ideas?

-- Mal
"Of two choices, I always take the third."
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: Let the gold rain down!

Post by white_haired_uncle »

I assume you're familiar with the various turn events, like new_turn or side_2_turn:

Code: Select all

                   [gold]
                        side=2
                        amount=100
                    [/gold]
 
Speak softly, and carry Doombringer.
User avatar
malthaussen
Posts: 36
Joined: April 6th, 2024, 11:05 pm

Re: Let the gold rain down!

Post by malthaussen »

@uncle: actually not a safe assumption, as I have only been fooling with this game for about three days. But maybe I worked it out, the scenario doesn't warn me anything is wrong:

Code: Select all

	[event]
		name=side_2_turn_20
			[gold]
				side=2
				amount=100
			[/gold]
	[/event]
-- Mal
"Of two choices, I always take the third."
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: Let the gold rain down!

Post by white_haired_uncle »

Speak softly, and carry Doombringer.
User avatar
malthaussen
Posts: 36
Joined: April 6th, 2024, 11:05 pm

Re: Let the gold rain down!

Post by malthaussen »

Yeah, I saw that. It doesn't give an example of the code, though.

-- Mal
"Of two choices, I always take the third."
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: Let the gold rain down!

Post by white_haired_uncle »

I just search the mainline campaigns, for example:

Code: Select all

grep -r name=side /export/share/build/spartan/wesnoth-git/data/campaigns/
Speak softly, and carry Doombringer.
User avatar
lhybrideur
Posts: 369
Joined: July 9th, 2019, 1:46 pm

Re: Let the gold rain down!

Post by lhybrideur »

malthaussen wrote: April 13th, 2024, 12:04 am @uncle: actually not a safe assumption, as I have only been fooling with this game for about three days. But maybe I worked it out, the scenario doesn't warn me anything is wrong:

Code: Select all

	[event]
		name=side_2_turn_20
			[gold]
				side=2
				amount=100
			[/gold]
	[/event]
-- Mal
The name= is wrong

https://wiki.wesnoth.org/EventWML#side_X_turn_Y
User avatar
Ravana
Forum Moderator
Posts: 3018
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Let the gold rain down!

Post by Ravana »

Looks correct name.
User avatar
Spannerbag
Posts: 538
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: Let the gold rain down!

Post by Spannerbag »

malthaussen wrote: April 13th, 2024, 12:04 am

Code: Select all

	[event]
		name=side_2_turn_20
			[gold]
				side=2
				amount=100
			[/gold]
	[/event]
-- Mal
Try replacing name=side_2_turn_20 with name=side 2 turn 20 (i.e. lose the underscores).
https://wiki.wesnoth.org/EventWML#side_X_turn_Y

[off_topic]
Note that [gold] does what it says on the tin; so if gold before is -101 and you have amount=100, gold after is -1.

Fwiw, with the help of many others cleverer than me (they did all the hard work) I created a lua snippet that creates a custom tag [gold_min].
This works like [gold] but also accepts a minimum value for the side's gold after the gold is added, regardless of a side's current gold.
You can do this in other more conventional ways of course but I use this logic a lot so created a custom tag.
So in the example above if you add 100 gold using [gold_min] to a side with -101 gold, then the side will have 100 gold afterwards (unless you specify an alternative minimum; the minimum defaults to the amount being added).
[/off_topic]

Anyway, good luck.

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
Ravana
Forum Moderator
Posts: 3018
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Let the gold rain down!

Post by Ravana »

Spaces in event names can be interchanged with underscores (for example, name=new turn and name=new_turn are equivalent).
User avatar
Spannerbag
Posts: 538
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: Let the gold rain down!

Post by Spannerbag »

Ravana wrote: April 15th, 2024, 9:30 am Spaces in event names can be interchanged with underscores (for example, name=new turn and name=new_turn are equivalent).
So that's true everywhere?
Oops... :oops:
Ah well, I've learned something!

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
malthaussen
Posts: 36
Joined: April 6th, 2024, 11:05 pm

Re: Let the gold rain down!

Post by malthaussen »

@Ravana: That explains why I see both methods in the .cfgs I've been reviewing.

-- Mal
"Of two choices, I always take the third."
User avatar
malthaussen
Posts: 36
Joined: April 6th, 2024, 11:05 pm

Re: Let the gold rain down!

Post by malthaussen »

@ lhybrideur: I've tested it, and it is working. Have to agree with Ravana here.

-- Mal
"Of two choices, I always take the third."
User avatar
lhybrideur
Posts: 369
Joined: July 9th, 2019, 1:46 pm

Re: Let the gold rain down!

Post by lhybrideur »

Same as Spannerbag, I learned something today.

BTW, if you want to counter the -101+100 problem, you can do

Code: Select all

		[modify_side]
			side=2 
			gold=100
		[/modify_side]
		
Post Reply