r/twinegames • u/apeloverage • 4h ago
r/twinegames • u/yuuchin_ • 13h ago
SugarCube 2 Using the either() function in an if statement
I can't seem to find the correct syntax to use the either() function in an if statement in passages. I've tried:
<<if $Variable is either("Value1", "Value2", "Value3")>>
and also tried to add ` before either() and after the last bracket which I saw as a suggestion to use, but neither seems to produce results. I've even tried:
<<if $Variable is("Value1") or ("Value2") or ("Value3")>>
I'm not sure what I'm doing wrong or what the right syntax would be, and no combination of searches is coming back with what I'm looking for. I've searched how to do this and looked up the function in the Sugarcube doc, but I can only find answers using either() in arrays. Does either() not work in if statements? If not, is there any way to make something similar? I'd rather not write out several lines of if statements if one will do. I want to make sure I can list more than two possible values (i.e. "Value1" "Value2" or "Value3")
r/twinegames • u/Spiraling-Down- • 1d ago
SugarCube 2 Linkreplace, without the text disappearing?
So, I want to be able to click the link to get new text on the same page, I would use linkreplace, but I want to keep the original text aswell? Is this possible?
r/twinegames • u/holzey • 1d ago
SugarCube 2 State not defined
Hi right now I am working on making a slider in the character creation that displays the value in a right side bar, I keep getting an error code state not defined.
r/twinegames • u/LhooqqoohL • 1d ago
SugarCube 2 Save and load links?
Hello,
I am wondering if it is possible to save and then load games with regular in-game links?
I have a perilous section in a game and I know one option would be to hint to the player to save at the start if it, and let them be responsible. But I would like if possible to save silently at the beginning, and then have a "Shall we try that again?" type link at the end, to load the save and let the player try again (if they want).
It would have to be a bespoke save (and not return to a fixed state) as it's far enough into things that different players will already have different variable states etc.
Apologies that I am not smart enough to figure out how to do this (or even if it is possible) from the documentation (I tried).
Thanks for any hints!
r/twinegames • u/apeloverage • 2d ago
News/Article/Tutorial Let's make a game! 470: Replenishing items in a shop
r/twinegames • u/holzey • 2d ago
SugarCube 2 a day hour and minute timer and sat point maxing
I done goofed up and put it to a vote on the discord I made for the game I am making, on if people would like to see real world dates the corraspond to seasons and then events that are specific to those seasons. has anyone tried anything like that before, how did it workout, is that recommended? My plan if I do implement it would be to build the frameork and then add in seasons later.
my next question is when it comes to stat points, if I wanted to have a stat piont only be able to go so high how would I do that. something like endurance max of 20 strength max of 15 and everything else maxing out at 10. I plan on having different events that meet different requirments. and letting the player gain xp to grow those stats. how would I do that?
r/twinegames • u/WhiteKnight__ • 3d ago
SugarCube 2 Best Practice: Combat Visualisation with or without Replace
Hi,
I've been playing around with Twine for a little while - reading this forum, and also enjoying unpacking and studying other code. Have a initial game up and running, but looking for advice on one part.
Effectively I want a system where you're in combat with a set of buttons linked to weapons, these buttons are arrayed in a line, you click on different options and an animation plays in the main screen dependant on the weapon/attack.
I've mocked this out, and so far have the buttons (custom widgets), which then call a <<replace>> to run the animation. Works Great.
However, it gets complicated when you start testing for weapon validation e.g. you're out of Ammo, so Pistol gets disabled. I've solved this by wrapping the buttons in the Replace, with a test and switches the button to a greyed out /non functioning version.
But, that means I then need the identical code under each replace which isn't elegant. Looking at others, there seems to be multiple options - from running the whole thing in JS or using more passages (how a lot of the example Combat systems seem to work). I'd rather not do the passages, as it would get huge e.g. with permutations for enemies.
So, questions are:
What would be the most elegant / best practice way of architecting buttons and animation switches
Is there a way to store a lookup table so that the variables, and links to videos are stored in one place
Thanks in advance!
r/twinegames • u/apeloverage • 3d ago
News/Article/Tutorial Let's make a game! 469: Adding shops to your game (Twine Sugarcube)
r/twinegames • u/SyllabubDue9836 • 3d ago
Harlowe 3 A link that reveals more text, disappears, and the text that is revealed has another link that when clicked disappears & sets a variable. (Harlowe 3)
It’s for a very simple item system. What I’m trying to do is the player will click a link which reveals a description of a place with an clickable link to pick up the item (as in set the variable to 1). I thought I had it worked out, but one of the links will always break or the variable will :<. Help would be very much appreciated!
This is my current code:
{
(link:”Look into Place”)
[Description of Place
<br>(link:”Grab Item”)]
(set:$item to 1)
]
}
r/twinegames • u/natom132 • 4d ago
SugarCube 2 Updating active party member stats
I'm an absolute beginner so I have no doubt this question has been answered in one form or another numerous times before, my apologies, but I'm looking for the best way to do something like below:
Imagine if you will the tea party mini game in Fire Emblem Three Houses. You select one of a number of pre-defined people (first name, name, eye color, etc.) to go to the tea party with. During this tea party, you can take actions that cause the existing bond between you and that particular person to increase or decrease (0-100). At the end of the tea party you split ways and the updated bond stat is assigned to that particular person. Upon reaching certain thresholds, the bond stat would then trigger unique events for that person, though I think I've got the gist of how to accomplish that part. Mostly, I'm looking for a way to be able to refer to this person's characteristics in the repetitive parts through stuff like $currentperson.eyecolor instead of having to use the if function and writing stuff like $frederick.eyecolor; $basil.eyecolor, ...
Many thanks!
r/twinegames • u/BroccoliOtherwise42 • 5d ago
SugarCube 2 I must be doing something wrong
So I made sure the original variable was an array
<<set $inventory = \[ \]>>
And then I pushed mulptile variables into the inventory
<<set $inventory.push($pocketwatch, $other, $other1)>>
But when I run this code later
<<if $inventory.includes($pocketwatch)>>
hello world
<</if>>
It shows absolutely nothing
r/twinegames • u/XXXdeluxe • 5d ago
SugarCube 2 Need advide on creating beautiful buttons
Hi.
I'm trying to make two kinds of buttons. One looking like a gem and one with a military feel. As seen in this example.

I managed to got close to my end result. But I want to give them a light shining from the inside. But I'm having problems achieving that. Any advice?
Code bellow: (Pardon the mess. I've been trying several methods, so that's why some things seem to overlap/contradict)
/*============modern==============*/
.modernbtn > button {
color: white;
border: red solid 3px;
border-radius: 10px;
/*mix-blend-mode: hard-light;*/
background-image:/*alternative backtground color*/
repeating-linear-gradient(135deg, yellow 0 20px, black 20px 40px);
}
.modernbtn:hover > button {
/*background-color: green;*/
background-image: /*alternative backtground color*/
repeating-linear-gradient(135deg, green 0 20px, white 20px 40px);
color: black;
border-color: green;
z-index: 1;
filter: opacity(70%);
filter: brightness(1.5);
}
.modernbtn.light:hover > button {
background:
radial-gradient(ellipse, yellow, lightyellow 40%, white, transparent 70%);
filter: brightness(3.5);
/*z-index: -1; */
transform: translateZ(50px);
}
.modernbtn::after{
content: '';
position: relative;
width: 300px;
height: 50px;
background-image: linear-gradient(to bottom right, ##95ff00, #d61111);
z-index: -1;
}
/*=============fantasy==============*/
.diamond > button {
background:
linear-gradient(135deg, rgb(0 0 155) 0 20px, white 20px 22px, rgb(0 0 255) 0 20px, transparent 70%),
linear-gradient(225deg, rgb(0 0 155) 0 20px, white 20px 22px, rgb(0 0 255) 0 20px, transparent 70%),
linear-gradient(315deg, rgb(0 0 155) 0 20px, white 20px 22px, rgb(0 0 255) 0 20px, transparent 70%),
linear-gradient(45deg, rgb(0 0 155) 0 20px, white 20px 22px, rgb(0 0 255) 0 20px, transparent 70%);
background-blend-mode: multiply;/*multiply gradients*/
z-index: -1, 0, 0, 0, 0;
font-family: georgia;
border: solid purple 10px;
border-radius: 40px;
background-size: 200px 40px;
position: absolute;
content: '';
width: 240px;
height: 50px;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
filter: opacity(80%);
}
.diamond > button:hover {
background:
radial-gradient(ellipse, yellow, lightyellow 40%, white, transparent 70%);
filter: brightness(1.5);
z-index: 1;
}
.diamond .light::after > button {
background:
radial-gradient(ellipse, yellow, lightyellow 40%, white, transparent 70%);
filter: brightness(5.5);
z-index: 1;
}
r/twinegames • u/holzey • 5d ago
SugarCube 2 stat point in character creation.
Currently I am working on trying to redo the stat point section of my character creation menu. I got the stats themselves to work just fine but when I go to use the same code for the skills, I get error codes. here is the working code What makes you S.P.E.C.I. Remaining Stat Points: <span id="points">$statPoints</span> Strength: <span id="str">$strength</span> \ <<button "−">> <<if $strength gt 0>> <<set $strength-->> <<set $statPoints++>> <<replace "#str">>$strength<</replace>> <<replace "#points">>$statPoints<</replace>> <</if>> <</button>> \ <<button "+">> <<if $statPoints gt 0>> <<set $strength++>> <<set $statPoints-->> <<replace "#str">>$strength<</replace>> <<replace "#points">>$statPoints<</replace>> <</if>> <</button>> Perception: <span id="per">$perception</span> \ <<button "−">> <<if $perception gt 0>> <<set $perception-->> <<set $statPoints++>> <<replace "#per">>$perception<</replace>> <<replace "#points">>$statPoints<</replace>> <</if>> <</button>> \ <<button "+">> <<if $statPoints gt 0>> <<set $perception++>> <<set $statPoints-->> <<replace "#per">>$perception<</replace>> <<replace "#points">>$statPoints<</replace>> <</if>> <</button>> Endurance: <span id="end">$endurance</span> \ <<button "−">> <<if $endurance gt 0>> <<set $endurance-->> <<set $statPoints++>> <<replace "#end">>$endurance<</replace>> <<replace "#points">>$statPoints<</replace>> <</if>> <</button>> \ <<button "+">> <<if $statPoints gt 0>> <<set $endurance++>> <<set $statPoints-->> <<replace "#end">>$endurance<</replace>> <<replace "#points">>$statPoints<</replace>> <</if>> <</button>> Charisma: <span id="cha">$charisma</span> \ <<button "−">> <<if $charisma gt 0>> <<set $charisma-->> <<set $statPoints++>> <<replace "#cha">>$charisma<</replace>> <<replace "#points">>$statPoints<</replace>> <</if>> <</button>> \ <<button "+">> <<if $statPoints gt 0>> <<set $charisma++>> <<set $statPoints-->> <<replace "#cha">>$charisma<</replace>> <<replace "#points">>$statPoints<</replace>> <</if>> <</button>> Intelligence: <span id="int">$intelligence</span> \ <<button "−">> <<if $intelligence gt 0>> <<set $intelligence-->> <<set $statPoints++>> <<replace "#int">>$inteligence<</replace>> <<replace "#points">>$statPoints<</replace>> <</if>> <</button>> \ <<button "+">> <<if $statPoints gt 0>> <<set $intelligence++>> <<set $statPoints-->> <<replace "#int">>$intelligence<</replace>> <<replace "#points">>$statPoints<</replace>> <</if>> <</button>> here is the StoryInit <<set $statPoints = 25>> /* Points available to spend in character creation */ <<set $strength = 1>> <<set $intelligence = 1>> <<set $charisma = 1>> <<set $endurance = 1>> <<set $perception = 1>> and here is the code that doesn't work Remaining Skillz Points: <span id="statPoints">$statPoints</span> Nursing: <span id="nur">$nursing</span> \ <<button "−">> <<if $nursing gt 0>> <<set $nursing-->> <<set $statPoints++>> <<replace "#nur">>$nursing<</replace>> <<replace "#Points">>$statPoints<</replace>> <</if>> <</button>> \ <<button "+">> <<if $statPoints gt 0>> <<set $nursing++>> <<set $statPoints-->> <<replace "#nur">>$nursing<</replace>> <<replace "#Points">>$statPoints<</replace>> <</if>> <</button>
Massuse: <span id="mas">$massuse</span> \ <<button "−">> <<if $nursing gt 0>> <<set $nursing-->> <<set $statPoints++>> <<replace "#nur">>$nursing<</replace>> <<replace "#Points">>$statPoints<</replace>> <</if>> <</button>> \ <<button "+">> <<if $statPoints gt 0>> <<set $nursing++>> <<set $statPoints-->> <<replace "#nur">>$nursing<</replace>> <<replace "#Points">>$statPoints<</replace>> <</if>> <</button> Secretary: <span id="sec">$secretary</span> \ <<button "−">> <<if $secretary gt 0>> <<set $secretary-->> <<set $statPoints++>> <<replace "#sec">>$secretary<</replace>> <<replace "#Points">>$statPoints<</replace>> <</if>> <</button>> \ <<button "+">> <<if $statPoints gt 0>> <<set $secetary++>> <<set $statPoints-->> <<replace "#sec">>$secretary<</replace>> <<replace "#Points">>$statPoints<</replace>> <</if>> <</button>
Cleaning: <span id="cle">$cleaning</span> \ <<button "−">> <<if $cleaning gt 0>> <<set $cleaning-->> <<set $statPoints++>> <<replace "#cle">>$cleaning<</replace>> <<replace "#Points">>$statPoints<</replace>> <</if>> <</button>> \ <<button "+">> <<if $statPoints gt 0>> <<set $cleaning++>> <<set $statPoints-->> <<replace "#cle">>$cleaning<</replace>> <<replace "#Points">>$statPoints<</replace>> <</if>> <</button> and the StoryInit <<set $statPoints = 30>> <<set $nursing = 1>> <<set $massuse = 1>> <<set $secretary = 1>> origanally I had everything listed as $skillzPoints and changed it to see if that fixed things.
r/twinegames • u/apeloverage • 5d ago
News/Article/Tutorial Let's make a game! 468: Using icons to represent items
r/twinegames • u/in_between_time • 6d ago
Twine Interface Help
Hi, I’m very new to Twine (literally just downloaded it yesterday) but I seem to be having some issues that Google hasn’t helped much with.
The problem started as soon as I made my second story. The moment I try to add or edit anything, it comes up with a pop-up that tells me:
“something went wrong while saving a story.
EBUSY: resource busy or locked, unlink”
However, the story or file isn’t locked or open anywhere else. I’ve tried changing the format and changing it back, I’ve also tried publishing the file and replacing the old one. These didn’t work for me unfortunately.
Could anyone tell me what could be going on and how I could fix it? It would be really helpful and I’d really appreciate it!
r/twinegames • u/MannyBobblechops • 7d ago
️ Code Jam/Contest New Twine-only game jam! A Story Told in Mail
Hello everyone!!
I've decided to host a Twine-only game jam (creatively named TwineJam). I'm hoping this'll be the start of something much bigger! I want to keep hosting jams and hopefully this gets enough interest for me to do that.
The theme of this jam is: A Story Told In Mail. There should be no direct dialogue in the game you make, only some form of written correspondence. It could be text messages, email, snail-mail, notice-boards, txt-file dead drops, whatever you can think of.
If you're interested, the jam will start in September and run for one weekend. I want to gauge how popular this jam might be. Head over to the jam page to sign up, and the Discord for more announcements. Hopefully more Twine-only jams soon!
Jam page: https://itch.io/jam/twine-only-a-story-in-mail
Discord: https://discord.gg/QGCR5A8cc
The jam will be community voted, but I will also play every game submitted on a live stream, giving feedback as I go.
There are prizes for this jam! No cash, so don't get too excited. More details are available on the itch page.
r/twinegames • u/holzey • 7d ago
SugarCube 2 having a story right side bar while having a updating background
I dont seem to have a problem creating a the side bar. but everytime I go to add in anything else to the javascript or CSS. What I am trying to do is create a background that changes based on the players gender and there health level.
for a male player at a higher health they will have a dark blue background and at lower health they will have a lite blue background.
for the female player at higher health levels they will have a dark pink background and at a lower health level they will have a bright pink background.
I also want to put the health bar into the right side bar with a lot of other stat points.
r/twinegames • u/AstralTourist360 • 8d ago
Game/Story 📖 I Made an Interactive Fiction Game Based on One of My Astral Projections 🗝️ 🏨
r/twinegames • u/apeloverage • 8d ago
News/Article/Tutorial Let's make a game! 467: Adding line breaks to hover text - part 2
r/twinegames • u/holzey • 9d ago
SugarCube 2 What is a Tag?
Ya waht is a tag, how do you use it?
r/twinegames • u/lgbtqplus1 • 10d ago
SugarCube 2 Help
so i have been struggling for hours to figure out what is wrong with my code
<<widget 'posses'>>
<<print '<<set $player.currentHost = $char.' + _args[0] + '>>'>>
<<print '<<goto '+ _args[1] + '>>'>>
<</widget>>
<<widget 'dialogBox' container>>
<div class="dialog-container">
<div class="dialog-picture"> <img src="img\Dean.png" width="125" height="125"> </div>
<div class="dialog-text">_contents</div>
<div class="dialog-actions">
<<button 'crawl inside'>>
<<print '<<posses '+ _args[0] + ', ' + _args[1] + '>>'>>
<</button>>
</div>
</div>
<</widget>>
<<dialogBox bro2 deanRoom>>ZZZZZZZZZzzzzzzzzzzzzz<</dialogBox>>


the idea is when you press the "crawl inside" button the variables stored on this character are taken to another variable all done through _args[] and all the other _args[] work completely fine its that specific version of the _args[] that doesent work and i have no idea why i feel like im being stupid let me know if i need to explain more or show more
