klembot / chapbook

A simple, readable story format for Twine 2.
https://klembot.github.io/chapbook
MIT License
80 stars 25 forks source link

Custom Inserts do not work if config variables have been edited #129

Closed bagelbyheart closed 7 months ago

bagelbyheart commented 2 years ago

Describe the bug Custom Inserts do not work outside of Test view if config options have been edited. This also breaks the feature going forward if cache is not cleared after correcting.

To Reproduce

  1. Make a new chapbook 1.2.1 story on the twine website
  2. Add the {smiley face} example from the chapbook manual
  3. Add the following to the only story passage
    config.header.left: '{passage.name}'
    --
    {smiley face}
  4. Use the Play link to test the issue. Instead of a 😀 we just see {smiley face}

Expected behavior Custom Inserts should work even when cosmetic config changes have been made, and moreso should behave consistently between Test and Play links from the Twine app.

Stories and screenshots testInsert.zip

Environment So far this has been tested on Windows 10 in Firefox and Chrome. The story has been tested from the Twine webapp, as well as built from twee source using tweego.

MoreFoxBeans commented 1 year ago

I've been having the same issue, I'm just gonna port my story to SugarCube for the time being.

HAL9000-GH commented 1 year ago

I experienced this exact problem as well with the latest 1.2.3. I even had the problem persist beyond changing the code back. I had to clear the cache manually. A console error reveals that the code in the Story JavaScript doesn't see the config object properly, I believe.

It seems to only happen when the variables are changed at the top of the page (above the --) in a page that uses the {inserts}. It also affects [modifers]. However, I did have success with using JavaScript:

[javascript]
config.body.transition.name = "none";
config.header.center = "something";
[continue]

This seems to work without issue as a solid workaround. And it even applies it all before the passage renders. Meaning, even the transition applies immediately and not afterwards on the next passage transition.

I believe it might be related to something odd happening above the -- in passages. It might be unrelated, but I sometimes can't edit the text above while using the Twine desktop app. The mapped passages show the typing updating in the preview boxes, but not in the actual editor window. If I edit out the --, I can then edit the code that was above and then type -- back in again after I'm done. Very strange. And I also experience some weirdness when using JavaScript to:

let storage_passage = engine.story.passageNamed("Storage");
write('The source of the passage is "' + storage_passage.source + '".');

...and the "Storage" passage has:

test_variable: 0
--
This is passage content! {test_variable}

...the output was not the entire passage and got hung up at the -- and actually rendered the javascript output as an <h2> tag so there is something going on above the -- in passages and it may all be related in some way.

klembot commented 7 months ago

I believe this is now fixed in version 2.0.0, but please re-open if you still see issues.