how to remove traits

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
inuyasha35
Posts: 32
Joined: September 24th, 2020, 2:57 am

how to remove traits

Post by inuyasha35 »

I made a unit that is meant to restrain another unit, I used the trait "active" to mark when it's restraining something, It works find for single scenario's but I need a macro to remove the trait at the end of a scenario. please help me.
vghetto
Posts: 464
Joined: November 2nd, 2019, 5:12 pm

Re: how to remove traits

Post by vghetto »

Show us the code for how you set the trait, maybe then someone can help you better.
If all else fails, you could do a store_unit and clear_variable of the trait and unstore_unit
User avatar
Ravana
Forum Moderator
Posts: 2519
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: how to remove traits

Post by Ravana »

This use case is more fitting for unit variable instead of trait.
inuyasha35
Posts: 32
Joined: September 24th, 2020, 2:57 am

Re: how to remove traits

Post by inuyasha35 »

I don't know how to store traits on a unit and access them, could you show me an example please?
User avatar
beetlenaut
Developer
Posts: 2558
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: how to remove traits

Post by beetlenaut »

Ravana is saying you shouldn't use a trait at all. I agree because having it display in the trait line of the unit would be confusing for the player. Usually this kind of thing is displayed with [unit_overlay], which puts a little icon above the unit.

Another reason not to use traits is that they are not straight-forward to code. Adding them is easy enough, but removing them is a lot more complicated. Inside [unit], there is a [variables] block and a [status] block. That's what you should be using. Either one would work, but I think status makes more logical sense here. You can modify them the same way as you modify any variable inside a container. If you are using a variable called "my_unit," you would use [set_variable] to change my_unit.status.restraining or whatever, then unstore the unit.

For more detail on unit variables, search for "unit container" on this page.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Post Reply