Skip to content

Coding standards for vgstation13

Rob Nelson edited this page Dec 1, 2020 · 3 revisions

Putting aside quality coding for the moment, there's a good number of objective standards that the codebase aims to work under. If you spot someone failing these standards, be sure to point it out to them, and then to a maintainer if they don't do anything about it. Common standard requirements are:

Absolute pathing

Absolute pathing is where every verb, proc, and type is preceded by its full path tree up to the highest sensible type. You won't have to go past mob, area, obj, or turf, but you will have to include those in the path if they're necessary. Let's look at an example:

/obj/item/fork  
   name = "fork"

   proc/eyestab(var/mob/target)

Ignoring the unrealistic nature of this particular chunk of code, this is an example of relative pathing, where the proc is not preceded by its type but is tabbed under it. This makes code harder to read, edit, maintain, and bugfix. We'd much rather have

/obj/item/fork
    name = "fork"

/obj/item/fork/proc/eyestab(var/mob/target)

Not much of a change, but you can immediately see which type the proc is under now, and there's no chance of something breaking if the eyestab proc is moved from one file to another, since it'll always have that pathing there to define it.

Span classes

Old coders in SS13 used color macros to help give variety and sense to on-screen messages for players. You can recognise them in the code because they look like your regular string formatters:

"\red Griff McShirt throws the fork!"
"\blue The machine beeps: Out of forks!"

Over time, these macros depreciated and got replaced by a newer, fancier CSS-style system that allows you to wrap messages in defined classes which give a bit more flavour and are easier to understand, such as:

"<span class='danger'>You got stabbed in the eyes!</span>"
"<span class='notice'>The doctor applies some medicine to Griff McShirt's eyes.</span>"

However, work has to be done to replace a lot of old color macros with the new standard, as well as prevent new color macros from being added in over the newer style. Old \red and \blue macros should be replaced with one of the following appropriate span classes:

  • attack - The red attack message, used primarily for attacks only or direct messages of denial
  • warning - Used during the failure of an action or as a response to an action ex: "access denied". It is the same as attack but italicized.
  • danger - Used to express direct danger to the player, a stronger form of warning. It is attack but italicized and bolded.
  • sinister - Used in select circumstances for text from particularly 'evil' things such as narsie
  • info - Used for giving descriptive information to the player, used in examine text primarily.
  • notice - The counterpart to warning, usually gives player information when an action is successful, used for giving a player notice of something.
  • bnotice - Bolded form of notice, for when notice just isn't going to get the message across
  • rose - Rarely used, except in certain circumstances.