Rolisteam/DiceParser

Changelog

Closed this issue ยท 11 comments

Either I am blind or I cannot find a proper changelog file.
It's another time something changes in the bot and I cannot find what happened and why.
Last time I just needed to add escape characters before " signs to replace existing macros that stopped working.
This time I can see the difference in text output (I have some screenshots in my GitHub repo with DiceParser macros, mainly " ; " changed into ",") but these are just cosmetics I can easily modify.
The worse thing is that some "ifs" in the middle of my macros stopped working and I've been trying to fix it for 3 hours without a success or a hint of what was changed. I am unable to read C/C++ to find it myself even though I tried to read the files changed in last 6 months.

No there is no changelog yet.
Could you give me a short example of the ifs that are broken now ?

@obiwankennedy Here's the macro that used to work some months ago (when we last played this game - WFRP4ed):

!macro add t([0-9]+) "\1;1d100;$1-$2;($1|10)-($2|10);($2|10);$2-(($2|10)*10);$5i:[=$6|=10]{\":bomb: Double! :bomb:\"};\":game_die: [ $5$6 / ($1) ]\";$2i:[>95]{\":skull: Ouch! Critical failure!\"};$2i:[<6]{\":star_struck: Great! Critical success!\"};$3i:[>=0]{\":white_check_mark: Test passed! SL: [ +$4 ]\"}{\":no_entry: Test failed SL: [ $4 ]\"}" True

Now I wanted to use it as a base for new game with similar mechanics (WH 40k) and I thought I will just remove/modify some conditions. So I did and it seemed that ifs for "Critcal failure/success" do not display anything, but "Test passed/failed" work fine.
Previously it looked like this:

crit

Now the middle part is missing.
Another macro with hit location went even worse than that, but I cannot find a picture of it in my full of garbage Discord server.

So... I tried and tried and finally using git blame I found there's been a change in official documentation, mentioning that the string needs to be the last command. So I thought that this change in parser/output module ruined my life, erm, macros.

I totally rewritten both macros and they seem to work, but the "code" looks like a mess and it shows additional things in places where it should not because I cannot use positional parameters like before.

Here's the new version:

!macro add t([0-9]+) "\1;1d100;$1-$2;$3i:[>=0]{(($1|10)-($2|10))+1}{(($2|10)-($1|10))+1};($2|10);$2-(($2|10)*10);$2i:[=100]{\":skull: Ouch! Automatic failure!\"}{$2i:[=1]{\":star_struck: Great! Automatic success!\"}{$3i:[>=0]{\":white_check_mark: Test passed!\"}{\":x: Test failed\"}}};$3i:[>=0]{\":arrow_up_small: DoS [ +\"}{\":arrow_down_small: DoF [ -\"};\":game_die: [ $5$6 / ($1) ] $7 $8$4 ]\" # $user" True

But the version with hit location is awful and hard to read:

!macro add a([0-9]+) "\1;1d100;$1-$2;(($1|10)-($2|10))+1;($2|10);$2-(($2|10)*10);($6*10)+$5;$2i:[=100]{\":warning: Ouch! Automatic failure! [\"}{$2i:[=1]{\":drop_of_blood: Automatic success! :dagger: DoS: [+\"}{$3i:[<0]{\":eyes: Miss :eyes: [\"}{\":dart: Hit! :dagger: DoS: [+\"}}};$3i:[<0]{\"(\"}{$7i:[>85]{\"You hit the Left Leg (\"}{$7i:[>70]{\"You hit the Right Leg (\"}{$7i:[>30]{\"You hit the Body (\"}{$7i:[>20]{\"You hit the Left Arm (\"}{$7i:[>10]{\"You hit the Right Arm (\"}{$7i:[>0]{\"You hit the Head (\"}{\"Zero Exception!\"}}}}}}};\":game_die: [ $5$6 / ($1) ] $8$4] $9$6$5)\" # $user" True

Here's how it looks when it should not display DoF and hit location:

๐ŸŽฒ [ 99 / (70) ] ๐Ÿ‘€ Miss ๐Ÿ‘€ [-1] (99)

Of course I do not need to display [-1] and (99) but I cannot do it in current version, because I get literal "$4" instead of DoS value when I put it in the $2i:[=1] string and then try to concatenate all previous commands to display final string. This ":game_die: [ $5$6 / ($1) ] $8$4] $9$6$5)" look like a total mess but at least it works now.

Here's my repo with macros (old and new) and pictures: https://github.com/pszeptynski/DiceParser-macros

Yes, I see the issue here.

I changed how string results are managed in order to allow new features around strings.
I made a rule about strings.

If the string has placeholder => (@x, $x, %x โ€ฆ) the string is managed as an output string.

If you have strings with placeholder and string without placeholder. Placeholder strings are the only displayed one. We make the supposition that other strings will be displayed inside the output thanks to placeholder.

This is the reason why the mid part of your command does not show any more.
Clearly it is not perfect, and I have to find a better solution.

I made a short command that show the issue.

