• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Lua Conventions or Blizzard Conventions?

Level 4
Joined
Feb 26, 2022
Messages
13
So, Lua has an officially sanctioned list of proper naming for their language, found here: GitHub - luarocks/lua-style-guide: Lua Style Guide, as used by LuaRocks

But, the problem is that Blizzard functions do not follow this.

For example, I don't think I can think of a single Blizzard function that uses snake_case in the name, which is how Lua tells you to do it.

So, which, in the opinion of HiveWorkShop is worse:
Inconsistent naming, since we have to use Blizz' function names, but we can at least stick with tradition on user-defined functions?
or
Following Blizz' naming conventions, which is consistent but results in more code heresy against Lua?
 
Well, Blizzard functions are written as they are primarily because of JASS, as that followed JASS style syntax.
The only time you would see snake_case is in user generated code via vJASS, but that's besides the point.

I personally use snakeCase and I think I achieve more cohesion in such way: static methods and global functions start capitalized, whereas local functions and methods start lower-cased. (same with variables)
 
It's what/ever case. "Blizzard" Jass is 25-years-old, created by overworked team to get the game out the door and not go bankrupt.
Lua has its roots in C. Last I looked, the style guides generate so little interest, there isn't a popular or accepted one, really. Would you please just get going instead of arguing about the way to tie your shoelaces?

Finally, WC3 is a special environment where your map is a self-contained unit with very little outside world interaction. You can do what you want and it won't affect anything else much.

Personally, I avoid snake_case because I hate typing underscores.
  • table2 = {}
  • CONSTANT_NAME;
  • someVariable
  • upper-case for first letter makes sense for classes, but they are still tables thus values and idk

I find code structure is a more important topic than naming style preference.
 
I personally follow the style that most resources here on hive tend to use. This way they integrate into my own code more elegantly.

Other than that:

CONSTANT_VARIABLES
GlobalFunctions
GlobalVariables
localFunctions
localVariables
ClassTables
Class:methods
Class.fields
table.property

Easily readable and typable.
 
Back
Top