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]: createMap does not accept add-on URIs #4626

Closed
Tdue21 opened this issue Jan 11, 2024 · 1 comment · Fixed by #4629
Closed

[Bug]: createMap does not accept add-on URIs #4626

Tdue21 opened this issue Jan 11, 2024 · 1 comment · Fixed by #4629
Labels

Comments

@Tdue21
Copy link
Contributor

Tdue21 commented Jan 11, 2024

Describe the Bug

It is not possible to use the new createMap function with an image from an add-on.
When I attempt to use the function with e.g. these parameters:

[h:lobbyImage = "lib://net.dovesoft.trinity-continuum/images/LobbyBackground.png"]
[h: lobbyId = createMap("01. Lobby", 
    json.set("{}",
        "player visible", json.true,
        "vision type", "Off",
        "vision distance", 1000,
        "lighting style", "OVERTOP",
        "has fog", json.false,
        "ai rounding", "None",
        "map asset", lobbyImage
    )
)]

I get the following exception:

20:41:53.233 DEBUG net.rptools.maptool.client.MapToolLineParser - net.rptools.parser.ParserException: createMap: "lib://net.dovesoft.trinity-continuum/images/StoryGuideScreen.png" is not a valid asset ID or URL
20:41:53.233 ERROR net.rptools.maptool.client.swing.MapToolEventQueue - java.util.concurrent.CompletionException: net.rptools.parser.ParserException: createMap: "lib://net.dovesoft.trinity-continuum/images/LobbyBackground.png" is not a valid asset ID or URL
java.util.concurrent.CompletionException: net.rptools.parser.ParserException: createMap: "lib://net.dovesoft.trinity-continuum/images/LobbyBackground.png" is not a valid asset ID or URL
    at net.rptools.maptool.model.library.addon.AddOnLibrary.lambda$callMTSFunction$15(AddOnLibrary.java:653) ~[MapTool.jar:1.14.3]
    at java.awt.event.InvocationEvent.dispatch(Unknown Source) [?:?]
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source) [?:?]

The image url is known to work, as I have tested it with [h:broadcast("<img src='" + lobbyImage + "'></img>")], which showed the image nicely in the chat window.

To Reproduce

  1. Create an add-on
  2. Add an image in the public folder and an onInit.mts file to the mtscript folder.
  3. In the onInit.mts add this:
[h:lobbyImage = "lib://test-library-namespace/LobbyBackground.png"]
[h: lobbyId = createMap("01. Lobby", 
    json.set("{}",
        "player visible", json.true,
        "vision type", "Off",
        "vision distance", 1000,
        "lighting style", "OVERTOP",
        "has fog", json.false,
        "ai rounding", "None",
        "map asset", lobbyImage
    )
)]

Where the lobbyImage variable points to the correct image with the correct namespace.
4. Import the add-on
5. Observe the exception.

Expected Behaviour

I expect the lib:// URI to be treated exactly as an asset:// URI. Even more so, as the ´createMap` function is so newly added.

Screenshots

No response

MapTool Info

1.14.3

Desktop

Windows 11

Additional Context

No response

@Tdue21 Tdue21 added the bug label Jan 11, 2024
@bubblobill
Copy link
Collaborator

Looks like multiple places in the code might suffer from hard coded assetId instead of URIs.

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.

2 participants