!"[99 / (70)]";1d100;"result $2";"$1 ; $2 ; $3"

The current output:

result 100,[99 / (70)] ; 100 ; result $2

This result is bad. It should be:

[99 / (70)] ; 100 ; result 100

I did not work to manage that case but your issue make me realize that.
I will find a solution about it. I can't go backward on the modification that break it but I believe a step forward in the right direction can help you a lot.
Another solution is to mark a string as output even where there is no placeholder. Instead of guessing, the user will be about to tell: this is an output format string and this is a regular string result. But I have no idea which syntax may fill this need. Any clues ?

I also plan to make a switch/case instruction to simplify the way to transform a number into string.

instead of:
$7i:[>85]{\"You hit the Left Leg (\"}{$7i:[>70]{\"You hit the Right Leg (\"}{$7i:[>30]{\"You hit the Body (\"}{$7i:[>20]{\"You hit the Left Arm (\"}{$7i:[>10]{\"You hit the Right Arm (\"}{$7i:[>0]{\"You hit the Head (\"}{\"Zero Exception!\"}

it could be something like that:

$7o[>85]{You hit the Left Leg}[>70]{You hit the Right Leg}โ€ฆ

I'm looking for a syntax that reduce a bit the size compare to ifs. I'm still thinking about a solution.
If you have any wishes, let me hear them.

@obiwankennedy Now you can clearly see why the changelog in this project is needed, I suppose ;-)
I've spent many hours on trials and errors and looking through documentation and code. A bit too late, I even found your discord server with a kind of change log. I also need another bot feature but I will open a new issue for it, because those macros somehow work in my old discord server.

I also plan to make a switch/case instruction to simplify the way to transform a number into string.

That's another great idea!

instead of:
$7i:[>85]{\"You hit the Left Leg (\"}{$7i:[>70]{\"You hit the Right Leg (\"}{$7i:[>30]{\"You hit the Body (\"}{$7i:[>20]{\"You hit the Left Arm (\"}{$7i:[>10]{\"You hit the Right Arm (\"}{$7i:[>0]{\"You hit the Head (\"}{\"Zero Exception!\"}

it could be something like that:

$7o[>85]{You hit the Left Leg}[>70]{You hit the Right Leg}โ€ฆ

I'm looking for a syntax that reduce a bit the size compare to ifs. I'm still thinking about a solution.
If you have any wishes, let me hear them.

Unfortunately that does not work. But I think I found a solution playing with the bot in your discord server:

!d60;$1i[>50]{"aaaa"}i[>20]{"bbbb"}i[>10]{"ccc"}{"dddd"};"You hit: $2"

That simplifies the macro code a bit and I am rushing to refactor my macros. :)

Of course, it does not work, I plan to do it soon. I will be a bit less verbose than ifs.

OK:

dice "3d10+4i:[>50]{"aaaa"}i:[>20]{"bbbb"}i:[>10]{"ccc"}{"dddd"};"You hit: $1""

Right. That seems work only with max 3 i: and one else/false at the end. I failed with my hit location macro, that's why I made my comment and so I made more tests. :)

If one makes their macro command like:
!75i:[>90]{"aaaa"}i:[>80]{"bbbb"}i:[>70]{"ccc"}{"other"};"You hit: $1"
all is fine and it works.

You hit: ccc

If you try to add more ifs before final "else" the macro only outputs else:
!75i:[>90]{"aaaa"}i:[>80]{"bbbb"}i:[>70]{"ccc"}i:[>60]{"dddd"}i:[>50]{"eeee"}i:[>40]{"ffff"}i:[>30]{"gggg"}i:[>20]{"hhhh"}i:[>10]{"iiii"}{"other"};"You hit: $1"

You hit: other

But if you remove the final else with more than 3 ifs, the macro seems to work fine:
!35i:[>90]{"aaaa"}i:[>80]{"bbbb"}i:[>70]{"ccc"}i:[>60]{"dddd"}i:[>50]{"eeee"}i:[>40]{"ffff"}i:[>30]{"gggg"}i:[>20]{"hhhh"}i:[>10]{"iiii"};"You hit: $1"

You hit: gggg

The command you want to do is this:

"75i:[>90]{"aaaa"}{i:[>80]{"bbbb"}{i:[>70]{"ccc"}{i:[>60]{"dddd"}{i:[>50]{"eeee"}{i:[>40]{"ffff"}{i:[>30]{"gggg"}{i:[>20]{"hhhh"}{i:[>10]{"iiii"}{"other"}}}}}}}}};"You hit: $1"

Basically your the command has an issue of logic. I agree that your way seems more logical but it leads to an error.

Your command stops when it find the first right value and then it wants to go the next step and the else is a good candidate.
Add explicit else condition for all if make it work.
The new operator will fix that.

OK, going back to my previous version with many "}"es but with less "$7"s before "i:" for a bit better readability and waiting for a new switch/case operator. :)

As the changelog has been created and you have see the bot-releases and changes channel on the official discord server, I'm closing this issue.