Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: onFirstInit doesn't get tracked unless an mts file is provided #4905

Closed
ShadowFantasy opened this issue Sep 12, 2024 · 0 comments · Fixed by #4906
Closed

[Bug]: onFirstInit doesn't get tracked unless an mts file is provided #4905

ShadowFantasy opened this issue Sep 12, 2024 · 0 comments · Fixed by #4906
Labels

Comments

@ShadowFantasy
Copy link

ShadowFantasy commented Sep 12, 2024

Describe the Bug

The onFirstInit event is run on every reload if an mts entry is not provided, this creates a problem when onFirstInit is handled exclusively by javascript. Here is some tests I ran that supports my theory.

Test 1

I wanted to test the onInit and onFirstInit with javascript files. I was more familiar what I can do with that and I needed it for some plans. And as you can see from the results it was always doing onfirstInit and onInit. Both events calling when it should have only been onInit when readding the addon, or closing and reopening the campaign.
events.json

{
    "events": [
        { "name": "onFirstInit", "js": "js/onFirstInit.js"},
        { "name": "onInit", "js": "js/onInit.js"}
    ],
    "legacyEvents":[]
}

test results

First Add Output ->
onFirstInit.js
onInit.js
<- End

Second Add Output ->
onFirstInit.js
onInit.js
<- End

Reopening Output ->
onFirstInit.js
onInit.js
<- End

Test 2

In this test I included the mts files wondering if it would give the same results and well. It caused a bit of a unforseen reaction.
events.json

{
    "events": [
        { "name": "onFirstInit", "mts": "onFirstInit", "js": "js/onFirstInit.js"},
        { "name": "onInit", "mts": "onInit", "js": "js/onInit.js"}
    ],
    "legacyEvents":[]
}

test results

First Add Output ->
onFirstInit.js
onFirstInit.mts
onInit.js
onInit.mts
<- End

Second Add Output ->
onInit.js
onInit.mts
<- End

Reopening Output ->
onInit.js
onInit.mts
<- End

mts ones work... and now the javascript ones as well...?

Test 3

This one was like the first test but instead mts was the one being tested alone, unlike the first, this one gave me the expected results.
test results

First Add Output ->
onFirstInit.mts
onInit.mts
<- End

Second Add Output ->
onInit.mts
<- End

Reopening Output ->
onInit.mts
<- End

Test 4

At this point I was starting to draw a line towards the mts files, I had narrowed it down to it involving requiring an mts file... or did it?
In this test instead of supplying two corresponding mts files, I gave two arbitrary names that don't have any files associated with them.
events.json

{
    "events": [
        { "name": "onFirstInit", "mts": "foo", "js": "js/onFirstInit.js"},
        { "name": "onInit", "mts": "bar", "js": "js/onInit.js"}
    ],
    "legacyEvents":[]
}

test results

First Add Output ->
onFirstInit.js
onInit.js
<- End

Second Add Output ->
onInit.js
<- End

Reopening Output ->
onInit.js
<- End

This test reveals that an mts file is not needed, but more that there must be an mts entry at all for the events to work reguardless if it is a valid entry or not. Of course this does throw up a window telling me that those files can't be found... but the javascript files gave the expected output.

To Reproduce

Create a library with events only handled in javascript like so.

{
    "events": [
        { "name": "onFirstInit", "js": "js/onFirstInit.js"},
        { "name": "onInit", "js": "js/onInit.js"}
    ],
    "legacyEvents":[]
}

Create the javascripts files and test the initialization events for importing the library for the first time, reimporting it, and closing and opening the campaign it is saved to. Every time it will run both events. If an mts property is included this doesn't happen.

Expected Behaviour

I expected this

First Add Output ->
onFirstInit.js
onInit.js
<- End

Second Add Output ->
onInit.js
<- End

Reopening Output ->
onInit.js
<- End

Screenshots

But instead I got this

First Add Output ->
onFirstInit.js
onInit.js
<- End

Second Add Output ->
onFirstInit.js
onInit.js
<- End

Reopening Output ->
onFirstInit.js
onInit.js
<- End

MapTool Info

1.15

Desktop

Windows

Additional Context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant