I have a ModuleScript where I store variables to use for my Dialogues. I have many many Dialogues, after finishing structuring everything I ended up with 11k+ lines.
I was wondering if 11k+ lines in one script is too much, let me hear you out
I have a ModuleScript where I store variables to use for my Dialogues. I have many many Dialogues, after finishing structuring everything I ended up with 11k+ lines.
I was wondering if 11k+ lines in one script is too much, let me hear you out
Modules are there to split up your code, so that you can more easily find issues and scroll through it. Now you’ll have to scroll through thousands upon thousands of unrelated lines to find whatever you want to change, lol.
it’s not unrelated lines, and it’s a huge nests of tables where i store values and different sets of dialogues
Yea I’d probably break them down into lots of different modules organising the dialogue into difference categories, and then having one main module that can act to retrieve the data. Are these 11k lines repetitive?
Oh, well it’s all up to you … but I’d seperate it into things like,
Answers
Questions
Statements
Quests
etc
you mean in separate modulescripts?
all lines and values are necessary for my code.
could you send like a small snippet of it
if you say so
i cannot upload the entire code since it’s extremely long
That’s why ModuleScripts are so useful, you can put the Sets in a ModuleScript like this:
-- ModuleScript
return {
["somevalue"] = 420
}
-- Main script
local Set1 = require(script.Module)
print(Set1.somevalue)
the only problem is the horrendously large amount of lines, which causes studio to lag just by scrolling or typing.
i was thinking about separating each set in different modules
Good idea, that’s the whole point of modules. For example, you can add Set1, Set2 and Set3 as ModuleScript under Dialogues. Then in Dialogues:
local Dialogues = {}
Dialogues = {
["Set1"] = require(script.Set1),
-- ...
}
i see. thank you and everyone for your help!
You could make one singular function to make the dialogue, with like the NPC name,image and a table containing all of its speech. That would shorten your script.
Also, complex scripts are just very long, so there’s no problem, but debugging would be a challenging task.
Even better, don’t want to change Anything besides the tables themselves, but still want to split them up? set “someValue” inside that moduleScript to be a value returned from yet another moduleScript.
Like so:
-- Module 1
local Mod1={}
local OtherValues={}
OtherValues.Mod2=require(script.Mod2)
OtherValues.Mod3=require(script.Mod3)
Mod1.Table={
X=OtherValues.Mod2.ValueOfX
Y=OtherValues.Mod3.ValueOfY
}
return Mod1
-- Module 2
local Mod2={}
Mod2.ValueOfX=420
return Mod2
-- Module 3
local Mod3={}
Mod3.ValueOfX=1337
return Mod3
this way you can make the table have the values themselves, not a reference to another table (which is a module) which then will have the values.
very subtle difference, but still works the same as just having the table be there, so it’s really something else.
local Dialogues = {}
Dialogues = {
["Set1"] = require(script.Set1).Set,
-- ...
}
You could even make all values inside “Set1” be inside the “Dialogues” table, instead of separated, by having a script iterate through it all and reorganize it on launch, which is very inexpensive (almost 20k lines of very nested tables get done in less than a tick) and i use this method (and others) with not a single bit of performance difference.
all the convenience of organized data for the programmer, none of the hassle of having the Scripts go through organization, you can un-organize it again on purpose to make it more acessible for scripts.
That’s how i’ve fixed my lag problem in big scripts, the biggest of which would be around 15k lines (and that’s after trimming it down by another 10k with other methods, like replacing repeating data with an ID for that data from another table, that alone got 8k lines, and that’s 8k lines from someone who likes to make their scripts >very< compact)
I don’t think it would be bad. If you are fine with it then keep going. I would say to make a few comments on top like a content area where it tells you that x is located and line y.
Though, I am sure that using more module would be worse as it would take more space.
Also some stupid thing you can do is store the text in an external database and then import it using httpservice LOL
i’m not talking about functions, i was talking about a huge tree of tables with lots of values. but yeah i already have all of those prepared
i agree, but since i have a weak laptop i can already feel the lag just scrolling through 11 thousand lines, and the screen would just freeze for a second just by expanding a table.
Whatttttt? No! I had like the worst laptop ever (a core i3 5th gen with 6 gb ram and no graphics ) and there wasn’t much lag.
Or see my third suggestion of using httpservice!
maybe it’s because your script doesn’t have THAT much lines as i do.