Make a unit type "Hold" a variable(s)?
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.
-
- Posts: 427
- Joined: May 10th, 2011, 7:20 pm
Make a unit type "Hold" a variable(s)?
Is there any way to make a unit "hold" a variable, so that e.g., when it is killed the results of an event is determined by the variable? I'm thinking about making an RPG where the unit can drop an item when it dies, and I want the items to be by type.
Thanks, Uncleshelby
Thanks, Uncleshelby
Timshel
Re: Make a unit type "Hold" a variable(s)?
Yes, you can store arbitrary keys and tags in a unit. Put them in mystoredunit.variables.
Code: Select all
{VARIABLE mystoredunit.variables.mycustomkey "foo"}
Code: Select all
[filter]
[filter_wml]
[variables]
mycustomkey="foo"
[/variables]
[filter_wml]
[/filter]
-
- Posts: 427
- Joined: May 10th, 2011, 7:20 pm
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Make a unit type "Hold" a variable(s)?
*I think* you can do [unit_type][variables]<wml as if in [set_variables][literal] (no variable substitution performed)> to give unit types wml variables for their way.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
-
- Posts: 427
- Joined: May 10th, 2011, 7:20 pm
Re: Make a unit type "Hold" a variable(s)?
Couldn't you just check the unit type and decide what to drop based on that?
-
- Posts: 427
- Joined: May 10th, 2011, 7:20 pm
Re: Make a unit type "Hold" a variable(s)?
Yeah, I geuss I could. How would I check the unit type? From a single unit filter variable, or would I have to store the unit?
Timshel
Re: Make a unit type "Hold" a variable(s)?
Since the killed unit in a die/last breath event is auto-stored in
unit
, you can use [switch] on unit.type
's value.Co-Creator of The Fellowship of the Clay (BfW 1.10) ~~ Maintainer of the German Code of Conduct
How to isolate problematic WML code ~~ WML error messages and their reasons
How to isolate problematic WML code ~~ WML error messages and their reasons