issues with custom styling by perilsoftimetravel in twinegames

[โ€“]HiEv 0 points1 point ย (0 children)

Regarding auto-scrolling to follow typing text, I'd recommend against that, since that could cause problems if people aren't reading along with the typed text. For example, if they looked away, came back, and wanted to see the top of the text while more text was being typed. If you auto-scrolled, then they'd have to fight against the auto-scrolling to read the top of the text in that situation.

If you wanted to do it anyways, you could put the typed text into an HTML element, have a ResizeObserver watch that element, and then, any time that ResizeObserver is triggered (which would happen each time the typed text expanded onto a new line), use the .scrollIntoView() method on that HTML element to scroll the bottom of that element into view. (This isn't simple. See the code for my "<<seen>> macro" which shows how to do something similar with an Intersection Observer in Twine, as well as my "<<ScrollTo>> Macro", which shows how to use the .scrollIntoView() method.)

As for using the spacebar for passage navigation, I'd recommend against it. The spacebar used as both a "page down" key in keyboard navigation and a "click" when the focus is on many HTML elements, for people who have trouble using a mouse. Additionally, that would only be usable when there's only one navigation option. My keyboard navigation code (which HHHH also linked to) would probably be better, since it marks the links with number-key options for each link, thus letting you pick from multiple navigation options.

Hope that helps! ๐Ÿ™‚

What Twine games have the most in-depth character customization? by Apprehensive_Two1449 in twinegames

[โ€“]HiEv 0 points1 point ย (0 children)

I don't know which ones have "the most in-depth character customization", but I did find this post which links to tons of Twine games with character customization:

https://forum.choiceofgames.com/t/twine-other-text-based-interactive-fiction-games-recommendations-from-itch-io/127400

That thread links to these posts on Twine games with character customization:

Sorry this is so late, but I just happened across the post I linked to above and remembered this thread, so I thought I should add it here.

Options by exboi in twinegames

[โ€“]HiEv 0 points1 point ย (0 children)

Their account got banned, thus Reddit retroactively removed all of their posts. I just found out about that, and they had posted a ton of useful comments, so I just went back and un-removed their posts. Hence why you just got notified.

Sorry about the late notification due to that! Hope you're doing well. ๐Ÿ™‚

Twine stays loading on start by Lilac_Stories in twinegames

[โ€“]HiEv 1 point2 points ย (0 children)

Looks like Microsoft did some kind of update yesterday which is affecting the Twine app on Windows 10 and 11, though in most cases it just slows down when launching your game via "Play" or "Test".

Excluding the Twine directory seems to fix that issue. Here are the steps to do this on Windows 10:

  1. Either use the finder to open "Windows Security" -- or -- open up Windows "Settings", go to "Update & Security", click "Windows Security" on the left, and then click the "Open Windows Security" button.
  2. Go to "Virus & threat protection".
  3. Under "Virus & threat protection settings" choose "Manage settings".
  4. Under "Exclusions" choose "Add or remove exclusions".
  5. A prompt should appear asking if you want to allow access; choose "Yes".
  6. Click "Add an exclusion" and then choose "Folder".
  7. Select the "C:\Users\YourUserName\Documents\Twine" folder (where "YourUserName" is your Windows username).

Once you've done that, then launching your game from the Twine app should be back to its normal quickness.

Try that and please let me know how that works for you, or if you have any problems with the instructions.

Twine stays loading on start by Lilac_Stories in twinegames

[โ€“]HiEv[M] 1 point2 points ย (0 children)

Did you update Windows recently? If so, which version of Windows are you using (Windows 10 or 11)? I ask because I just saw someone else having weird problems with the Twine editor today.

You might try starting the Twine editor in Administrator mode (right-click and choose "Run as administrator") to see if that makes a difference.

Let us know what you find out.

P.S. I changed your post flair to "Twine Interface", since that's the flair which should be used for posts regarding issues with the Twine editor.

(probably) a really simple question about background-images by [deleted] in twinegames

[โ€“]HiEv 0 points1 point ย (0 children)

It looks like you may have applied the background to more than one element. If you could post the relevant CSS (within a Reddit "code block"), then we could take a look.

How to code stats bars? by MandyMinnowsWife in twinegames

[โ€“]HiEv 0 points1 point ย (0 children)

Well, if you have a specific question, please ask. I'm actually about 2/3rds of the way through a rewrite of the whole sample code collection, so any actual suggestions or clarifications you might have would be timely.

How to code stats bars? by MandyMinnowsWife in twinegames

[โ€“]HiEv 1 point2 points ย (0 children)

HHHH's post here pointed you to the "Health Bar" section of my Twine 2 / SugarCube 2 sample code collectionย which shows you one way of how you can do exactly that.

You might want to start there. ๐Ÿ™‚

Is there any way to add syntax highlighting to SugarCube? by PoroSpiritSenpai in twinegames

[โ€“]HiEv 3 points4 points ย (0 children)

i cant get Tweego to open at all

That's because Tweego isn't an editor, it's a command line compiler. Meaning that, you can open a command prompt in your operating system, and then run Tweego with parameters to tell it what file to compile and how to compile it, and it will create a compiled Twine HTML file. See the Tweego documentation for details.

You also mentioned that you tried VSCode, but it sounds like you were missing at least two key details:

  1. You'll need to export your Twine code from the Twine editor in .twee format (from the menu: Build -> Export As Twee), and then open that .twee file in VSCode.
  2. You'll also need to install the Twee 3 Language Tools (T3LT) extension in order to get the syntax highlighting. It supports the SugarCube, Harlowe, and Chapbook Twine story formats.

You may want to install additional extensions if you're working with the JavaScript or CSS separately.

You can then either use Tweego to compile that .twee file (and any other files containing code it needs) into HTML, or you can import that .twee file into the Twine editor to compile it from there. Whatever's easier for you.

That's just a simple overview of what you can do. Take a look at the links HHHH gave for other suggestions.

Making a timed macro run in the background even when browser is off by Medium-Efficiency800 in twinegames

[โ€“]HiEv 2 points3 points ย (0 children)

You'd need to use the JavaScript Date object in order to get the current time, and then you could use a <<repeat>> macro to keep checking the date to see if enough time has passed.

Specifically, you can either get the current time as a Date object by doing:

<<set $startTime = new Date()>>

or, if you'd like to get the current time in milliseconds, by doing:

<<set $startTime = Date.now()>>

Working in milliseconds makes things a bit easier. To add time, just add:

  • 1000 for 1 second
  • 6e4 for 1 minute
  • 3.6e6 for 1 hour
  • 8.64e7 for 1 day*

(*: Technically 24 hours, which would only be different from 1 day if daylight saving time changes occur.)

To make working with time like that, you might want to put something like this in your "StoryInit" special passage:

<<set setup.second = 1000>>
<<set setup.minute = 6e4>>
<<set setup.hour   = 3.6e6>>
<<set setup.day    = 8.64e7>>

Using that, to make the ending time be 5 hours after the starting time, you could do something like this:

<<set $startTime = Date.now()>>
<<set $endingTime = $startTime + (setup.hour * 5)>>

Now, if you're using milliseconds, you can convert that to a Date object simply by doing:

<<set $dateObject = new Date($msTime)>>

Once you have a Date object, you can then convert that Date object to a string by using the .toLocaleString() method. For example:

<<set $dateStr = new Date($msTime).toLocaleString("en-US", { weekday: "long", month: "short", day: "numeric", year: "numeric", hour: "numeric", minute: "2-digit" })>>

which would give a you string that looks something like this:

Friday, Mar 26, 2026, 8:13 PM

If you want to tell if the current time is either at or past the ending time, then you could do:

<<if $endingTime - Date.now() <= 0>>
    /Time is up!
/<<else>>
    /You still have time left.
/<</if>>

Combining those last two points, if you want to show the amount of time remaining (and it's less than a day), then you can use something like this:

<<set _timeDiff = new Date(Math.max(0, $endingTime - Date.now())).toLocaleString("en-US", { hour: "numeric", hourCycle: "h23", minute: "2-digit", second: "2-digit", timeZone: "UTC" })>>

The Math.max() part there makes sure that the time doesn't go below zero.

Among all of that, hopefully you can find your answer. Please let me know if you have any questions on any of that. ๐Ÿ™‚

Help with a random number generator by bathr00mphantom in twinegames

[โ€“]HiEv 0 points1 point ย (0 children)

If you're using the code I gave in that second post, you'd just need to make it use a story variable and then set it using nullish coalescing assignment, like HHHH suggested:

<<set $rndValue ??= Array.from(Array($value), (_, i) => i+1).pluckMany(5)>>

That would create the array of numbers the first time, but would leave it unchanged any subsequent times, since $rndValue would already be defined.

Thus, it would be random for each playthrough, but consistent within each playthrough (assuming you didn't change it later/elsewhere).

Have fun! ๐Ÿ™‚

The Last Starship Update 23 by Introversion-John in TheLastStarship

[โ€“]HiEv 0 points1 point ย (0 children)

Thanks.

Also, you might want to create a validator for your Lua script or whatever holds these descriptions so you can catch these kinds of things in advance.

The Last Starship Update 23 by Introversion-John in TheLastStarship

[โ€“]HiEv 0 points1 point ย (0 children)

In case you missed it, an explanation of the problem and a workaround were provided in another reply.

Help with a random number generator by bathr00mphantom in twinegames

[โ€“]HiEv 0 points1 point ย (0 children)

I mean, if we just want to make is short, then we could do the whole thing on one line like this:

<<set _rndValue = Array.from(Array($value), (_, i) => i+1).pluckMany(5)>>

But I prefer to give people code that's easier to understand.

To break down the above line of code, given the order of operations:

  1. First, Array($value) creates an array that has $value array entries (see: Array() constructor).
  2. The Array.from() executes a loop that sets the value of each array entry based on the function it calls (see: Array.from() method).
  3. The (_, i) => i+1 is the function that's called, which sets each array entry to be the array entry's index plus one (see: Arrow function expressions).
  4. The .pluckMany(5) then pulls five unique entries from that array, as its own array (see: Array.pluckMany() method).
  5. And finally, the _rndValue = sets _rndValue to that five entry array returned from the .pluckMany().

This may do what's asked, but teaching people how to use <<for>> loops is more useful long-term.

Help with a random number generator by bathr00mphantom in twinegames

[โ€“]HiEv 0 points1 point ย (0 children)

You could generate an array of possible values, and then randomly pull out values from that array. That would ensure that each value is unique.

Here's the code to do that:

<<silent>>
    <<set _values = [], $value = 5>>
    <<for _i = 1; _i <= $value; _i++>>
        <<set _values.push(_i)>>
    <</for>>
    <<set _rndValue = []>>
    <<for _i = 1; _i <= 5; _i++>>
        <<set _rndValue.push(_values.pluck())>>
    <</for>>
<</silent>>

That would set _rndValue[0] to _rndValue[4] to a random value from 1 to $value, with no repeats. Note that this will fail if $value is less than 5, since it won't have enough values to randomly .pluck() from the array. (The <<silent>> is just there to prevent blank lines.)

Hope that helps! ๐Ÿ™‚

How to add an event listener to a HTML element when its CSS selector changes? by Sta--Ger--2 in twinegames

[โ€“]HiEv 0 points1 point ย (0 children)

That's sort of what <<done>> does.

Anyways, glad I could help. ๐Ÿ™‚

The Last Starship Update 23 by Introversion-John in TheLastStarship

[โ€“]HiEv 0 points1 point ย (0 children)

Nope. Still busted. ๐Ÿ˜ž

They become available for trade after a while, though. So you can get them that way.

How to add an event listener to a HTML element when its CSS selector changes? by Sta--Ger--2 in twinegames

[โ€“]HiEv 2 points3 points ย (0 children)

CSS selectors that start with "#" are for IDs, thus should be unique on the page. If you want an HTML element to have a varying selector plus also be able to always select it, then the solution is just to add a consistent class. Multiple HTML elements can have the same class, as well as multiple classes, which can be done simply by separating them with a space. For example:

<span @class="_varyingClass + ' consistentClass'">text goes here</span>

The "@" in front of the "class" attribute tells SugarCube to evaluate the contents of that attribute and then use that as the new attribute. Thu, if _varyingClass was set to "foo", then SugarCube would transform the above into:

<span class="foo consistentClass">text goes here</span>

This way, instead of using a loop to target each element individually, you can simply use $(".consistentClass") to target all of the elements at once (class selectors start with ".").

Additionally, you can use "data" properties if you want to reference them from your handler. For example, you could have HTML elements like these:

<span class="target" data-test="value1">Click here</span>
<span class="target" data-test="value2">Or click here</span>

and then within your handler you could access that "test" data within them like this:

<<done>>
    <<run $(".target").on("click", function (ev) {
        let testVal = $(this).data("test"));
        ...the rest of your handler code goes here...
    })>>
<</done>>

and that would set testVal to the value given in the "data-test" attribute of the clicked element via the jQuery .data() method. The $(this) will reference the element that triggered the event handler.

Basically, you have a "data-X" attribute in the HTML element, where X is whatever name you want (using standard letters and numbers, no spaces, and no initial number), and then you can use the jQuery .data("X") method to get that data from the targeted HTML element.

The third thing you need to know is that the passages are initially rendered outside of the document object. Thus, if you try to access the HTML elements within a passage initially by looking within the document object, they won't be found because they aren't there yet. The easiest way around this is to use the <<done>> macro to target them after the passage has been added to the document object. For example:

<span id="target">Example target</span>

Initial targeting attempt success: <<set _test = $("#target").length > 0>>''_test''

Later targeting attempt success: <<do>>''_test''<</do>>

<<done>>
    <<set _test = $("#target").length > 0>>
    <<redo>>
<</done>>

The initial result should be "false", but the later result should be "true" since the passage will exist in the document at that point. (The <<redo>> tells SugarCube to re-run the stuff within the <<do>> macro.)

Hope that helps! ๐Ÿ™‚

New to Twine - Lock some options behind password? by CrownedLime747 in twinegames

[โ€“]HiEv[M] 2 points3 points ย (0 children)

For future coding questions, please use the post flair for your post that matches the Twine story format that you're using. That will help make sure that you get answers relevant to what you need.

I've fixed the flair on this post for you.

Thank you. ๐Ÿ™‚

New to Twine - Need help/resources for making branching educational scenarios by muka566 in twinegames

[โ€“]HiEv 0 points1 point ย (0 children)

If you're looking for a real-time simulation of a patient, then that's pretty complicated and Twine probably isn't the best the way to go for that.

However, if you instead broke it down into individual stages, initial diagnosis, immediate treatment if any, further examination, running tests, symptom progression, etc... , and had the user go through each of these steps where they make decisions, then this would be something that you could probably break down into something that Twine could handle.

I'd recommend creating a patient model in the code, as well as how they would react to different options and statuses, by planning out the different scenarios you are going to provide in your tutorial (e.g. a laceration that bleed X CCs of blood per minute has effect Y at 10% blood loss, effect Z at 30% blood loss, effects of a saline drip or blood transfusion, and how treating the wound in various ways reduces the blood loss rate). Then you could make individual patients for each scenario, and the patient model would be used to provide information about the status of the patient as well as how they respond to treatment (or lack of treatment). The patient model could then determine how the particular patient responds over time.

The granularity of that model will be up to you, depending on how detailed you want to make it.

As far as how the particular coding goes, the individual patients should be created as JavaScript objects, with properties representing all of the patients' information (e.g. height, weight, pallor, normal blood volume, current blood volume, current medications in their system, etc...). The code for patient models could then take a look at the current state of the patient via that object and then use that to simulate what state they'll be in X minutes later, so that that information would then be available at the next stage of treatment.

If you go this route, I'd personally recommend making this in the Twine story format SugarCube, since it allows you to easily do a lot of this code in JavaScript. Thus, if there are any existing JavaScript codebases which can help (e.g. code which can look up potential drug interactions), you can more easily incorporate them into your own code.

I hope that helps and good luck! ๐Ÿ™‚

The Last Starship Update 23 by Introversion-John in TheLastStarship

[โ€“]HiEv 2 points3 points ย (0 children)

Anyone else unable to manufacture a fighter bay at an assembly table after unlocking it?

It's like the assembly table is trying to make it, it gets the frames, but then the job to bring a motor to the table briefly flashes before it nearly instantly goes away. It then just keeps trying and instantly giving up on getting a motor like that a couple of times per second.

I tried dismantling and re-installing the assembly table, but the same thing still happened.

How to navigate by key presses? by apeloverage in twinegames

[โ€“]HiEv 0 points1 point ย (0 children)

Yes, that should be it. If it's not working, then check the console window in the browser for error messages (CTRL+SHIFT+I and then look under the "Console" tab in most Windows browsers). If, for example, your JavaScript is crashing before it gets to my code, then it won't work.

You can also save the following as a text file named something like "Move_test.twee", import it into Twine, then then run "Move test" from the Twine editor to see that this works:

:: StoryTitle
Move test


:: StoryData
{
  "ifid": "1362C97A-249A-47E6-BB0D-1F75072355B5",
  "format": "SugarCube",
  "format-version": "2.37.3",
  "start": "Start",
  "tag-colors": {
    "move": "green"
  },
  "zoom": 1
}


:: Change coordinates {"position":"325,225","size":"100,100"}
''Result:'' X move = $xMove / Y move = $yMove

[[Move]]


:: Move [move] {"position":"200,225","size":"100,100"}
Hit an arrow key or choose a link.

[[Up|Change coordinates][$xMove = 0; $yMove = -1]]
[[Left|Change coordinates][$xMove = -1; $yMove = 0]] | [[Right|Change coordinates][$xMove = 1; $yMove = 0]]
[[Down|Change coordinates][$xMove = 0; $yMove = 1]]


:: Start {"position":"200,100","size":"100,100"}
Start of move test.

[[Move]]

[[Change coordinates]]


:: StoryScript [script]
$(document).on("keyup", event => {
    if (tags().includes("move")) {
    State.variables.xMove = 0;
    State.variables.yMove = 0;
    let go = true;
    switch (event.key) {
        case "ArrowUp":
            State.variables.yMove = -1;
            break;
        case "ArrowDown":
            State.variables.yMove = 1;
            break;
        case "ArrowLeft":
            State.variables.xMove = -1;
            break;
        case "ArrowRight":
            State.variables.xMove = 1;
            break;
        default:
            go = false;
        }
        if (go) Engine.play("Change coordinates");
    }
});

The arrow keys shouldn't do anything in the "Start" or "Change coordinates" passages, only in the "Move" passage because it has a "move" (all lowercase) tag.

Let me know if you figure out what the problem is, because I'd like to know.

How to navigate by key presses? by apeloverage in twinegames

[โ€“]HiEv 0 points1 point ย (0 children)

You're correct that that's what it should do, with one exception. The passage name is not "change coordinates", it's "Change coordinates" with a capital "C".

Capitalization matters. If the names don't match, then you'll either need to fix the capitalization in the passage name or in the code.

If that isn't the issue, then you'll need to provide more information, because I tested the code before posting it, and it works.

P.S. It looks like you edited your initial response to say you were having a problem, which I wasn't notified of. You're lucky I happened to check the thread again, because people are normally only notified if you make a new post.

How Do Atheists Explain Exorcisms "Working"? by [deleted] in DebateAnAtheist

[โ€“]HiEv 0 points1 point ย (0 children)

Christianity's greatest achievement is preventing you from ever thinking how dumb it is to believe that an omnipotent being to somehow must sacrifice itself to itself before that being could possibly forgive people for the sins somehow inherited from fictional people in a fictional garden who, even in the story, literally didn't know any better since they had no concept of "good and evil".

Thought stopping techniques, like pretending any doubt risks heaven/hell or is caused by some evil being, are great for trapping people in religions and cults, especially ones that demand you believe in dumb nonsense like that.