HTML Twine/sugarcube Variables

Marduk73

Newbie
Jul 19, 2021
19
4
Hi it´s me , again....
The following problem: in StoryInit I declare the following: set $ajax to "images/chars/test.jpg" and the variable $noema is false, in the passage I set the variable $noema to true and <if $noema is true> set $ajax to "images/chars/char.jpg" <else>set $ajax to "images/chars/test.jpg"
</if> but this does not change the display image in the speechbox. What am I doing wrong? speechbox declares <characters "Ajax" $ajax>, which works
 

Alcahest

Engaged Member
Donor
Game Developer
Jul 28, 2017
3,485
4,330
Post the relevant code or we can just guess, but one thing that comes to mind is that you have the if statement after the image is displayed.
 

Marduk73

Newbie
Jul 19, 2021
19
4
the code: in Storyinit:
<<set $noema to false>>
<<set $jo to "images/characters/face_01.jpg">>
<<character "Jo" $jo>>
<<character "Noema" "images/characters/noema_03.jpg">>
in Passage:
<<Jo>>Stop, that's not me. What is wrong with me?<</Jo>>
<<Noema>>Wrong, that's exactly you. Don't you remember?<</Noema>>
<<set $noema to true >>
<<if $noema is true>> <<set $jo to "images/characters/char_01.jpg">>
<<else>>
<<set $jo to "images/Characters/face_01.jpg">>
<</if>>
//After the if query, the character image should be changed//
<<Jo>>Damn, am I crazy? Who are you and what are you doing in my head?<</Jo>>
<<Noema>>I? I am you, at least to a large extent. It'll take too long to explain all this, but you'll figure it out. I will help you with it.<</Noema>>
<<Jo>>Then why can't I remember you?<</Jo>>
 

Alcahest

Engaged Member
Donor
Game Developer
Jul 28, 2017
3,485
4,330
I see, it's about Chapel's character macro.

The thing is that the macro is not saving the variable to use for the image, it's just saves the value of the variable. So changing the variables afterward is pointless.

I could think of a few ways to do it, but since I'm not familiar with Chapel's macros, I don't wanna give any advice. Someone else might be able to help.
 

Marduk73

Newbie
Jul 19, 2021
19
4
Right, so I don't have to change the image but use a new character or it´s possibe: <<set $jo to <<character "Jo" "images/characters/test_01.jpg">> and then changed to <<character "Jo" "images/characters/char_01.jpg">>?
 
Last edited:

Feyschek

Well-Known Member
Game Developer
Jun 12, 2021
1,594
1,002
I don't know how useful it will be, but I hope it will help. Go to the stylesheet and paste this code.

.Vendor {
background-color: #00abab;
}

.Vendor .avatar {
background-image: URL("System/Characters/Vendor.jpg");
}

.avatar {
display: block;
padding: 1px;
height: 84px;
width: 84px;
float: left;
margin: 0px 10px 0px 0px;
border: 2px solid Black;
border-radius: 5px;
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}

.speech {
color: #eee;
border: 2px solid Black;
border-radius: 8px;
padding: 8px 8px 8px 8px;
}

Change the values that I marked in red to yours. After that, we insert this code into the engine pass.

<div class="speech Vendor"><span class="avatar"></span>Кассир<hr>Спасибо за покупку. </div>\

What should be used in the style sheet is highlighted in red. The character's name is highlighted in green, change it to the one you need.

Example.

unknown_2024.03.12-21.35.png
 
  • Like
Reactions: Marduk73