Most efficient branching dialogue system

Discussion in 'Programming' started by Buginjar, Mar 11, 2019.

  1. Buginjar

    Buginjar Member

    Joined:
    Mar 11, 2019
    Posts:
    6
    Hello, I am extremely new to programming and game making so I'd like to get some advice before i officially start working with game maker 2. My goal is over the next couple years to make a game primarily based around a fairly complex branching dialogue/branching narrative system. Theres going to be a smallish interactive town with 50 or so characters, each with 10-30 conversations, all with many branching dialogue trees. It's also going to feature a huge amount of long winded text for all of the branches.

    I started making this in rpg maker but recently abandoned that project as rpg maker is too limiting for me. Unfortunately I was spoiled by how utterly simple it is to build branching dialogue trees in that program.

    So I have a few questions. The first is is it wise to even attempt this project in game maker studio 2? Or would I be better off using a different program/learning more complex coding myself and just building this in C++ or something?

    Second is if this could work in game maker what is the most efficient way to code all this?

    A few other things, I know basically nothing about coding. I am willing to put in whatever time I need to understand any tutorial you guys can post, i just wanted to get some advice before I really dived into learning how to do this.

    And one other thing is my game is not going to have any sort of combat system. It will be more in the style of a visual novel, but with a town you can walk around in and time progression. So any space that would have been taken up by that will also be going to more dialogue and branches.

    Any advice is appreciated thanks!
     
    Last edited: Mar 11, 2019
  2. SoVes

    SoVes Member

    Joined:
    May 17, 2017
    Posts:
    108
    I'd recommend looking into json files. They should do you fine with dialogue branches
     
  3. Buginjar

    Buginjar Member

    Joined:
    Mar 11, 2019
    Posts:
    6
    Just to be clear, would I need to create the json files in a different program? I dont know how to use javascript but this seems like a good solution since it seems difficult to do in the standard game maker code. Thanks a lot for your reply.

    Sorry if this is an obvious question but like I said I am extremely new at this.
     
  4. SoVes

    SoVes Member

    Joined:
    May 17, 2017
    Posts:
    108
    You can do it completely in gamemaker. There are great tutorials if look for them.
     
  5. Buginjar

    Buginjar Member

    Joined:
    Mar 11, 2019
    Posts:
    6
    Thank you again for your reply. Actually, I found another program called inky which let's you write choose your own adventure style branching text and export it as a json file. Now I am trying to figure out how to use the exported json files in game maker. I am having a lot of trouble understanding exactly what I'm supposed to do.

    I uploaded a couple json files to my included files section on the database, but whenever I try to do anything with it with code I get the same error.

    It always tells me "variable the name of the object the code is attached to not set before reading it". But just what am I supposed to set it to? I've tried making it a variable or a string, and all sorts of other things but I always get slight variations of that exact same error message. I always tie it to the json_decode(myjsonfilename) command. I know it's not the program I'm exporting the json files from cause I've tried this on another imported json I just made in notepad and got the exact same error.
     
  6. Danei

    Danei Member

    Joined:
    Mar 23, 2018
    Posts:
    207
    How are you accessing the data in the files? I think the standard thing to do would be something like
    Code:
    jsonFile = file_text_open_read("filename_including_extension.txt");
    
    readString = "";
    
    while !file_text_eof(jsonFile){
    readString += file_text_read_string(jsonFile);
    file_text_readln(jsonFile);
    }
    
    jsonMap = json_decode(readString);
    
    file_text_close(jsonFile);
    
    Included files still need to be handled just like any other external file, the IDE can't automatically read what's in them.
     
  7. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    301
    It's Inkle, not Inky :)
     
  8. Buginjar

    Buginjar Member

    Joined:
    Mar 11, 2019
    Posts:
    6
    Thank you for your reply. I've tried using the code you wrote but unfortunately i cant get it to do anything. I'm using drag and drop mainly but I've tried it in the game maker coding layout as well. The only difference is in the coding layout for some reason the sprite always disappears after I input your code. I have no idea why.

    I've tried using several different json files I made in different programs so I dont think it's a problem with the files. I've tried creating it as a draw event, create event, key press event as well as splitting it between create and draw. I also checked that simpler text commands were working. What else am I supposed to do to use these files? I am feeling really stumped.

    Actually, Inkle was shut down in 2018 and replaced with a program called Inky.
     
  9. Danei

    Danei Member

    Joined:
    Mar 23, 2018
    Posts:
    207
    Are you familiar with the use of ds_maps and other data structures? My code ought to be creating a ds_map that contains the information in the JSON. I'm completely unfamiliar with drag-and-drop, so I don't know what the interface for data structures looks like in it, or if there even is one, but if you aren't utilizing the ds_map, you'll basically need to read up on data structures before you can use JSON for much of anything inside gamemaker.

    If you are utilizing the ds_map already please post or screenshot the code you're using for that.
     
  10. Buginjar

    Buginjar Member

    Joined:
    Mar 11, 2019
    Posts:
    6
    Thank you for clarifying I didn't really understand that at first. Also I'll just use gml instead of drag and drop for now.

    Anyways I've read up on ds maps but I'm still having issues. "jsonMap" is supposed to be the name of the ds map containing the json file correct? I'm finding myself unable to interact with in it any way as a ds map.

    I've tried using a number of commands, most of them I'm probably not using right anyways since I have no idea what the key is. I understand how you'd set one if you were writing a ds map in gml but I don't understand how to set it for an external file. Would I have to set it in the original program where I wrote the json file?

    Anyways the bigger issue is that anything I try to do with jsonMap makes my game crash. Commands like ds_map_find_first or ds_map_write where I dont need a key give me the same result. I always get basically the same error that says "Variable object1.jsonMap(100004, -2147483648) not set before reading it."

    Is there something else i need to do to set the json as a ds map that I'm skipping?
     
  11. Danei

    Danei Member

    Joined:
    Mar 23, 2018
    Posts:
    207
    Hmm, it sounds like the map isn't being made properly. I know my code works in general because I copied it straight out of a project that relies on it, and just changed the file name string, so double check and make sure the string you're using matches your file name exactly, including extension, and that you're interacting with it from the same object you're creating it in.

    If that's all true, right after
    Code:
    jsonMap = json_decode(readString);
    try putting
    Code:
    show_debug_message(string(ds_exists(jsonMap, ds_type_map)));
    This should output 1 if the map has been properly created, and 0 if not. That will help narrow down where the problem is.
     
  12. Buginjar

    Buginjar Member

    Joined:
    Mar 11, 2019
    Posts:
    6
    Oh, yep, whoops I was trying to interact with the ds map from a different object. I didn't realize that would be a problem.

    However, the json files I exported from inky are uh, not what I had in mind. I can access words from the file but none if the actual dialogue I typed. It seems even more complicated than just writing the files in gml.

    Inky has a plug in for unity though I'm just gonna try switching over to that. Thanks a lot for your help though you probably saved me weeks of wasted effort.
     
  13. Danei

    Danei Member

    Joined:
    Mar 23, 2018
    Posts:
    207
    It's actually not a problem at all, it's entirely trivial -- you can use instance_id.variable "dot notation" to access variables in other instances. I was just trying to keep things as simple as possible and not introduce a new factor.

    I don't know how Inky works, but it could just be that the actual text is wrapped down inside several levels of JSON structure. The whole point of JSON really is that you can nest maps inside maps inside lists inside maps etc. You need to pry open the JSON like a delicious chocolate egg that contains other chocolate eggs, one layer at a time, with care and patience.

    If you want you can post a snippet of the JSON file and I can tell you what the structure is, or maybe just go with unity if you find it easier to work with.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice