[difficulty] : add params for image + var

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderators: Forum Moderators, Developers

Forum rules
Before posting a new idea, you must read the following:
Post Reply
denispir
Posts: 163
Joined: March 14th, 2013, 12:26 am

[difficulty] : add params for image + var

Post by denispir » October 30th, 2019, 10:25 am

[Not sure whether this is the place for proposals about language evolution (WML)... If not, just move this thread: and tell me!]

Hello,

I was very pleased to discover the new [difficulty] tag. However, there still remain obscure notations about image variants or modifs. Mainly, I guess, we commonly need to indicate a color or a gender. Exemple I would like to be able to code:

Code: Select all

    [difficulty]
        define=EASY
        # no more that:
        # mage="units/human-magi/mage+female.png~RC(magenta>red)"
        image="units/human-magi/mage"
        gender=female
        color=red
        label= _ "easy"
        description = _ "novice player"
    [/difficulty]
Note that this simplifies the C++ side of the affair, since it is no more needed to analyse the image definition.
I don't know if there are more image modifications, or wishable params for other elements than about the image.

I take the opportunity to ask for a real "diff" var (WML and Lua?) in addition to, and later instead of, a preprocessor symbol. This would allow the use of standard WML conditions and conditional actions, thus making both language and coding more simple & coherent.

Thank you for reading !

User avatar
Elvish_Hunter
Forum Moderator
Posts: 1396
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: [difficulty] : add params for image + var

Post by Elvish_Hunter » October 30th, 2019, 11:41 am

denispir wrote:
October 30th, 2019, 10:25 am
[Not sure whether this is the place for proposals about language evolution (WML)... If not, just move this thread: and tell me!]
The Ideas forum seems better suited for this proposal (and you're likely to get more feedback there), so I moved your topic.
denispir wrote:
October 30th, 2019, 10:25 am
However, there still remain obscure notations about image variants or modifs.
What do you find "obscure"? The "+female" is just part of the filename, while all the available image modification functions are documented here: https://wiki.wesnoth.org/ImagePathFunctions.
denispir wrote:
October 30th, 2019, 10:25 am
I take the opportunity to ask for a real "diff" var (WML and Lua?) in addition to, and later instead of, a preprocessor symbol. This would allow the use of standard WML conditions and conditional actions, thus making both language and coding more simple & coherent.
That's very easy to do on your own with WML, and a prestart event sounds like the best one for this purpose.

Code: Select all

[set_variable]
    name=diff
#ifdef EASY
    value=easy
#endif
#ifdef NORMAL
    value=normal
#endif
#ifdef HARD
    value=hard
#endif
[/set_variable]
Current maintainer of these add-ons:
1.14: The Sojournings of Grog, A Rough Life, The White Troll (co-author), Wesnoth Lua Pack
1.12: Children of Dragons

denispir
Posts: 163
Joined: March 14th, 2013, 12:26 am

Re: [difficulty] : add params for image + var

Post by denispir » October 30th, 2019, 12:48 pm

Thank you Elvish_Hunter!
Elvish_Hunter wrote:
October 30th, 2019, 11:41 am
The Ideas forum seems better suited for this proposal (and you're likely to get more feedback there), so I moved your topic.
All right.
Elvish_Hunter wrote:
October 30th, 2019, 11:41 am
What do you find "obscure"? The "+female" is just part of the filename, while all the available image modification functions are documented here: https://wiki.wesnoth.org/ImagePathFunctions.
That it's indeed obscure in itself (if you don't agree, well, try to judge it fairly); that it's 2 special syntactic structures only for this special use about images; that it's incoherent with all the rest (WML or Lua).
Elvish_Hunter wrote:
October 30th, 2019, 11:41 am
denispir wrote:
October 30th, 2019, 10:25 am
I take the opportunity to ask for a real "diff" var (WML and Lua?) in addition to, and later instead of, a preprocessor symbol. This would allow the use of standard WML conditions and conditional actions, thus making both language and coding more simple & coherent.
That's very easy to do on your own with WML, and a prestart event sounds like the best one for this purpose.

Code: Select all

[set_variable]
    name=diff
#ifdef EASY
    value=easy
#endif
#ifdef NORMAL
    value=normal
#endif
#ifdef HARD
    value=hard
#endif
[/set_variable]
Sure, and that is word-for-word what I do. But AFAIK we have to place that in scenarios, while it is a whole-campaign information. (Actually, I did not try to place that somewhere in _main; should it work? and where?)

Tad_Carlucci
Inactive Developer
Posts: 445
Joined: April 24th, 2016, 4:18 pm

Re: [difficulty] : add params for image + var

Post by Tad_Carlucci » October 30th, 2019, 1:12 pm

diff? color? I do wish people would use more descriptive terms.

Is if diff-erence or diff-icult or diif-ussion? Or maybe it's something obsure like "default, if, and only if". It's not like we have to stay inside a 72-column limit or make things easier for the key-punch department any more.

"replace_with_team_color = red" means something even to someone who has no idea what is going on.
I forked real life and now I'm getting merge conflicts.

User avatar
Elvish_Hunter
Forum Moderator
Posts: 1396
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: [difficulty] : add params for image + var

Post by Elvish_Hunter » October 30th, 2019, 1:39 pm

denispir wrote:
October 30th, 2019, 12:48 pm
Elvish_Hunter wrote:
October 30th, 2019, 11:41 am
What do you find "obscure"? The "+female" is just part of the filename, while all the available image modification functions are documented here: https://wiki.wesnoth.org/ImagePathFunctions.
That it's indeed obscure in itself (if you don't agree, well, try to judge it fairly); that it's 2 special syntactic structures only for this special use about images; that it's incoherent with all the rest (WML or Lua).
This is exactly why I asked you what did you find obscure: because I wanted to read your opinion on that :) . While the +female is just a naming convention (nobody forbids you from using -f in you add-ons, for example), I agree that the ImagePathFunction is different from the rest of WML. What can be done about that? I'm not really sure: keep in mind that we had such functions (well, back then there was only the ~TC() function) since Wesnoth 1.2. What would be a decent alternative syntax, considering that such functions work everywhere there's an image and not just inside [difficulty] tags?
denispir wrote:
October 30th, 2019, 12:48 pm
Sure, and that is word-for-word what I do. But AFAIK we have to place that in scenarios, while it is a whole-campaign information. (Actually, I did not try to place that somewhere in _main; should it work? and where?)
In the 1.14 series you can place global events directly inside the [campaign] tag: https://wiki.wesnoth.org/CampaignWML (search for [event] in that page, because it can be hard to see).
Tad_Carlucci wrote:
October 30th, 2019, 1:12 pm
diff? color? I do wish people would use more descriptive terms.

Is if diff-erence or diff-icult or diif-ussion? Or maybe it's something obsure like "default, if, and only if". It's not like we have to stay inside a 72-column limit or make things easier for the key-punch department any more.
I know! I tend to even use "index" instead of "i" in loops, because it's much clearer. However, this becomes a problem when I have two nested loops, whose index variables are usually named "i" and "j": should I call the innermost one "jndex" then? :P
Current maintainer of these add-ons:
1.14: The Sojournings of Grog, A Rough Life, The White Troll (co-author), Wesnoth Lua Pack
1.12: Children of Dragons

User avatar
Ravana
Forum Moderator
Posts: 2244
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [difficulty] : add params for image + var

Post by Ravana » October 30th, 2019, 4:05 pm

I would default source color palette to magenta.

denispir
Posts: 163
Joined: March 14th, 2013, 12:26 am

Re: [difficulty] : add params for image + var

Post by denispir » October 30th, 2019, 5:03 pm

Elvish_Hunter wrote: What can be done about that? I'm not really sure: keep in mind that we had such functions (well, back then there was only the ~TC() function) since Wesnoth 1.2. What would be a decent alternative syntax, considering that such functions work everywhere there's an image and not just inside [difficulty] tags?
Hem, what is wrong about something like my proposal: adding keys to tags that contain an image? I agree with Tad_Carlucci that "color" is not clear enough. Rather "image_color" or "team_color" (or even "image_team_color") depending on case.
(I also agree with him that "diff" is a very bad name for "difficulty".)
Elvish_Hunter wrote: n the 1.14 series you can place global events directly inside the [campaign] tag: https://wiki.wesnoth.org/CampaignWML (search for [event] in that page, because it can be hard to see).
Yes, thank you! That is really great to be able to define global events that way. (But IIUC, it's not a big deal to define a macro, inserted at start of each scenario, just like the special ToD of UtBS for instance).

For everyone's information, I also discovered that we can now write [option] tags in _main ! This allows 2 features I was looking for a way to do simply:
* This issue of having a real "difficulty" var instead of a #symbol: just make the dif-menu that way. I will try, first to see how it looks like in UI. I would happily get rid of all preprocessor pollution, macros included. We have enough confusion and complication with the WML/Lua pair. I'm not speaking for myself, having practiced C and the like for years, but for amateur programmers who should be able to author Wesnoth games without dealing with such horrible mess.
* Even better: add a "trial" checkbox for authors and "trial players. This allows coding a jump to scenarion to be tried, plus giving decent troop forces.
I opened yesterday a thread on the latter topic: https://forums.wesnoth.org/viewtopic.php?f=8&t=51072. I will try when I have the time, and say more if it works well.

User avatar
Ravana
Forum Moderator
Posts: 2244
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [difficulty] : add params for image + var

Post by Ravana » October 30th, 2019, 6:43 pm

Personally I use #ifhave or wesnoth.have_file as the trial toggle (depending on whether the toggle should be synced). https://github.com/ProditorMagnus/Agele ... ad.lua#L43 https://github.com/ProditorMagnus/Oroci ... d.cfg#L121
we can now write [option] tags in _main
All addon WML can be in _main.cfg, it is specific tags that might support [option].

And something on topic too - the gender key seems unlikely to be useful. You need to know the filename in order to know about "units/human-magi/mage", so you might as well add +female.png yourself.
Color - could be, though it would just be indication to append color shift function to image.

denispir
Posts: 163
Joined: March 14th, 2013, 12:26 am

Re: [difficulty] : add params for image + var

Post by denispir » November 2nd, 2019, 2:37 am

Ravana wrote:
October 30th, 2019, 6:43 pm
And something on topic too - the gender key seems unlikely to be useful. You need to know the filename in order to know about "units/human-magi/mage", so you might as well add +female.png yourself.
You are right indeed, but only once we know that '+' is part of the name, not a special code; just like '~' is precisely. There is no way to know or guess that, even less because this char is so rare in filenames; and less so to know it for sure, which you need to avoid bugs. The case would be much if the convention used '_' or '-' or '.', what do you think?

shevegen
Posts: 233
Joined: June 3rd, 2004, 4:35 pm

Re: [difficulty] : add params for image + var

Post by shevegen » November 10th, 2019, 3:19 pm

> I know! I tend to even use "index" instead of "i" in loops, because it's much clearer.

I think the name "index" is better than "i".

In ruby I tend to prefer long names, but I also tend to use a style such as this:

def foobar(i)

Simply because I know that "i" stands for "input" and I just want to work with the first
argument. When there is more than one argument, I tend to give them real names,
which tend to be longer - but for simple methods/functions, I prefer a short name.

For loops/iterators such as:

hash.each_pair {|key, value|

I tend to use longer names too. Many others use {|k, v| instead which I can understand,
but in these cases I prefer the longer names.

IMO readability is a good thing and the typical REAL explanation as to why short names
are chosen, is laziness by the developer at hand who wrote the code.

As for "diff" versus "difficulty": I think the longer name, difficulty, is better, but in particular
XML can be hugely annoying. You need the same closing tag, and there long names
are ... annoying. I am not a fan of XML at all. Evidently WML is its own beast - I
applaude you guys for having the patience to waddle through it. I am a way too
impatient person to want to get my head to adjust to that. :P (Lua is better but
I prefer ruby ... I don't think mruby will be anywhere close to lua in use in general
though for the short term future ... but it would be great if we could use different
languages, and have some unified base standard that could then be used by different
languages; a bit like JVM for java or WebAssembly for the www. But I digress.)

Tad_Carlucci
Inactive Developer
Posts: 445
Joined: April 24th, 2016, 4:18 pm

Re: [difficulty] : add params for image + var

Post by Tad_Carlucci » November 10th, 2019, 7:53 pm

shevegen wrote:
November 10th, 2019, 3:19 pm
> I know! I tend to even use "index" instead of "i" in loops, because it's much clearer.

I think the name "index" is better than "i".
In an array of weapons, the index would be better named "weapon_index" so you're not confused about which "index" this is, if you also have an array of armor (hence armor_index), and units (unit_index).

But, then, how are we to keep the noobs on their toes if we don't name them all, just "i"!!!
I forked real life and now I'm getting merge conflicts.

Post Reply