Variables Question
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.
- DEATH_is_undead
- Posts: 960
- Joined: March 4th, 2007, 3:00 pm
- Location: Northern United States
Variables Question
OK, I never really needed to set my own variables in a map, so I'm fairly new to setting them. It's a simple variable I'm trying to do just to push the boundaries of WML knowledge.
All I'm trying to do is make it so that when a unit dies, it adds one to the variable.
I set the variable as bats to start with :
Now, since I have the variable made, I shall add one each time a bat is killed.
Using :debug feature in-game, I decided to check this to see if it was working before I continued to make the last part. Obviously it hasn't worked, and seeing variables are...varying... I haven't found a link to help me with what I'm planning to do.
EDIT: I found that only side 1 is able to change the variable for some reason, even though I don't have a filter set to just side 1, nor any other side for this matter.
EDIT2: Found that first_time_only wasn't set to no.
(I haven't even attempted to make the last part yet; making an event fire after a variable reaches a certain number. I'm going to use this thread to help with that as, if needed be.)
All I'm trying to do is make it so that when a unit dies, it adds one to the variable.
I set the variable as bats to start with :
Code: Select all
[set_variable]
name=bats
value=0
[/set_variable]
Code: Select all
[event]
name=die
[filter]
type=Vampire Bat,Dread Bat,Blood Bats
[/filter]
[set_variable]
name=bats
add=1
[/set_variable]
[/event]
EDIT: I found that only side 1 is able to change the variable for some reason, even though I don't have a filter set to just side 1, nor any other side for this matter.
EDIT2: Found that first_time_only wasn't set to no.
(I haven't even attempted to make the last part yet; making an event fire after a variable reaches a certain number. I'm going to use this thread to help with that as, if needed be.)
Last edited by DEATH_is_undead on July 25th, 2011, 8:56 pm, edited 2 times in total.
3P MP Scenario - Great Dwarves Escape
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.
Re: Variables Question
By default events fire only once. You need to tell it to fire every time, not just the first time.
- DEATH_is_undead
- Posts: 960
- Joined: March 4th, 2007, 3:00 pm
- Location: Northern United States
Re: Variables Question
I just noticed that, and changed it, then tried it again, but it still doesn't set the variable for any other side.zookeeper wrote:By default events fire only once. You need to tell it to fire every time, not just the first time.
3P MP Scenario - Great Dwarves Escape
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.
Re: Variables Question
What kind of bat you'd like to count? If there are Blood Bats among them, you should change the type 'Blood Bats' to Blood Bat, even if you are going to count multiple Blood Bats.
- Captain_Wrathbow
- Posts: 1664
- Joined: June 30th, 2009, 2:03 pm
- Location: Guardia
Re: Variables Question
Also, just fyi, there are some helpful macros for setting variables and performing operations on them: {VARIABLE} for just setting one to a fixed value or initializing it, and {VARIABLE_OP} for doing any mathematical operations.
- DEATH_is_undead
- Posts: 960
- Joined: March 4th, 2007, 3:00 pm
- Location: Northern United States
Re: Variables Question
Shoot, how did the S get there? I copied and pasted it directly from the CFG file... Yeah, that fixed it Now to make an attempt at counting Variables.lipk wrote:What kind of bat you'd like to count? If there are Blood Bats among them, you should change the type 'Blood Bats' to Blood Bat
I figure it's only right to start doing a variable without Marcos first; But thank you.Captain_Wrathbow wrote:Also, just fyi, there are some helpful macros for setting variables and performing operations on them: {VARIABLE} for just setting one to a fixed value or initializing it, and {VARIABLE_OP} for doing any mathematical operations.
3P MP Scenario - Great Dwarves Escape
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.
Re: Variables Question
Just tweaking, but
is a lot easier to type than
Code: Select all
[filter]
race=bats
[/filter]
Code: Select all
[filter]
type=Vampire Bat,Dread Bat,Blood Bat
[/filter]
“It is written in my life-blood, such as that is, thick or thin; and I can no other.” - J.R.R. Tolkien
My campaign: Swamplings - Four centuries before the founding of Wesnoth, the first wolf rider emerges from a tribe of lowly swamp goblins.
My campaign: Swamplings - Four centuries before the founding of Wesnoth, the first wolf rider emerges from a tribe of lowly swamp goblins.
- DEATH_is_undead
- Posts: 960
- Joined: March 4th, 2007, 3:00 pm
- Location: Northern United States
Re: Variables Question
Heh, didn't think about race. Truthfully, I only think I'm going to put the level 0 in, but I have to do some balance testing to make sure they'll be strong enough for my needs. (Hence why I haven't started coding the counting variable part)boru wrote:Just tweaking, but
is a lot easier to type thanCode: Select all
[filter] race=bats [/filter]
Code: Select all
[filter] type=Vampire Bat,Dread Bat,Blood Bat [/filter]
And truthfully, I'm just going to copy and paste this code for the next part, and there is more then one race there.
Edit: I made the event in which it checks, once a bat has died, if it has 8 kills. If it has 8 kills, then it was to show a message stating I was going to balance the area there in. But, this, as well, is not working. Originally, it was in the same event as the set_variable was in, but it didn't work. So I changed it to its own event, in false hopes.
Code: Select all
[event]
name=die
[filter]
race=bats
[/filter]
[if]
[variable]
name=bats
numerical_equals=8
[/variable]
[then]
{QUAKE (rumble.ogg)}
[message]
speaker=narrator
message="I Am Currently Working On Balancing What Is Already Made. The Rest Of This Map Will Be Revealed In The Next Release."
[/message]
[kill]
side=4
canrecruit=yes
[/kill]
[/then]
[/if]
[/event]
3P MP Scenario - Great Dwarves Escape
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.
Re: Variables Question
zookeeper wrote:By default events fire only once. You need to tell it to fire every time, not just the first time.
“It is written in my life-blood, such as that is, thick or thin; and I can no other.” - J.R.R. Tolkien
My campaign: Swamplings - Four centuries before the founding of Wesnoth, the first wolf rider emerges from a tribe of lowly swamp goblins.
My campaign: Swamplings - Four centuries before the founding of Wesnoth, the first wolf rider emerges from a tribe of lowly swamp goblins.
- DEATH_is_undead
- Posts: 960
- Joined: March 4th, 2007, 3:00 pm
- Location: Northern United States
Re: Variables Question
Heh, shoot (again). That worked perfectly. (In my subconscious, it was filtering it, so I wouldn't need the first_time_only)boru wrote:zookeeper wrote:By default events fire only once. You need to tell it to fire every time, not just the first time.
3P MP Scenario - Great Dwarves Escape
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.