Let the gold rain down!
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.
- malthaussen
- Posts: 37
- Joined: April 6th, 2024, 11:05 pm
Let the gold rain down!
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
Any ideas?
-- Mal
"Of two choices, I always take the third."
-
- Posts: 1285
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Let the gold rain down!
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.
- malthaussen
- Posts: 37
- Joined: April 6th, 2024, 11:05 pm
Re: Let the gold rain down!
@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:
-- Mal
Code: Select all
[event]
name=side_2_turn_20
[gold]
side=2
amount=100
[/gold]
[/event]
"Of two choices, I always take the third."
-
- Posts: 1285
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
- malthaussen
- Posts: 37
- Joined: April 6th, 2024, 11:05 pm
Re: Let the gold rain down!
Yeah, I saw that. It doesn't give an example of the code, though.
-- Mal
-- Mal
"Of two choices, I always take the third."
-
- Posts: 1285
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Let the gold rain down!
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.
- lhybrideur
- Posts: 377
- Joined: July 9th, 2019, 1:46 pm
Re: Let the gold rain down!
The name= is wrongmalthaussen 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:
-- MalCode: Select all
[event] name=side_2_turn_20 [gold] side=2 amount=100 [/gold] [/event]
https://wiki.wesnoth.org/EventWML#side_X_turn_Y
Re: Let the gold rain down!
Looks correct name.
- Spannerbag
- Posts: 553
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Let the gold rain down!
Try replacingmalthaussen wrote: ↑April 13th, 2024, 12:04 am-- MalCode: Select all
[event] name=side_2_turn_20 [gold] side=2 amount=100 [/gold] [/event]
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
Re: Let the gold rain down!
Spaces in event names can be interchanged with underscores (for example, name=new turn and name=new_turn are equivalent).
- Spannerbag
- Posts: 553
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Let the gold rain down!
So that's true everywhere?
Oops...
Ah well, I've learned something!
Cheers!
-- Spannerbag
- malthaussen
- Posts: 37
- Joined: April 6th, 2024, 11:05 pm
Re: Let the gold rain down!
@Ravana: That explains why I see both methods in the .cfgs I've been reviewing.
-- Mal
-- Mal
"Of two choices, I always take the third."
- malthaussen
- Posts: 37
- Joined: April 6th, 2024, 11:05 pm
Re: Let the gold rain down!
@ lhybrideur: I've tested it, and it is working. Have to agree with Ravana here.
-- Mal
-- Mal
"Of two choices, I always take the third."
- lhybrideur
- Posts: 377
- Joined: July 9th, 2019, 1:46 pm
Re: Let the gold rain down!
Same as Spannerbag, I learned something today.
BTW, if you want to counter the -101+100 problem, you can do
BTW, if you want to counter the -101+100 problem, you can do
Code: Select all
[modify_side]
side=2
gold=100
[/modify_side]