mmower / rez

Rez is a language, compiler, and runtime for creating interactive fiction games
GNU General Public License v3.0
9 stars 1 forks source link

Make default project playable #5

Open islemaster opened 1 year ago

islemaster commented 1 year ago

It would be nice if the default project set up by rez new was "complete" in the sense that it compiles and plays without issue, before making any changes.

Issues I've run into with the default project in its current state:


These assets (asset.jpg, sound.mp3, moo.mpg) are not actually in the repo.

https://github.com/mmower/rez/blob/7ada4dee9cde5076e546e55bdd39d3e2e47dafea/assets/templates/source.rez.eex#L131-L150

This results in a runtime error while trying to determine the mime type of these missing assets, which in turn blocks the rest of game initialization.

Uncaught Attempt to get value of attribute |detected_mime_type| which is not defined on |#mov1|

Removing references to the missing assets allows the game to load! At this point clicking on the "Hit the troll with the bottle" link produces another error message and fails to change the scene:

Uncaught Error, no data-op! runtime.js:1981:17
    transformLinksToEvents file:///C:/Users/islem/Projects/mmower/rez/testgame/dist/assets/runtime.js:1981
    (Async: EventListener.handleEvent)
    transformLinksToEvents file:///C:/Users/islem/Projects/mmower/rez/testgame/dist/assets/runtime.js:1947
    forEach self-hosted:203
    transformLinksToEvents file:///C:/Users/islem/Projects/mmower/rez/testgame/dist/assets/runtime.js:1943
    render file:///C:/Users/islem/Projects/mmower/rez/testgame/dist/assets/runtime.js:1253
    playCardWithId file:///C:/Users/islem/Projects/mmower/rez/testgame/dist/assets/runtime.js:1907
    start file:///C:/Users/islem/Projects/mmower/rez/testgame/dist/assets/runtime.js:2133
    setCurrentScene file:///C:/Users/islem/Projects/mmower/rez/testgame/dist/assets/runtime.js:1232
    start file:///C:/Users/islem/Projects/mmower/rez/testgame/dist/assets/runtime.js:1296
    <anonymous> file:///C:/Users/islem/Projects/mmower/rez/testgame/dist/index.html:37
islemaster commented 1 year ago

I made a quick attempt to fix the second issue, above.

The "Hit the troll with the bottle" link is created by DynamicLink.allow(), which generates a hyperlink without a data-op attribute, possibly assuming that it will always link to a card rather than a scene.

In transformLinksToEvents we find this code that assumes any link to a scene will be tagged as a "shift" or an "interlude" with data-op.

https://github.com/mmower/rez/blob/7ada4dee9cde5076e546e55bdd39d3e2e47dafea/assets/templates/runtime.js.eex#L1883-L1892

Here was my first attempt to fix this: https://github.com/islemaster/rez/commit/ee38e81020b6d633f73d4a11a2814ea481f66f01 . I made DynamicLink detect that it was linking to a scene and tag it as a shift. And this worked! But upon trying to link back, I found that the documented scene shift link syntax wasn't working:

image

So now I'm not sure if this syntax is broken, or if it's vestigial. Should we instead detect whether we're linking to a scene?

mmower commented 1 year ago

For some reason I either never saw this or forgot it, apologies. I’m now updating the sample source to be a real demo game.