Skip to content

[Bug]: Add-on onInit fails if it requires data from e.g. a table #5178

@Tdue21

Description

@Tdue21

Describe the Bug

A campaign with an add-on embedded will generate an error on the add-on's onInit, if the event requires campaign resources, like switching to a lobby map, reading images from a table etc.

According to Skullman3194 (on the Discord), it appears that MT attempts to execute the add-on code before it has actually load the campaign resources.

If I defer the onInit code that requires these resources, i.e. use the execLink(link, 1, "self") function, my initialization code works.

To Reproduce

  1. Create a campaign.
  2. Create a second map.
  3. Create an add-on which attempts to switch to second map in onInit.
  4. Save campaign.
  5. Restart MapTool and load campaign.
  6. Observe failure.

Expected Behaviour

I expect the add-on to be able to load campaign resources in the initialization code, just like a library token.
Without having to resort to deferring code.

Screenshots

No response

MapTool Info

1.15.2 - clean install

Desktop

Windows 11

Additional Context

I will ASAP construct an example campaign to demonstrate the issue.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions