https://github.com/kilpyfr/Roblox/tree/main/Combat Stuff i want to know how i could scale this and just overall make it better
#how could i improve my code
1 messages · Page 1 of 1 (latest)
wdym having constants
make more things
I need to perfect one before I move on
no you dont
physically impossible to perfect it before moving on because later on you might need it to do things you didn't originally plan on needing it to do; meaning you may need to throw it out and start again to get it to do what you wanted. meaning all that time you spent perfecting and optimizing it? wasted.
s1 is expected to know this
Technical Ranking Guidelines
[Scripter 1 - Beginner] Key Expectation: Novel problem solving with intent
What this looks like in a script:
- The script is not prematurely optimized: https://www.youtube.com/watch?v=tKbV6BpH-C8
When should you optimize your code?
Access to code examples, deleted scenes, song names and more at https://www.patreon.com/codeaesthetic
what really matters here is that whenever you need to do this, re-write modules to add behavior, you have originally made it so that you don't need to change anything else that depended on the module, only the module itself. this is what decoupling and abstraction is supposed to be for. s2's are expected to know this
[Scripter 2 - Intermediate] Key Expectation: Novel problem solving at scale with intent
Meaning:
In addition to the scaling problem, you, or another scripter, often may need to go back to your scripts at a later time to fix a problem ("Maintainability"), change or add new behavior ("Robustness"), or produce new content with it ("Versatility"), so it is a major priority for marketplace employers that their codebase stays clean, organized, and manageable as its scale increases so that any person or team working with your scripts, yourself a year from now included, are able to look upon your work and understand what it is doing in order to build upon it with minimal time and effort; this is the problem of collaboration.
What this looks like in a script:
- The script shows decoupling and independence, separating implementation details away from its inputs and outputs, also known as Abstraction: https://www.youtube.com/watch?v=L1-zCdrx8Lk
Get "Ultimate bGuide to Software Freelancing" - a FREE roadmap for a very, very lucrative career. CLICK HERE: https://iamdev.net/free
Really simple - abstraction is hiding stuff!
you won't be s1 until you learn that optimization and performance don't matter as much as you, and so so many other s0's think it does. learning this is the best way to improve your code.
coz if i can look at your code and say "this section sucks but all i have to do is change the body of the function and nothing else" it is excellent code 👌
So that's decoupling?
pretty much
the inputs and outputs are 'decoupled' from the implementation
idc abt s1 bro
whennnn did i mention optimization gng
i asked how i could improve my code
and youre edgiiing it
i already watched this smh
trust me i did my research
im already above s1 wdym
im like high s1
im tryna get low-mid s2
that was your first question
which I answered
right here
what else would "perfect one before I move on" mean?
y'know, the second question you asked right here
organization, abstraction, just general format of the code
Which I also answered
right here
and here
and here
but really the best thing you can do is what i suggested the first time
gaslighting is not necessary when i've already answered your question
how am i gaslighting???
atp just make more stuff.
that's the best way to improve.
it's really not that deep.
it really, really is that simple.
i just want to know if my general format is fine
i dont think im asking for much
it's fine
ya you didn't ask for much and i gave you a lot, perhaps too much
sure but you still didnt give me what i wanted
which is mainly what i care about
i dont think im prematurely optimizing cuz im asking for organization advice, not optimization advice
you're trying to optimize your organization
and i'm saying dont bother; just roll with what you have
it may not be the answer you wanted, but it is the correct answer
so everywhere i turn is a dead end
wat
im trying to scale so its easier to add more stuff
cuz i plan on adding more to this system
yeah, you're doing it backwards
add more stuff first and then scale it
not the other way around, that is premature optimization
oh so i add something, see what made it difficult, and then fix it?
now you're getting it!
it's impossible to know in advance how flexible you need your systems to be .. until you actually use your system to do those flexible things
what if im just trying to makle it more readable though
coz you can plan all you like, it won't matter when it comes to actually making the things you want to make
9 times out of 10 you'll hit something that you weren't expecting. you simply cannot account for that short of just making stuff, finding all those boundaries, scale up, and keep going. rinse repeat
that's just practice over time
abstraction helps though right
the more stuff you create, the more accustomed to making stuff you'll be, and the more consistent your code will become because you simply know the patterns you're using better, which will in turn make it more readable because your code is more consistent
abstraction is a tool
you need it to make systems flexible
and do more stuff
isnt that the job of decoupling
isnt abstraction hiding functionality and decoupling making it more usable to more situations
or is abstraction more than that
how to put it simply
"do more with less"
i.e every time you go to use an animation you usually don't care how it is loaded or anything, so you abstract away those responsibilities to some abstraction layer that handles loading and playing back animations
then wherever you need an animation you call into that abstraction since you only care about actually playing an animation at that point, how it gets loaded or where the id comes from is irrelevant
coupling is the specific functions and interfaces you depend on
the specific kinds of inputs the abstraction needs
there is always some coupling
i.e animationsystem:PlayAnimation(name_or_id)
your system could take a named animation, or it could take a flat id, or maybe it can take both!
could it take an object?
but the :PlayAnimation() function is a dependency now - the function must always have that name and do exactly that job, you can't change it because anything that depends on it must also change. this is coupling.
and this is why abstraction so good. if you later decide you want to pass in animation objects directly, you can do that without changing anything else coupled to it
but wouldnt you have to go to all scriptss using it and change the id to an object?
make your abstraction support both
wait thats a good idea
if you want to remove capability such as removing the ability to pass in a pure id, then yes you would need to change all the scripts that use a pure id to use the new technique instead
naturally, doing that without making those changes first is going to break a lot of things
this is the purpose of Deprecation.
so my inout handling system is tightly coupled since it only supports 3 parameters?
so your system might still be capable of taking a pure id - but you would consider it "deprecated" and slowly phase out anywhere you still use a pure id, and never use it for future works. this is why you should absolutely care when roblox deprecates something because it is exactly the same as this
so changing parameters in a module should be handled like how roblox deprecates objects
or even a function in general
only if you remove functionality or change it in a way that older methods are no longer supported
the goal is backwards compatability; code that hasn't been updated to use new methods still need to function
otherwise your game breaks
this stuff isn't hard to research btw
i see
and should be glaringly obvious
like well duh if you remove something that other parts of your game relies on, it's going to break your game
I didn't need to tell you that, you already knew that
yeah bt i didnt think about the backwards compatability part
the only part you probably didn't realize is yes code really is that stupid
most beginners tend to overthink it
i mean yeah code isnt sentient
like omg deprecated big word such complex
no.. it just means you don't break your game when you go to remove something
everything in scripting is like this
all of it
in fact the more ooga booga caveman smallbrain you are about it, the better.
in fact, you may find me asking really stupid questions, or posting really dumb or obvious answers to people's questions
** You are now Level 56! **
i mean i already know what deprecated means
i don't do it just because, it's actually a very specific technique
you dont make more things?
i make more things all the time
last week i made gui particles
this week i made a bytenet replacement
so you dont do what
today and tomorrow i'll be working on the player session sync thing, basically networking/remotes wrapper so i can share data
i thought you hated buffers and optimization
you're overthinking it
what is the simplest, dumbest reason you can think of for why i would tell beginners not to use bytenet, but then go and make my own even better one for myself?
cuz youre a hypocrite
that's simple but not very dumb
kinda dumb tho
it's actually because beginners don't know how to use that stuff whereas i do
i already figured it out
a beginner, who does not understand remotes in the first place, does not need something that makes their remotes harder to use
it really is that dumb and simple
the skill level of the person i am speaking to matters a lot
if thats your idea of a beginner then i guess iim not a beginner
you're still in the range where adding it is just more work you don't need to care about right now
it's only worth using when you have good reason to use it
and know why you would use it instead of not use it
buffers or remote events?
cuz remote events are unavoidable in most cases
you should be using something more like knit instead which gives more meaningful networking communications
bytenet is pure compression into buffers (and tbh doesn't do a very good job of it)
so you were talking abot buffers
i learned that but i frogot to remove them
im pretty sure buffers should be used for very very frequent calls with many parameters
no, you're overthinking it again
how is that overthinking it
buffers are only useful if you can beat roblox
are buffers not meant to be used in expensive situations
???
do you really think roblox doesn't already compress a lot of its network traffic?
if you can't do better than that, there's no point to using buffers with remotes
i knwo roblox does that but buffers do it better in most cases. usually not by much, but still more
yeah it's usually not by much. people post benchmarks where they send 2gb of data in 1kb and you might think how? in reality it's the same data duplicated a billion times
it doesn't show meaningful compression because real data is much more random and unsorted
most of the time, people are not going to be sending so much data that any of this actually matters
I am in a position where i do expect to be sending a lot of data
hence i need proper networking systems
-- i also know how to build them
so what would be some uses of buffers in an actual game
or are they just not useful
and i only know that coz i've already made so much stuff. when I say make more things, i'm not suggesting you do anything I have not already done myself.
I have already done all that work. you have not
i know the answer to this because i've made so much stuff. you don't because you've never properly hit resource limits
like as in without doing something dum like an infinite loop or insane memory leak - in the normal course of operation the game maxes out servers. i've hit limits like that before
generally they're not that useful. main use is to reduce memory usage
so theoretically if i had an ability that fires 10-15 times a second would buffers be useful or is that still too far under the threshold
i would benchmark but i cant realy simulate a real game
so what you'd be sending a number or a boolean - the buffer isn't going to change anything
you'd get better gains by sending a number instead of a string
coz i see that a lot
:FireServer("SomeAbility")
the entity id is a number from 1-256
and then they go ermagherd bytenet uber compress ByteNet:FireServer("SomeAbility")
..... send a number not a string would've been better in both cases, bytenet didn't help
most games need more than 255 entities
in fact with roblox the definition of an entity isn't as clear-cut as it is in other games
but i'm not going to go into that right now
entity meaning a humanoid
** You are now Level 20! **
what the hell is ermagherd bytenet uber
anyway, bottom line is that i'm not kidding, exaggerating, gatekeeping, or "edgiiing" when i say, just make more things. I genuinely mean it.
coz while you're still trying to perfect one little tiny piece of code, someone else, such as myself, has made leaps and bounds of progress in making systems and content - they aren't perfect, but the job absolutely gets done to a reasonable degree, and in substantially larger volumes.
it's like
you can spend a year making one thing that doesn't end up doing what you want after a week of adding content to it
or you can spend a year making and releasing a thousand things that may not be perfect but they function and people can play with what you make.
it's really up to you, i'm not your mom
the self glaze 💔 😭
im tryna make stuff that looks good on my port so thats the main reason im making this
well yeah i've just spent an hour explaining to you that you should be focusing on making stuff not perfecting it when i could've spent that time making my own stuff
we've both lost productivity in your pursuit of unnecessary perfection.
well theoretically you could spend any time doing that so thats not saying much
its the principle
just make stuff that's fun to play with
but
well
commisioners dont care about that sadly
you can forge your own path and i won't stop you if you really want to do that, at least you are now informed that it is a bad idea and why it is a bad idea.
is about all i can give you - can lead a horse to water but can't make it drink.
How would I balance it though
Cuz at the end of the day commissioners barely care about back end
Only how it looks
And if it works
you only need to improve code when it needs improving
you will know when it needs improving when your code doesnt do what you need it to do or is lagging your game
I should also balance this with making it readable right?
i think you're overthinking what readability is
readability is just dont make it confusing to read or follow on a later read
aka use descriptive variable and function names, don't nest too heavily
don't using confusing weird ass logic where it doesn't belong
"bEcAuSe OpTiMiZaTiOn" is not a good excuse to make your code impossible to follow
and your datastore code shouldn't have any animations in it
that is - keep related stuff together
don't put unrelated stuff together
avoid globals and magic variables etc
I’m not
I meant just making my code readable
Hmm
I did my research and around 200 entities is the max for oop before noticeable hits in performance
So I think your hatred for dod is unjustified