Avatar pic in sidebar

I have been wracking my brain for a while, googled for an hour and cant figure this out. I have it so you can choose an avatar from 7 different pics. I want whatever pic you choose to appear on the sidebar but cannot get it to appear. simply using $avatar just gives me the pic name using img src just gives me a broken image.

Are you checking by pressing the button Test or Play?
Then it is normal. It has to do with the URL of the file.

See this thread:

Workarounds:

  • temporarily host the images online
  • export to html and open that file

hmm ive never actually done a test before I usualy just run the index html from the folder and everything usualu runs, but when i tried the test its telling me my start page has an issue with my widget. Error: starting passage “widgets” contains special tags; invalid: “widget”. yet the passage works and the picture is there when i open it with the index

this is my widget. I use it all the time and never have an issue with it,

<<widget "addPic">>
<center>
<<if $args[1].includes(".webm")>>
​
<<print '<video src="ssexImages/clips/'+$args[0]+'/'+$args[1]+'" autoplay loop muted style="width: 60%; height: auto;"></video>'>>
​
<<elseif $args[1].includes(".gif")>>
​
<<print '<img src="ssexImages/'+$args[0]+'/'+$args[1]+'" style="width: 50%; height: auto;"/>'>>
​
<<elseif $args[1].includes(".webp")>>
​
<<print '<img src="ssexImages/'+$args[0]+'/'+$args[1]+'" style="width: 50%; height: auto;"/>'>>
​
<<elseif $args[1].includes(".jpg")>>
​
<<print '<img src="ssexImages/'+$args[0]+'/'+$args[1]+'" style="width: 50%; height: auto;"/>'>>
​
<<else>>
​
<<print '<img src="ssexImages/'+$args[0]+'/'+$args[1]+'" style="max-width: 120vh; height: 80vh;"/>'>>
​
<</if>>
</center>
<</widget>>

I actually just figured out the sidebar pic

<<print '<img class="head" src="ssexImages/people/You/'+$avatar+'">'>>
Not sure about the widget though. It all still works when running the actually game just not when I test from here

The error tells you everything.
The Starting passage of your project is tagged with widget, which is something you’re not allowed to do.
Players should not be sent to any passage tagged widget

Beyond the actual issue, noted by @manonamora, here’s a tip.

You don’t need to use the Stupid Print Trick™ here—i.e., printing markup so that you can resolve expressions. SugarCube’s HTML parser supports what’s known as the evaluation attribute directive, which allows you to resolve expressions without the SPT™.

Here’s an example of what you should be doing instead using the first two elements from your example widget:

<video @src="'ssexImages/clips/' + $args[0] + '/' + $args[1]" autoplay loop muted style="width: 60%; height: auto;"></video>
​
<img @src="'ssexImages/' + $args[0] + '/' + $args[1]" style="width: 50%; height: auto;">
1 Like