1.83 Possible bug: Clicking "Ok" doesn't update macro

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
notbono
Cave Troll
Posts: 61
Joined: Sun Oct 24, 2010 4:44 pm

1.83 Possible bug: Clicking "Ok" doesn't update macro

Post by notbono »

So this is something weird that happened while working on my current framework. I have a macro called getContainerWeight that is mapped to a user function (getContainerWeight) using defineFunction in the onCampaignLoad. It runs recursively (if a container contains other containers, it calls itself to get the weight of those.) I recently had to update it to fix how bags of holding are handled. So I made changes to the code and clicked "Okay" and re-ran the macro that loads a dialog that calls the getContainerWeight function. Nothing changed, and the whole thing ran and displayed container weights as before.

Now I couldn't tell if anything was being hit, so I inserted an division by zero error into the macro, right at the beginning, and clicked "Ok." Reloaded the dialog that shows container weights... No problem. I closed MapTool and started again from scratch, and still, even with the division by zero error saved in the code after relaunch, it ran fine. I searched for another macro with the same name--there is not one.

Finally I renamed the macro getContainerWeightxxx, re-ran onCampaignLoad by clicking it, and re-ran my container dialog... Bingo, no dialog and error trace showing up. Now I could fix things and my changes started showing up.

notbono
Cave Troll
Posts: 61
Joined: Sun Oct 24, 2010 4:44 pm

Re: 1.83 Possible bug: Clicking "Ok" doesn't update macro

Post by notbono »

So I had the same experience today, that the macro called by the UDF doesn't get updated until I re-run the defineFunction statement... I have no idea if that is by design or not.

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: 1.83 Possible bug: Clicking "Ok" doesn't update macro

Post by Full Bleed »

You should only have to re-run onCampaignLoad if you are initializing a new function after loading your campaign (or renaming an existing one.)

Can't currently test that anything has changed with this, but maybe you can put together a simple campaign file showing the issue?
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
bubblobill
Giant
Posts: 167
Joined: Sun Jan 24, 2010 3:07 pm

Re: 1.83 Possible bug: Clicking "Ok" doesn't update macro

Post by bubblobill »

Full Bleed wrote:
Thu Mar 11, 2021 5:20 pm
You should only have to re-run onCampaignLoad if you are initializing a new function after loading your campaign (or renaming an existing one.)
Ahh... the good old should

I get this all the time using "Apply" and "Run" buttons. Sometimes it sticks and sometimes the code changes stick and sometimes they don't. Particularly when macros are calling macros such as using forms. I can usually force MT to take notice by closing and reopening the macro editor window, although I have had improved success using the name change trick above.
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: 1.83 Possible bug: Clicking "Ok" doesn't update macro

Post by Full Bleed »

bubblobill wrote:
Fri Mar 12, 2021 6:48 am
I get this all the time using "Apply" and "Run" buttons.
Hmmm... I never have this problem (in previous versions anyway). Though, perhaps it's worth noting that I never use the "run" button... and do most of my macro writing in Notepad++ and paste the updated code into the MT editor and just click apply.
Sometimes it sticks and sometimes the code changes stick and sometimes they don't. Particularly when macros are calling macros such as using forms. I can usually force MT to take notice by closing and reopening the macro editor window, although I have had improved success using the name change trick above.
There has to be some reason some people have this issue and some (most?) don't.

Are you certain that it's not a window focus issue or an apply button miss click?

For example, I have an issue where I copy code from the mt editor, go to notepad++, do some coding, copy, then click on the mt macro editor window to paste... at this point the editor window seems to have focus, but when I ctrl-A to select all the text in the macro editor window to paste over the new code a "Save Campaign" dialog pops up. So my first click back to MT from notepad++ switches focus to MT but not to the editor even if its on top. I have to double-click on the MT editor window when switching back to it from another window to make sure the focus is on the editor.

And can you be sure that every time MT "loses" your code updates that you haven't just missed the apply button and then closed the window? Perhaps some kind of visual feedback should be added to make it clear that the new code has been applied... or, even better, maybe a warning message when closing the editor that changes have not been applied.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

notbono
Cave Troll
Posts: 61
Joined: Sun Oct 24, 2010 4:44 pm

Re: 1.83 Possible bug: Clicking "Ok" doesn't update macro

Post by notbono »

I think I figured it out, and it's user error rather than a bug. I had inadvertently made a copy of my main lib:token. This had a second version of the macro and a onCampaignLoad macro. So presumably, the 'defineFunction' version that was in play was the one on the copy and not my main token, by random chance depending on which one happened to run first... Clicking onCampaignLoad of my main token "fixed" it by linking the correct version.

Thanks for the help as always, and sorry for wasting your time (although if it saves someone else from wasting their time, maybe it's worth something.)

User avatar
bubblobill
Giant
Posts: 167
Joined: Sun Jan 24, 2010 3:07 pm

Re: 1.83 Possible bug: Clicking "Ok" doesn't update macro

Post by bubblobill »

Full Bleed wrote:
Fri Mar 12, 2021 12:43 pm
bubblobill wrote:
Fri Mar 12, 2021 6:48 am
I get this all the time using "Apply" and "Run" buttons.
Hmmm... I never have this problem (in previous versions anyway). Though, perhaps it's worth noting that I never use the "run" button... and do most of my macro writing in Notepad++ and paste the updated code into the MT editor and just click apply.
Sometimes it sticks and sometimes the code changes stick and sometimes they don't. Particularly when macros are calling macros such as using forms. I can usually force MT to take notice by closing and reopening the macro editor window, although I have had improved success using the name change trick above.
There has to be some reason some people have this issue and some (most?) don't.

Are you certain that it's not a window focus issue or an apply button miss click?
Oh, it's definitely a weirdness with MT that I've noticed with 1.8.3. It might have been around before but I never twigged.
I can be in the macro editor, add a thing, click run, and have the new thing ignored. Click ok, hit the macro button and the new thing is there.
It is occasional, and since I can mostly tell when it's happening I can deal with it. I do tend to half multiple macro editors open so that may be part of it. Most assuredly not the usual user error of not focussed or updated and expecting it to still work.
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: 1.83 Possible bug: Clicking "Ok" doesn't update macro

Post by Full Bleed »

bubblobill wrote:
Sat Mar 13, 2021 5:03 am
I can be in the macro editor, add a thing, click run, and have the new thing ignored. Click ok, hit the macro button and the new thing is there.
So it sounds like you're reporting that the RUN button in the macro editor, on occasion, does not update a macro. That's different from the OP's initial concern with the OK button (now determined to be user error) and probably deserves its own bug report.

That said, the lack of clairity when the code has been updated in the editor seems to be an issue and I suggest the following improvements be considers by devs:

1) Have the editor visibly display a notification that the macro has been updated after APPLY or RUN is clicked.
1a) Perhaps a "Current/Editing" state displayed somewhere prominently could provide the necessary notification.
2) Gray out APPLY when there is no new code to APPLY.
3) When closing the editor dialog, warn if APPLY or OK has not been executed after changes to the code have been made.


And, related to insulating against a focus issue:

4) Option to force the Editor Dialog (if present and in the foreground) to have focus when MT receives focus from an outside application.


Any other suggestions that could be added to a Editor Feature Request?
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: 1.83 Possible bug: Clicking "Ok" doesn't update macro

Post by Full Bleed »

Full Bleed wrote:
Fri Mar 12, 2021 12:43 pm
For example, I have an issue where I copy code from the mt editor, go to notepad++, do some coding, copy, then click on the mt macro editor window to paste... at this point the editor window seems to have focus, but when I ctrl-A to select all the text in the macro editor window to paste over the new code a "Save Campaign" dialog pops up. So my first click back to MT from notepad++ switches focus to MT but not to the editor even if its on top. I have to double-click on the MT editor window when switching back to it from another window to make sure the focus is on the editor.
Was looking at the github backlog and it turns out this is currently listed as a Bug: https://github.com/RPTools/maptool/issues/773

Doesn't seem like working on the editor is sexy enough to draw much dev attention though.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

Post Reply

Return to “MapTool”