Jump to content

Coding Best Practices

Recommended Posts

In the two (well, one and a half) mods I've made so far, I was coding for functionality only ("just make it work.")
I was on a deadline and I didn't know the environment (or Lua) very well, and I did get everything working, but the result was very messy code.
I ended up with 1647 lines of code in my modmain file.

Now I'm about to start working on a new mod, something bigger and possibly with other people too, so this style of work is not a good approach - and I don't like it either, coming from a background of coding with a strong emphasis on design, style and conventions.

So what I'm looking for here is some advice from veteran Don't Starve script writers.
What are some good practices and rules of thumb for coding in Lua for Don't Starve Together?
Some design patterns would also be nice (for example, I always try to wrap an existing function with my extra code rather than replace it with a copy of the original that has my additions in it.)

I know there's an option for importing modules which can help reduce the size of modmain and organize the code better, but I think that when I tried using it I had some trouble accessing the GLOBAL variable (my memory's kind of fuzzy on that part).

Thanks in advance. =)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...