Make a unit type "Hold" a variable(s)?

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
uncleshelby
Posts: 427
Joined: May 10th, 2011, 7:20 pm

Make a unit type "Hold" a variable(s)?

Post by uncleshelby »

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
Timshel
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Make a unit type "Hold" a variable(s)?

Post by zookeeper »

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]
uncleshelby
Posts: 427
Joined: May 10th, 2011, 7:20 pm

Re: Make a unit type "Hold" a variable(s)?

Post by uncleshelby »

Dang. Sorry, I meant under the [unit_type] tag.
Timshel
Anonymissimus
Inactive Developer
Posts: 2460
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Make a unit type "Hold" a variable(s)?

Post by Anonymissimus »

*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 startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
uncleshelby
Posts: 427
Joined: May 10th, 2011, 7:20 pm

Re: Make a unit type "Hold" a variable(s)?

Post by uncleshelby »

How would I access these variables?
Timshel
JaMiT
Developer
Posts: 511
Joined: January 22nd, 2012, 12:38 am

Re: Make a unit type "Hold" a variable(s)?

Post by JaMiT »

Couldn't you just check the unit type and decide what to drop based on that?
uncleshelby
Posts: 427
Joined: May 10th, 2011, 7:20 pm

Re: Make a unit type "Hold" a variable(s)?

Post by uncleshelby »

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
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Make a unit type "Hold" a variable(s)?

Post by Ceres »

Since the killed unit in a die/last breath event is auto-stored in unit, you can use [switch] on unit.type's value.
Post Reply