Skip to content

Major dialogueSys.js Update 1.3.20f

Compare
Choose a tag to compare
@CalmBubbles CalmBubbles released this 23 May 08:03
· 44 commits to main since this release
707f228

Change Log

  • remade the typeOnBox system
  • line break prediction (kinda)
  • text style can now be changed

s1

Code:

// variables are assigned the same way
// as css style attributes
// 
// dialogueSys.textColor = color
// dialogueSys.textBg = background
// dialogueSys.textStyle = font-style
// dialogueSys.textWeight = font-weight

diaSys.clearBox();

diaSys.typeOnBox("You can now use ", 1, "claire", "Happy", () => { diaSys.textColor = "yellow"; });
diaSys.typeOnBox("color, ", 1, "claire", "Happy", () => { diaSys.textColor = "#f0f0f0"; diaSys.textBg = "linear-gradient(red, orange, yellow, green, blue, indigo, violet)"; });
diaSys.typeOnBox("background", 1, "claire", "Happy", () => { diaSys.textColor = "inherit"; diaSys.textBg = "none"; diaSys.textStyle = "italic"; });
diaSys.typeOnBox(", style ", 1, "claire", "Happy", () => { diaSys.textStyle = "normal";});
diaSys.typeOnBox("and ", 1, "claire", "Happy", () => { diaSys.textWeight = "1000"; });
diaSys.typeOnBox("weight " , 1, "claire", "Happy", () => { diaSys.textWeight = "normal"; });
diaSys.typeOnBox("in text.", 1, "claire", "Happy");
  • text characters can now be manipulated individually

s2

Code:

// Every text characters are in a span which can be
// manipulated
// 
// The element has an id of `dialogueSysChar_${charIndex}`
// charIndex defines a count of characters from start to end
// charIndex starts counting from 0
// 
// The element can be simply get by using
// document.querySelector

diaSys.typeOnBox("Welcome to ", 1, "claire", "Happy", () => { diaSys.textColor = "red"; });
diaSys.typeOnBox("Hell", 1, "claire", "Happy", () => {
    
    // Magik starts here
    
    // We set an array of the elements/chars we will use
    var chars = [
        document.querySelector("#dialogueSysChar_11"),
        document.querySelector("#dialogueSysChar_12"),
        document.querySelector("#dialogueSysChar_13"),
        document.querySelector("#dialogueSysChar_14")
    ];
    
    // For each variable in chars
    for (let i = 0; i < chars.length; i++)
    {
        // We need to set the display to inline-block
        // because inline element cannot be animated
        chars[i].style.display = "inline-block";
        
        // Add the animation
        chars[i].style.animation = `shake${i} 0.12s infinite`;
    }
});
  • functions now ONLY run when another function from the same object is not active (this means functions are now queued(example can be seen on previous examples))
  • less horror code (usually spaghetti code)

Before:
Screenshot_2022_0523_152451

After:
Screenshot_2022_0523_152525

Credits