ForestDragon's WML questions

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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.

Re: ForestDragon's WML questions

Postby ForestDragon » January 22nd, 2017, 6:42 pm

Ravana wrote:I noticed you call for variable name you do not assign.

please be specific about what exact variable it is
User avatar
ForestDragon
 
Posts: 1308
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Postby Ravana » January 22nd, 2017, 6:46 pm

this_leader
User avatar
Ravana
Moderator
 
Posts: 1504
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: ForestDragon's WML questions

Postby zookeeper » January 22nd, 2017, 6:46 pm

You have a [store_unit] in your [set_menu_item].
User avatar
zookeeper
WML Wizard
 
Posts: 9630
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: ForestDragon's WML questions

Postby ForestDragon » January 22nd, 2017, 6:48 pm

oh, thanks!
User avatar
ForestDragon
 
Posts: 1308
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Postby Ravana » February 23rd, 2017, 7:12 pm

I guess I cant expect more from you.

formula= is part of standard unit filter not filter_wml.
User avatar
Ravana
Moderator
 
Posts: 1504
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: ForestDragon's WML questions

Postby ForestDragon » February 23rd, 2017, 7:18 pm

well, slightly better, but, the ability triggers no matter how much hp the unit has
Code: Select all
#define ABILITY_DESPERATE VALUE
    # Canned definition of the Desperate ability to be included in an
    # [abilities] clause.
    [leadership]
        id=desperate
        value={VALUE}
        cumulative=no
        name= _ "desperate ({VALUE}%)"
        female_name= _ "female^desperate ({VALUE}%)"
        description= _ "This unit's attacks do {VALUE}% more damage when it's health is below 50%."
        affect_self=yes
        affect_allies=no
        affect_enemies=no
        [filter_self]
           [filter]
               formula="(($this_unit.max_hitpoints -1+1) / ($this_unit.hitpoints -1+1)) > 2"
      [/filter]
        [/filter_self]
    [/leadership]
#enddef
User avatar
ForestDragon
 
Posts: 1308
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Postby zookeeper » February 23rd, 2017, 7:23 pm

You have stuff in your [filter_self] that shouldn't be there. When you have a problem with one single tag then you could first check whether you're using it right.
User avatar
zookeeper
WML Wizard
 
Posts: 9630
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: ForestDragon's WML questions

Postby ForestDragon » February 23rd, 2017, 7:51 pm

zookeeper wrote:You have stuff in your [filter_self] that shouldn't be there. When you have a problem with one single tag then you could first check whether you're using it right.

can you please be more specific?
User avatar
ForestDragon
 
Posts: 1308
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Postby zookeeper » February 23rd, 2017, 8:05 pm

ForestDragon wrote:can you please be more specific?

The extra [filter] tag. When the wiki says that you can put a StandardUnitFilter somewhere, then it means you can put the stuff listed on the StandardUnitFilter page there. If you need to wrap said StandardUnitFilter stuff in a [filter] tag, then the wiki will say so.
User avatar
zookeeper
WML Wizard
 
Posts: 9630
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: ForestDragon's WML questions

Postby ForestDragon » February 24th, 2017, 5:12 am

zookeeper wrote:
ForestDragon wrote:can you please be more specific?

The extra [filter] tag. When the wiki says that you can put a StandardUnitFilter somewhere, then it means you can put the stuff listed on the StandardUnitFilter page there. If you need to wrap said StandardUnitFilter stuff in a [filter] tag, then the wiki will say so.

well, the thing is, when i put the additional [filter], the ability triggers no matter how much hp the unit has, but if i remove the filter, the ability doesn't trigger at all
User avatar
ForestDragon
 
Posts: 1308
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Postby ForestDragon » February 25th, 2017, 8:46 am

hello everyone! well, i got another filter issue: i want the [store_unit]'s filter not store units who have at least 2 enemies adjacent to them, but I have done something wrong with the filter, not quite sure what though
Code: Select all
                  [option]
               message=  {MENU_IMG_TXT "items/holy-water.png~BLIT(halo/elven/shaman-heal-halo-4.png)" "Deposit All"}
               [command]
                  [store_unit]
                     [filter]
                        side=$side_number
             [not]
             [filter_adjacent]   
                [filter_side]
                    [enemy_of]
                        side=$side_number
                    [/enemy_of]
                [/filter_side]
                count=2-6
             [/filter_adjacent]
             [/not]
                     [/filter]
                     variable=exp_drained_unit
                  [/store_unit]
                  {FOREACH exp_drained_unit i}
                  [set_variable]
                      name=exp_stored_[$side_number]
                      add="$exp_drained_unit[$i].experience"
                  [/set_variable]
                  {VARIABLE exp_drained_unit[$i].experience 0}
                  [unstore_unit]
                     variable=exp_drained_unit[$i]
                     find_vacant=no
                  [/unstore_unit]
                  {NEXT i}
                  {CLEAR_VARIABLE exp_drained_unit}
               [/command]
            [/option]
User avatar
ForestDragon
 
Posts: 1308
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Postby zookeeper » February 25th, 2017, 10:08 am

Looks correct to me.
User avatar
zookeeper
WML Wizard
 
Posts: 9630
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: ForestDragon's WML questions

Postby beetlenaut » February 25th, 2017, 10:14 am

ForestDragon wrote:well, the thing is, when i put the additional [filter], the ability triggers no matter how much hp the unit has, but if i remove the filter, the ability doesn't trigger at all
Since [filter] is not allowed here, everything inside it is ignored when you use it. When you take it out, the formula is evaluated, but it must not equal what you think it does. I have never used formula, but from the wiki, it looks like you should be using the variable "self" instead of "$this_unit".
ForestDragon wrote:I have done something wrong with the filter, not quite sure what though
Maybe the filter is not the problem. You should always try your code without CLEAR_VARIABLE the first time so you can use :inspect to see what your variables actually equal--in this case, what units did get stored, if any. You may have a problem because you are treating your variable as an array, but it might not be one.
Campaigns: Dead Water
The Founding of Borstep
Secrets of the Ancients
User avatar
beetlenaut
Developer
 
Posts: 2090
Joined: December 8th, 2007, 3:21 am
Location: Washington State

Re: ForestDragon's WML questions

Postby zookeeper » February 25th, 2017, 10:52 am

Oh, yeah, this is definitely a case where you're trying to treat a container as a variable:

Code: Select all
                  [set_variable]
                      name=exp_stored_[$side_number]
                      add="$exp_drained_unit[$i].experience"
                  [/set_variable]
User avatar
zookeeper
WML Wizard
 
Posts: 9630
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: ForestDragon's WML questions

Postby ForestDragon » February 25th, 2017, 11:07 am

zookeeper wrote:Oh, yeah, this is definitely a case where you're trying to treat a container as a variable:

Code: Select all
                  [set_variable]
                      name=exp_stored_[$side_number]
                      add="$exp_drained_unit[$i].experience"
                  [/set_variable]

well, sorry for not understanding, but what exactly should i fix?
User avatar
ForestDragon
 
Posts: 1308
Joined: March 6th, 2014, 1:32 pm

PreviousNext

Return to WML Workshop

Who is online

Users browsing this forum: No registered users and 4 guests