Mordor's WML Problems

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
landofMordor
Posts: 6
Joined: August 19th, 2019, 2:01 pm

Mordor's WML Problems

Post by landofMordor »

Hey all, first post here, about six months into my hobby writing WML campaigns.

The majority of my coding issues have been pretty easy to find here on the forums (EarthCake, thank you for having all of my same problems right before I did, lol), but a couple issues have persisted and I can't find workarounds anywhere:

Issue 1: I'm 8 scenarios in on a 9-scenario campaign, and suddenly on scenario 8, my leader spawns like a new unit! I used the exact same code on the previous 7 scenarios and it worked just fine:

Code: Select all

[side]
    side=1
    controller=human
    team_name="good"
    user_team_name= _ "My Team"
    id=Rich
    type="Master at Arms"
    canrecruit=yes
    gold=0
    fog="yes"
    shroud="yes"
  [/side]
This is a map without keeps or enemy leaders, a simple "escape the dungeon" scenario, which is the only difference I can find from my previous, functional scenarios.

Issue 2: I'm trying to store some story-relevant units in scenario 7 (I'll unstore them to bust my leader out of the aforementioned dungeon in 8, without any recruiting). This storage should happen regardless of whether or not I recalled the unit for 7. I figured I could accomplish this using "if" statements like so, but I've troubleshot by inserting messages into the "then" statements, but they never fired, which suggests the "if" condition is never fulfilled at all...

Code: Select all

[if]
        [have_unit]
          id=Yran
        [/have_unit]
        [then]
              [store_unit]
                [filter]
                  id=Yran
                [/filter]
                variable=Yran
              [/store_unit]
        [/then]
        [elseif]
            [have_unit]
                id=Yran
                search_recall_list="yes"
            [/have_unit]
            [then]
              [store_unit]
                [filter]
                  id=Yran
                  x,y=recall,recall
                [/filter]
                variable=Yran
              [/store_unit]
            [/then]
        [/elseif]
      [/if]
It's possible I can find a story workaround to avoid the necessity for these codes entirely, but I'd prefer to use these more elegant solutions if I can. Thanks in advance for the help! -- Cheers, Mordor
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Mordor's WML Problems

Post by beetlenaut »

landofMordor wrote: November 10th, 2019, 7:52 pm Hey all, first post here, about six months into my hobby writing WML campaigns.
Welcome to the forums, then! Even with EarthCake's "help", that's a long time to go without needing to post a question, so: Good work.
landofMordor wrote: November 10th, 2019, 7:52 pm my leader spawns like a new unit!
You've given us just about nothing to go on here. If the code is not different, then something else is. But, you didn't show us anything else. The only thing you showed us the part you say you have already ruled out. However, you should note the rules for an ID in a [side] tag: If the ID matches a unit on the recall list, the unit is recalled, and the rest of the unit attributes are ignored. If not, a new unit is spawned.
landofMordor wrote: November 10th, 2019, 7:52 pm they never fired, which suggests the "if" condition is never fulfilled at all...
If the ID really does not exist at this point, we can't possibly know why by looking at this. If the [if] is not being read at all, then the problem is not with the code inside it, but the code outside it. Which we don't have.

A problem with your recall list could cause both of these problems, though I obviously can't tell you why you would have one. At this point, there is not much more we can do. You should try using :inspect liberally to make sure that all the variables and units are set they way you expect them to be in both scenarios. If you want more help, you will have to post more of the campaign--either the whole thing, or at least the offending scenario and save file in a runnable condition (which means incuding _main.cfg and required unit files, macros, and so on). One of us will fire it up and take a look. If you post more of the code but not in a runnable condition, we might be able to figure it out, but no promises.

Actually, you could just post the campaign on the add-on server now as long as it's labeled "incomplete" or "WIP" so people know it's not expected to be completely playable at this point. A lot of UMC authors do that. Let us know if you decide to do that.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
landofMordor
Posts: 6
Joined: August 19th, 2019, 2:01 pm

Re: Mordor's WML Problems

Post by landofMordor »

Noted, beetlenaut (how do I @ you on this forum?). I'll give :inspect a shot this weekend and post more detailed code if needed. I'll probably post a WIP version on the add-on server, too, once I get scenario 9 hacked out. Thanks!
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Mordor's WML Problems

Post by Pentarctagon »

landofMordor wrote: November 11th, 2019, 7:59 pm Noted, beetlenaut (how do I @ you on this forum?). I'll give :inspect a shot this weekend and post more detailed code if needed. I'll probably post a WIP version on the add-on server, too, once I get scenario 9 hacked out. Thanks!
People will get a notification if you quote them.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
landofMordor
Posts: 6
Joined: August 19th, 2019, 2:01 pm

Re: Mordor's WML Problems

Post by landofMordor »

beetlenaut wrote: November 11th, 2019, 1:47 pm You should try using :inspect liberally to make sure that all the variables and units are set they way you expect them to be in both scenarios.
Thanks again for this suggestion. I learned that both of my problems were caused by losing my recall list at the end of scenario 7. Therefore, my leader was a "new unit" for 8, and I had no loyal units to recall for 8, either.

My fix, for any other users who might run into this, was to save my entire team in the method of Delfador's Memoirs (the {SAVE_VETERANS} and dependent macros), and unstore them in 8 as needed. Still not sure why they weren't saving in the first place... but the fire has been quenched for now, and everything is working as expected. If I do figure out why the recall list wasn't saving, I'll be sure to reply here.

I'm also working to post the campaign as an add-on, but I'm running the 1.15 development version right now and I'm not sure it'd be compatible if users downloaded onto 1.14 clients. I'll be sure to make a separate forum post as soon as the campaign is up, though!
landofMordor
Posts: 6
Joined: August 19th, 2019, 2:01 pm

Re: Mordor's WML Problems

Post by landofMordor »

Having trouble using the random_placement tag (https://wiki.wesnoth.org/InternalAction ... acement.5D). I'm trying to have undead units spawn in a semi-random fashion (zombie horde kinda feeling), and this was the most succinct code I could find to accomplish this. I think I'm getting something wrong in my use of the tag, but can't find any examples in mainline campaigns to compare my work to. See annotated code snippet below:

Code: Select all

[random_placement] 
   [filter_location]
          terrain=Uu^Uf
   [/filter_location]
          num_items=3
          variable=locvar #this variable doesn't exist when I use :inspect. Normally I'd use a [set_variable] tag but documentation didn't seem to use one.
          allow_less="yes"
          min_distance=1
   [command]
          [message] #During debug I do get this message, which assures me that the [command] tag is firing.
                 speaker=Undead_Leader
                 message=".... Rise, my servants..."
          [/message]
          [unit] #this code never happens, probably because the locvar variable doesn't exist.
                 type="Skeleton"
                 side=3
                 x,y=$locvar
          [/unit]
   [/command]
[/random_placement]
I'm sure it's just something silly but it's really stumped me for awhile now. Any help is appreciated! cheers
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Mordor's WML Problems

Post by Ravana »

Try x,y=$locvar.x,$locvar.y

Probably you used [inspect] outside [command], so variable was removed already.
landofMordor
Posts: 6
Joined: August 19th, 2019, 2:01 pm

Re: Mordor's WML Problems

Post by landofMordor »

Ravana wrote: May 4th, 2020, 7:33 pm Try x,y=$locvar.x,$locvar.y
Worked like a charm. (Obviously I need to level-up my variable skills, haha.) Thank you for the speedy reply!
Post Reply