C.Fighter's Textbox Library

C.Fighter's Textbox Library v1

What permissions do you give others to modify and/or maintain your submission?
Modify: YES - Maintain: YES - I give permission for my entire submission to be modified by others or used in their own work. I give permission for my entire submission to be maintained by others as well.
I made sure my file(s) follow the Submissions Guidelines
  1. Yes
Remember Ashi's Dialog System?
Yeah, that inspired me to create my own.

LIBW.png

What is this?
In short, another asset for dialog box creation. Thank Ashi for the inspiration lol.

I'll let the gifs speak for themselves.
srb20098.gif
srb20100.gif


I've also included a test script with both textboxes shown. Press Custom 1 to summon the one on the left, and Custom 2 to summon the one on the right.
NOTICE: Load the example AFTER loading the library.

And of course...
The format of a textbox is a bit complicated, so I hope you can follow along through the process.
The code:
-- BOX TREE STRUCTURE
-- First, we must create what I'll call from now on a "box tree".
local boxtree = {
    [1] = { -- The first box in the tree. The textbox numbering always starts at 1, and the textbox will always initialize to 1.
        name = "Someone", -- The name of the speaker. Can be omitted.
        portrait = {"sonic", SPR2_WAIT, A, 8}, -- The "portrait". Basically, this shows who is speaking just above the textbox.
        -- Uses in-game sprites as a basis: skin, spr2, frame, angle. Can be omitted.
        color = SKINCOLOR_BLACK, -- The color to use for the portrait. Has to be supplied with the portrait.
        text = "Is anyone there?", -- The text to print into the box. Puts the "text" in "textbox".
        sound = sfx_talks, -- Optional. The sound to play for every letter printed.
        delay = 3*TICRATE, -- The time to wait for to automatically advance the textbox. Required for non-movement-locked textboxes, otherwise optional.
        mini = { -- Mini-text, similar to Deltarune. Yes.
            {portrait = {"sonic", A}, color = SKINCOLOR_BLUE, text = "WHO are you?", pos = "dl"}, -- Portrait (has to use the TBXM sprite, no angles), color, text, position.
            {portrait = {"tails", A}, color = SKINCOLOR_ORANGE, text = "Doesn't matter, Sonic!", pos = "dr"} -- You can have multiple.
        },
        script = function(player) -- This runs once the textbox is displayed. Can be used to lock the player out of activating the box again.
            -- Yeah you can put whatever code you want. Lol.
        end,
        next = 2 -- The ID of the next textbox. Set to 0 to close the textbox once the box is skipped.
    },

    [2] = {
        -- The same format applies to the other boxes.
    },
 
    -- CHOICES
    [3] = {
        -- You can have someone speaking with the choice if you want.
        choices = { -- This defines what you can choose.
            {text = "Um...", box = 4, pos = "left"}, -- The option itself, then the box ID it takes you to, then the relative position.
            {text = "Do I know you?", box = 5, pos = "right"} -- Try to position these so that scrolling L->R makes sense. Order does metter here.
        }
    },
 
    -- ...
}

-- FUNCTIONS
-- Now that you have the table ready, we can summon it by calling THIS function:
CFTextBoxes:DisplayBox(player, boxtree, move)
-- "player" determines the player it's shown for. If it's nil, the textbox is displayed globally.
-- "boxtree" is the box tree that the textbox will use. Of course.
-- "move" determines whether the player can move during the textbox. False or nil means movement lock, true means no movement lock.

-- If you want to close it prematurely: call
CFTextBoxes:CloseBox(player)

-- And for a premature push to the next box:
CFTextBoxes.Advance(player)
-- Note that this one has a dot instead of a colon. Remember that!
There's also a special type of escape sequence I specifically created for this purpose - "bar commands"! Basically a bar (|) followed by a three-letter identifier and the vars if necessary:
  • |delxy - Set delay between characters drawn, including spaces. Default is |del11 - 1 char per 1 tic. Base 10. Both MUST be nonzero, will be set to 1 if found as 0.
    • x: how many characters to draw per tic
    • y: how many tics to wait until the next char
  • |paunn - Pause for nn tics. This pauses AFTER drawing the next character. Base 10. MUST be nonzero, will be set to 1 if found as 0.
  • |shkn - Shake text. 1 - light, 2 - medium, 3 - intense
  • |wav - Wavy text
  • |rst - Reset
  • |esc\xFF - Parse escape sequence. Required (and recommended to be used ONLY) for colors.
Controls:
  • Jump - advances the textbox, selects the chosen option if there is a choice. Speeds up text.
  • Spin - renders the whole text instantly
  • Strafe Left/Right - moves the cursor if there is a choice.
Have fun.
Author
CloneFighter
Downloads
1,013
Views
4,872
First release
Last update

More resources from CloneFighter

Share this resource

Latest reviews

A very nice and flexible library, I find it very useful.
Only things I wish for were more easy usage of arbitrary graphics, and for my suggested bugfix regarding non-green resolutions to be implemented.
Upvote 0
I don't know how to make it trigger.
Upvote 0
This is an awesome release, even when people are making a level pack. They can used this addon for in need of hand, All though your addon is fine. But it might have some bugs, overall. This ain't bad addon, Welcome to releases! (it was late all though, my bad)
Upvote 0
Back
Top