Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

331
Vistas
How to make the JavaScript in Twine 2 work the way that I want it to?

Well, you see here I am trying to make this:

Config.saves.slots = 16;

Config.saves.onSave = function (save, details) {
    switch (details.type) {
        case 'slot':
            // code to post-process the save object from slot saves
            break;
        case 'disk':
            // code to post-process the save object from disk saves
            break;
        case 'serialize':
            // code to post-process the save object from serialize saves
            break;
        case 'autosave':
            // code to post-process the save object from autosaves
            break;
    }
};

var parts = document.getElementById("parts");
var part = parts.getElementsByClassName("part");

var chapter = document.getElementsByClassName("chapter");
var nOCPP = 966;
var nOC = 46368;

const starterChapters = new Array();
for (var seli=0; seli < chapter.length; seli++) {
    function tftgdedd(num) {
        starterChapters[num] = chapter[num].innerHTML;
    }
    tftgdedd(seli);
}

for (var seli=0; seli < part.length; seli++) {
    function tftgdedd(num) {
        part[num].addEventListener("click", function() {
            for (var sli=0; sli < chapter.length; sli++) {
                chapter[sli].innerHTML = parseFloat(starterChapters[sli]) + (nOCPP*num);
            }
        });
    }
    tftgdedd(seli);
}

for (var seli=0; seli < chapter.length; seli++) {
    function tftgdedd(num) {
        chapter[num].addEventListener("click", function() {
            // Stuff to make it so that you can travel to the content of the selected chapter, there is 46368 chapters, there is 966 chapter select buttons
        });
    }
    tftgdedd(seli);
}

Work the way that it does in normal JavaScript. It really will suck if I can't find a way to make this work, after all, if it can't work the way that I want then I will have to completely scrape the story, as I have over 58.68 billion words typed out that make up the entire story, it is too much to give up on, and if I can't get Twine 2 to work the way that I need it to then I am going to need to make the entire thing over without using a game engine, it is probably easier to find a way to make Twine 2 to work than taking the next year reprogramming the story.

I should say that I am using SugarCube v2.34.1

The Problem:

Well, when I click the test button this alert message pops up:

twinery.org says

Apologies! An error has occurred. You may be able to continue, but some parts may not work properly.

Error [tw-user-script-0]: Cannot read properties of null (reading 'getElementsByClassName').

I would like to make it so that getElementsByClassName works the way it should, also I want all normal JavaScript to be able to be used in twine 2.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda