HTML Need help to add gifs or video in my game

worgenxtream67

New Member
Aug 18, 2023
10
2
Hello everyone, I'm using twine with sugarcube to create my first html real porn game, and i want to add gifs and vidéo in my game, i know how to add 1 or more vidéo on the same page, but not how to create random vidéo, i want that in the player room, he can click on computer, and clickon look porn and there is 1 random gifs or vidéo appear and i don't know how to do this ?
I'm bad in english and it's my first game so i'm a real beginner x)
 

KillerCat!

New Member
Jul 4, 2024
6
4
You can add Images/Gifs [img[Here/is/My/Img.png]] like so.
Here is the documentation (Sugarcube Docs)

You can also just add them as basic HTML Elements using:
<img src="Here/is/my/image.png">
<video src="Here/is/my/video.mp4" autoplay></video>

documentation
documentation

You can make something random by doing something a little like this:
<<set _Video = ["Here/is/my/Video.mp4", "Here/is/my/Video2.mp4", "Here/is/my/Video3.mp4"].random()>>
<video @src=_Video autoplay></video
Do not forget the @ symbol or it will not work! (It lets Sugarcube know you want it to run logic first!)

If you are this brand new to Sugarcube, I would recommend you watch/read some tutorials first, to get a hang of things like this!
Have a great rest of your day!
 
Last edited:

worgenxtream67

New Member
Aug 18, 2023
10
2
You can add Images/Gifs [img[Here/is/My/Img.png]] like so.
Here is the documentation (Sugarcube Docs)

You can also just add them as basic HTML Elements using:
<img src="Here/is/my/image.png">
<video src="Here/is/my/video.mp4" autoplay></video>

documentation
documentation

You can make something random by doing something a little like this:
<<set _Video = ["Here/is/my/Video.mp4", "Here/is/my/Video2.mp4", "Here/is/my/Video3.mp4"].random()
<video @src=_Video autoplay></video
Do not forget the @ symbol or it will not work! (It lets Sugarcube know you want it to run logic first!)

If you are this brand new to Sugarcube, I would recommend you watch/read some tutorials first, to get a hang of things like this!
Have a great rest of your day!
Thank you, i will try this tomorrow,yes i'm really new, have begin yesterday x) i've read sugarcube documentation, watch tuto on youtube ect but i've never find what i was looking for, so thank you, and hope i can do it :)
 
  • Hey there
Reactions: KillerCat!

worgenxtream67

New Member
Aug 18, 2023
10
2
Hello, i have try today and i've found how to do it, thank you !

that's what i've done:

<<nobr>><<switch random(1, 4)>>
<<case 1>>
<img src="URL" /><br>
<<case 2>>
<img src="URL" /><br>
<<case 3>>
<img src="URL" /><br>
<<case 4>>
<img src="URL" /><br>
<</switch>><</nobr>>
 
  • Like
Reactions: KillerCat!

Feyschek

Well-Known Member
Game Developer
Jun 12, 2021
1,271
708
Hello everyone, I'm using twine with sugarcube to create my first html real porn game, and i want to add gifs and vidéo in my game, i know how to add 1 or more vidéo on the same page, but not how to create random vidéo, i want that in the player room, he can click on computer, and clickon look porn and there is 1 random gifs or vidéo appear and i don't know how to do this ?
I'm bad in english and it's my first game so i'm a real beginner x)
Here's the code I'm currently using to create random videos.
The only disadvantage may be for you that the video should be named in the form of numbers.

<video autoplay loop muted><source @src='"Content/Pornohub/"+random(1,200)+".webm"' type="video/webm"></video>

After that, you need to create a button that will update the video content.

<span id="videocontent">\
<video autoplay loop muted><source @src='"Content/Pornohub/"+random(1,200)+".webm"' type="video/webm"></video>\
</span>\

<<button "repeat">>\
<<done>><<replace "#videocontent">>\

<video autoplay loop muted><source @src='"Content/Pornohub/"+random(1,200)+".webm"' type="video/webm"></video>\

<</replace>><</done>>\
<</button>>\

After clicking the "repeat" button, the game will update this section of the content which is in the <span> macro.
;) Have fun.
 

KillerCat!

New Member
Jul 4, 2024
6
4
Hello, i have try today and i've found how to do it, thank you !

that's what i've done:

<<nobr>><<switch random(1, 4)>>
<<case 1>>
<img src="URL" /><br>
<<case 2>>
<img src="URL" /><br>
<<case 3>>
<img src="URL" /><br>
<<case 4>>
<img src="URL" /><br>
<</switch>><</nobr>>
My Way of doing it would look a little like this:
<<set _img to ["URL1", "URL2", "URL3"].random()>>
<img @src=_img>
As this is a little more compact for my linking, but I understand if you choose a different route, as many paths lead to the same exit.

Also if you're using a <<nobr>> macro you might as well use some spaces and indentation, for it to be easier to read.
Something a little like this:
VSCodium_TgyBbEoOjq.png
Hope you're having a great day, and good luck on making your game!
 
  • Like
Reactions: worgenxtream67

Feyschek

Well-Known Member
Game Developer
Jun 12, 2021
1,271
708
My Way of doing it would look a little like this:
<<set _img to ["URL1", "URL2", "URL3"].random()>>
<img @src=_img>
As this is a little more compact for my linking, but I understand if you choose a different route, as many paths lead to the same exit.

Also if you're using a <<nobr>> macro you might as well use some spaces and indentation, for it to be easier to read.
Something a little like this:
View attachment 3804624
Hope you're having a great day, and good luck on making your game!
It's enough to do these things and that's it, you'll have spaces between the lines.

<<button "repeat">>\

<</button>>\

<<nobr>> it is convenient, but it is better to do manual control.
 
  • Like
Reactions: worgenxtream67

KillerCat!

New Member
Jul 4, 2024
6
4
<<button "repeat">>\

<</button>>\
Why are you putting in a button? Maybe I understood this wrong, I thought the Author wanted a random image to appear, and not for there to be a functionality of cycling through all the random images?

It's enough to do these things and that's it, you'll have spaces between the lines.
Every game looks a little different, as well as the code, I added indentation because I feel it adds very much to the visibility/readability, I don't know if the author rewrote the code here and struggled with the spacing or if this is his 1 to 1 copy of his in Twine Code, so I was just putting this out for him to see that's it a possibility.

<<nobr>> it is convenient, but it is better to do manual control.
What do you mean by Manual Control?
<<nobr>> or using Config.passages.nobr = true is basically manual control?
As the game will never generate a <br> tag for you, you can add them manually by using <br>.

Also, for all of my projects,
I add nobr where ever possible or toggle it permanently, as widgets and or macros might generate unwanted break lines, and make a passage have a ridiculous 5-line break between content.

Hope you're also having a nice day!
 

worgenxtream67

New Member
Aug 18, 2023
10
2
My Way of doing it would look a little like this:
<<set _img to ["URL1", "URL2", "URL3"].random()>>
<img @src=_img>
As this is a little more compact for my linking, but I understand if you choose a different route, as many paths lead to the same exit.

Also if you're using a <<nobr>> macro you might as well use some spaces and indentation, for it to be easier to read.
Something a little like this:
View attachment 3804624
Hope you're having a great day, and good luck on making your game!
Thank you, yes i have do it like this, with indentation, it's easier to read :)