Wiki issue with AI_Recruitment

Discussion of all aspects of the website, wiki, and forums, including assistance requests and new ideas for them.

Moderator: Forum Moderators

Post Reply
Kharn
Posts: 83
Joined: December 12th, 2005, 7:50 pm
Location: Dallas, Tx

Wiki issue with AI_Recruitment

Post by Kharn »

https://wiki.wesnoth.org/AI_Recruitment

The attributes for [recruit] show
type="": (string)

This indicates it defaults to open quote close quote with no value.

However the examples mentions

[recruit]
type=Orcish Grunt

and

[recruit]
type=scout

Neither have quotes. It appears in testing that if you use a name the system only accepts it if it is done with quotes type="Orcish Grunt"
Perhaps it works without quotes on type=scout
It appears to me the type field when using a name attribute requires quotes and when using a usage attribute does not. Either way it appears during testing with my mod that when I use the name of a unit, as in a string, it requires quotes, but when type is used to refer to the usage value, it does not require quotes.

I have not done enough testing to be completely sure, but if my guess is right, there needs to be a note added to this wiki page that says "If type is used to refer to a name attribute it requires quotes, and if type is used to refer to a usage attribute it does not require quotes. And along with this the examples need to be corrected to show quotes when type is referring to name.

Even better would be to fix the [recruit] tag to stop using teh type filter and instead allow filtering by either [recruit] name="string of name" and [recruit] usage=usagetype

Thoughts? Did I miss something fundamental? Let me know.
Creator of 120+ units Lord of the Rings era and campaign now outdated & lost.
Creator of WWII Battleground Europe mod with 120+ units most with custom wml and animations. Every variable is mathematically derived based on WWII stats such as historical cost & mm armour.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: Wiki issue with AI_Recruitment

Post by enclave »

Im not sure about [recruit] tag in particular, but with any other tag (like [unit]) it would work without quotes to the best of my knowledge,
UNLESS you are using it with macro or custom macro... (and your macro requires 1 variable, but instead you are feeding it with 2 variables.. it then gives error) the thing is if you do {RECRUIT black elephant} your macro thinks that it has 2 variables "black" and "elephant", while if you use {RECRUIT "black elephant"} then it's treated like 1 single variable "black elephant"... you may use parentheses (round brackets) instead of quotes... like {RECRUIT (black elephant)}, although sometimes this will remove some spaces from your quoted text.. no idea why.
so if you are not using macros and not using lua... then I have no idea why quotes are required... usually for most tags they are not needed... and everything works fine.. maybe somebody else could share the light..
However I often do use quotes for long lines.. like if it's image "data/campaigns/game_of_thrones/images/story/gandalf.jpg", it works without quotes too.. but I just want to make sure that it won't create some secret error/bug which wesnoth will not be able to detect and give me a hard times looking for it.. so in some cases I prefer to use quotes even though they are not required... and I recommend it to everyone..
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Wiki issue with AI_Recruitment

Post by mattsc »

Hi — I just did a quick test with the first example from the wiki page, recruiting 3 grunts and nothing else. I used it as is, except that I removed the turns=3-5 line and it works without changes, that is, without adding quotes. That is the expected behavior, WML keys (for the most part) do not require quotes, unless they are passed as macro arguments and contain spaces, as enclave explained.

So there must be something else going on in your code. You could post it here if your problem persists and you'd like help finding it.
Kharn
Posts: 83
Joined: December 12th, 2005, 7:50 pm
Location: Dallas, Tx

Re: Wiki issue with AI_Recruitment

Post by Kharn »

When I do my own testing, it appears to work with and without quotes. At the same time I have several memories of adding quotes to names with spaces and that change alone caused the code to switch to working. Must be faulty memories or perhaps it was happening when I was editing a macro, which is also likely.

I would still recommend updating the wiki to explain that:
1) The type attribute searches for matches to both both name and usage attributes
2) The type attribute functions with our without quotes unless they are passed as macro arguments and contain spaces.
Creator of 120+ units Lord of the Rings era and campaign now outdated & lost.
Creator of WWII Battleground Europe mod with 120+ units most with custom wml and animations. Every variable is mathematically derived based on WWII stats such as historical cost & mm armour.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Wiki issue with AI_Recruitment

Post by mattsc »

Kharn wrote: October 24th, 2018, 12:33 amI would still recommend updating the wiki to explain that:
1) The type attribute searches for matches to both both name and usage attributes
Isn't that what the page says already:
AI Recruitment wiki wrote: type="": (string) This key takes a comma separated list containing unit types, usages or levels. Common values for usage are 'scout', 'fighter', 'archer', 'healer' and 'mixed fighter'. An empty string means 'all units'. If more than one unit is specified, the AI decides what to recruit according to the score map.
I am probably too familiar with this to see how this might be unclear. :| So if you have a different (better) wording, feel free to change it yourself, the wiki can be edited by anybody.
Kharn wrote: October 24th, 2018, 12:33 am2) The type attribute functions with our without quotes unless they are passed as macro arguments and contain spaces.
I actually don't think that this should be done. This applies to pretty much all WML keys, so singling it out here does not seem like the right place to do so. If there's a general "How to use WML" page somewhere (I forgot if there is) that would be where this should go.

I'm glad to hear that the problem does not appear any more for you though. If you encounter it again, just post the code here and we can try to figure out what's going on.
User avatar
Celtic_Minstrel
Developer
Posts: 2158
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Wiki issue with AI_Recruitment

Post by Celtic_Minstrel »

Bit late, but... this isn't specific to AI at all - quotes are a fundamental part of the WML syntax that disable whitespace-collapsing in the value (stripping leading and trailing whitespace and replacing internal runs with a single space). To put it another way, the only way the presence or absence of quotes would make the difference between working and not working is if you have a run of spaces somewhere in the attribute. For an empty value, type= is completely equivalent to type="".

This should definitely be documented at SyntaxWML if it's not already, though
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply