how to remove traits
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: 32
- Joined: September 24th, 2020, 2:57 am
how to remove traits
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.
Re: how to remove traits
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
If all else fails, you could do a store_unit and clear_variable of the trait and unstore_unit
Re: how to remove traits
This use case is more fitting for unit variable instead of trait.
-
- Posts: 32
- Joined: September 24th, 2020, 2:57 am
Re: how to remove traits
I don't know how to store traits on a unit and access them, could you show me an example please?
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: how to remove traits
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
For more detail on unit variables, search for "unit container" on this page.
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
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide