So, I downlaoded the Custom Macro “Speech Box System” https://github.com/ChapelR/custom-macros-for-sugarcube-2/blob/master/docs/speech-box-system.md
This Macro works using Java and CSS. I know how to edit CSS, but Java eludes me completely. The thing is, this macro lets me create a character and assing an image to show its avatar. I want to do that, but I need the avatar to change based on a Twine variable ($mood)
I know how to write the code in Twine, that is not the problem. But the .js is written in such a way, that the avatar section only works for images, so it does not allow a variable, even if the variable == an img.
Can someone tell me what is it that I have to change in the .js? Thanks!
I don’t wanna be that guy, but… Java and JavaScript are two completely different programming languages.
I don’t think you need to change the source code. After reading the documentation you linked, why don’t you create different character macros for each mood, for example, Lisa_Sad, Lisa_Happy, Lisa_Surprised, ec, and then use the appropriate character mood in you own code.
The thing is, that would work if I wanted the dialogue to be different depending on the mood. But I don’t. I want the avatar to be a sort of “clue” for the player to understand the mood the character currently has. If I were to create a character for each mood, I would need to copy paste each dialogue line six times, one for each mood, inside a big if and ifelse macro, leaving me with huge passages and strigs even for the smallest interaction.
Or, if you want to use the same syntax as in the examples, you could use a widget instead of the <<character>> macro. Create a new passage, tag it widget (and optionally nobr), with this code:
<<widget lisa container>>
<<say 'Lisa' `'images/lisa_'+$mood+'.jpg'`>>_contents<</say>>
<</widget>>