[Open Assets] Simple Dialogue System

This content may be freely modified and/or maintained by anyone.
Status
Not open for further replies.

Joat

Gum Phoenix
This is a simple dialogue system for SRB2. The top box shows the text being spoken to the player, while the bottom box has up to four options they may choose from for a response. A chosen response may result in further conversation, ending the conversation, or a function being executed.

Included in the LUA script is the dialogueTest function (and a call to it using the MapLoad hook), which describes, in comments, how to properly format the dialogue. I do hope I made things sufficiently clear in the comments, but I shall be the first to admit that I am a rather lousy teacher, so if anything is unclear, please tell me and I shall make adjustments to rectify that.

As a side-note, also included are the dialogue box graphics shown in the image (which, to give credit, are created from the BRDR graphics in srb2.srb), which is why this is in the form of a .wad file, rather than simply a .lua one.

As a final note, though, I shall point out that this script should be used very carefully. As the wiki points out, "Sonic the Hedgehog, SRB2 included, is about flow", and inserting dialogue into a level is a good way to stop that flow dead in its tracks.
 

Attachments

  • srb20008.png
    srb20008.png
    5.6 KB · Views: 2,160
  • dialogue.zip
    6.3 KB · Views: 672
Last edited:
Welcome to releases!
 
The script is actually a good idea, but I would like to point out that calling hud.add in a MapLoad hook is a very bad idea, as it'll create a new HUD function everytime you reload the map. Which means if you load the map ten times, it'll display the exact same thing ten times when only one is needed. It's visually invisible to the player, as the dialogue will just override the one that was just drawn, but it'll result in the framerate dropping more and more each time you reload the map. I recommend calling hud.add only once and changing its behavior depending on the map or something similar.
 
Last edited:
Apparently, the solution was to just have the hud.add outside of any function or hook, simply running as soon as the script is loaded, before the gameplay officially starts. I did not call that. In any case, I have uploaded a corrected file.

On another note, I have also made it so that the "you have selected a different item, good job, give yourself a gold star" beep does not occur if there is only one item to choose from.
 
Code:
//To handle input and stop the player from moving around when selecting an option.
addHook("ThinkFrame", do
    for p in players.iterate()
        //Handle if dialogue is currently open.
        if p.conversation != nil then
            //Stop the character from moving.
            p.normalspeed = 0
            p.jumpfactor = 0
            p.charability = 0
            p.charability2 = 0
            dialogueHandler(p)
        //Otherwise, set speed, jump height, and abilities back to normal. For this reason, this script does not play nice, by default, with anything that alters any of these.
        else
            p.normalspeed = skins[p.mo.skin].normalspeed
            p.jumpfactor = skins[p.mo.skin].jumpfactor
            p.charability = skins[p.mo.skin].ability
            p.charability2 = skins[p.mo.skin].ability2
        end
        p.oldButtons = p.cmd.buttons //Keep the oldbuttons variable up to date.
        p.oldForwardMove = p.cmd.forwardmove //Keep oldForwardMove up to date.
    end
end)
This is a pretty huge bump, but I had just thought of this, and figured it was worth bringing up. Wouldn't a fairly simple fix to this be to save the player's stats to variables (or a table, if you want to be fancy) before overwriting them, then, when the menu is closed, replace the player's stats with the ones saved from before? The only possible problem with that solution that I could think of is if Speed Shoes directly modify the player's stats in order to achieve their effect, and that probably wouldn't be too difficult to find workarounds for (You could check and see if the player has speed shoes when saving the variables and adjust accordingly, that would probably work.).

In any case, if anyone is looking to implement this into something and wants to also provide support for scripts that modify the player's stats, this is something to keep in mind.
 
I just like how this lua deeply reminds me of Strife's dialogue, perhaps the idea was from there so that's why I see it in Zandronum and here now.
 
Good heavens, it's been a long time since I showed signs of life here! These changes are long overdue.

I have changed the script in accordance to LunarDestroyer's advice. I have also added in the capacity to have more than four response options.

EDIT: I almost forgot to mention. Speed shoes do not modify p.normalspeed.
 
I like all the outcomes of the inputs! Keep it up!��
 
I said something about an error but just nvm this, nice wad also
 
Last edited:
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top