Is 11588 lines way too much?

…Why did I read the title as 115888 lines? I was about to say that your fingers must be broken, and that it’s a miracle that you were even able to make this post. (Joke, but I can’t talk anyway, because I’m sure I’ve typed way more than that in total in my lifetime.)

Anyway, there’s never a certain number of lines that’s “too much”. How many lines are needed are how many lines are needed. You can organize your code however you want to, but I personally think that putting that many lines into a single ModuleScript is bad practice and unorganized, something that ModuleScripts are meant to prevent.

I suggest putting some of your lines into other ModuleScripts, or if possible, make a flexible function.

1 Like

In summary, if I were in your situation I would format your different parts of the dialogue into different modules scripts, which I’m guessing will be chronologically sorted, with a main module script that combines those together, so you have a sort of directory. (I would even make the referenced modules reference even smaller modules so that you can access them even easier.) I’m thinking this would decrease lag a ton, and save you a ton of time. Reading 11588 lines of code isn’t really even a module anymore. Chapters of a book were made for a reason. Good luck with your game! :happy2:

1 Like

If you want to show me the code maybe i can help reduce it’s size? i don’t think devforum can handle the size, but you could use Pastebin to share it.

1 Like

it is defo waaaaay too long, use module scripts and functions to lower the need of repeating your code.

1 Like

i am already using modulescripts and its not about functions since the modulescript is all data and values for a single dialog npc

1 Like

if you want i can send a file with the modulescript (taking screenshots would take too long) after school

yes that’s not too much it is actually too little. MAKE MORE LINESO F CODEDE!

1 Like

Did you scan in a book for your NPC to read? This is unbelievable. If a novel had 10 words per line and the same number of lines as your script, it would be 115,880 words.

Some stats:
100,000 words is 200 pages single-spaced or 400 pages double-spaced . Typical documents that are 100,000 words or more include full-length novels.

1 Like

not sure what you mean there (i only have 3 braincells left)

I’m telling you that 11,500 lines is enough to make a 200 - 400 page book.

1 Like

And this is why I code Java.

1 Like

then my entire modulescript with 11k lines is the npc’s vocabulary

No need to send files or anything, Pastebin is a website made for sharing large amounts of text, just paste the entire moduleScript there and send the link here.

alright i will do later. im still at school

1 Like

im back, here’s the full code

i was thinking about separating the SideChoices and SideDialogues to another ModuleScript (you can see in the pastebin) since it’s probably the reason the lines are so long

You seem to be keeping about 20 dialogs, even when only like 3 or 5 are used. You could probably get rid of 80% of the entire script by just removing the unnecessary lines.

Rather than have “Dialogue1, Dialogue2, Dialogue3…” just have a single “Dialogue” array that has all the dialogue in it. That way, you can also get rid of “AmountOfDialogues” by just checking the length of the array.

1 Like

you have a point. i’ll try this out, thanks alot!

UPDATE: i’ve managed to shorten it down to 2329 lines. thanks for everyone’s help!
@savio14562 you were right about getting rid of 80% unnecessary lines haha

1 Like

after taking a look at the pastebin, was there any reason why the empty dialogues were being kept there?

you don’t need empty keys if they’re empty, if they’re all the same, then when any script would try to get them you could just treat them as

if dialogueValue==nil then dialogueValue="" end

that is, if you even need the empty keys, which you probably don’t, so they not existing at all would be even better.

i understand that it’s all empty ATM, but it honestly shouldn’t exist if it doesn’t exist yet.


Here’s the i’d do it, it’s very efficient, clean, and best of all, modular and reusable, you don’t need to nest things, just reference them by their ID.

i wrote lots of different usages and scenarios in the --comments, if you can understand the general idea you’ll be good to go.


local DialogueTable={

	Character_1={ -- this is entirely optional, just for organizing things for different characters
                -- you'd be better off without it if you want different characters to use the same dialogue
                -- but it can even be by a script on game start, i do with lots of tables
                -- just loop through the primary "unwanted" tables and place all their contents inside the main one you're looping through, and then delete the now empty 'Character_1' entry
                -- as long as you don't create two values in two different 'Character tables' with the same ID, you'll be good, so it's always good to have the "replacing" function check if the key is duplicate and warn you so you can fix it
              

		DIA_A0={
			Texts={ "This is the main text" },
			Choices={ "DIA_A1","DIA_A2", },
		},

		DIA_A1={
			Texts={ "Second Choice", },
			Choices={}, --if #lenght of Choices table is 0, you can make it automatically treat it as and 'End Dialogue' without creating an specific dialogue for ending it
		},

		DIA_A2={
			Texts={ "hey, this is the first text?", "this is the second text", "and third, lol", }, --the order of texts is the order in which they're placed inside the ARRAY
			--but if you make it a dictionary (giving it a key, instead of just throwing it inside a table) then it's order is random, so it only works like this
			Choices={ "DIA_A2a","DIA_A2b","DIA_A2c", },
			--same principle of order, here you'd place the ID of the new dialogue which would be inside Character_1's table, no need to nest things
			-- +they can (and should) be reused by other dialogues
		},

		DIA_A2a={
			Texts={"generic text"},
			Choices={"DIA_A2a2"}, --you can nest tables even further without creating indents in the code
		},

		DIA_A2a2={
			Texts={"generic text again"}, 
			Choices={"DIA_A2b"}, --DIA_A2b is mentioned both as a choice for DIA_A2 and DIA_A2a2, you can have dialogue trees without being restrained by nesting everything
		},

		DIA_A2b={
			Texts={"this is being used by two different dialogues, without having to write it twice"},
			Choices={"DIA_A0"}, --and you can even create dialogue loops, want to go back to the first dialogue like games usually do? you can
		},

		DIA_A2c={
			Texts={"i'm out of text ideas"},
			--the 'Choices' Table doesn't exist, that also can both save you Lines of code, and be automated to be treated as if it was an empty table, like i explained above
			--after all, and empty table is the same as no table at all, it just takes less space
		},

	},

}
1 Like