JavaScript emojis are kinda elusive

Hey,
I’m using Twine 2.7.0 and Chapbook 1.2.3.
I wanted to see if it was possible to add emojis. I did what the documentation says and add this to the js section :

engine.extend('1.0.0', () => {
    config.template.inserts = [{
        match: /^smiley face$/i,
        render: () => '😀'
    }, ...config.template.inserts];
});

It didn’t worked so I dl the example on twinery (/cookbook/addingfunctionality) and it worked…
Until I duplicated the project and started to add anything in the vars section. Then it worked on “test” but not on “play”.
I only added this to the vars section :

config.style.backdrop: "#4A3F35"

I tried to duplicate again and changed only the header and it’s the same.
Basically if I put anything in the vars section emojis stop working on “play”.

Any ideas ?

2 Likes

I copied and pasted the JavaScript code you provided and called the {smiley face}. It worked.
I added the backdrop style to the var section and it worked too. Both with playing and testing.

I’m assuming your page just displays {smiley face} as straight code (not rendered, no errors).

There is this issue that is still open on the Chapbook github. Maybe Chris @klembot can provide some clarity and the best way to avoid the problem.

I’m a little fuzzy about it all though since I haven’t had to deal with it for a very long time. Here’s the explanation Greyelf @Greyelf provided…

…I just cleared my browser’s entire cache/cookies and it worked to reset things, but Greyelf explains how to target that specific local storage variable. Also, his take on the order of adding the var section variables and extending the custom inserts is spot on.

I really like Chapbook, but this issue needs more light shed on it for new users.

Let us know if you need any further guidance. :slight_smile:

1 Like

Damn…
I think I’ll just forget about emojis :no_mouth: this is not my level right now and too much to handle with all I had to learn already. Anyway I don’t need them, it was just for fun :sweat_smile:

But thanks for the answer, I keep it in mind in case I need to add some java modifiers or something like that some day !

1 Like

Yeah, Chapbook is great, clean and simple… and then you try and customize it. :nerd_face:

It’s the case for customizing all Twine story formats though. :wink:

Good luck on your game!

1 Like