Difference between revisions of "Coding"

From Space Station 13 Wiki
Jump to: navigation, search
(talks about making new branches with git, branch conventions, adds disclaimer that this guide is pretty much just for terminal git)
(modifies some article flow, rearranges some things, sets up some categories that should be filled in the future, adds a bunch of stuff about navigating git (almost done))
Line 1: Line 1:
  
== So you want to wicky wangy diddly dangy learn how to code SS13? ==
+
==So you want to learn how to code for SS13?==
  
 
Well you've come to the right place. This page is dedicated to helping you learn the ins and outs of writing SS13 code. I'll assume you have an above average knowledge of computers. If you ever need help with any of this, feel free to visit the #imcoder channel in the goonstation discord! There's a bunch of helpful people in there who would love to help you learn or help you with any errors you're getting <3  
 
Well you've come to the right place. This page is dedicated to helping you learn the ins and outs of writing SS13 code. I'll assume you have an above average knowledge of computers. If you ever need help with any of this, feel free to visit the #imcoder channel in the goonstation discord! There's a bunch of helpful people in there who would love to help you learn or help you with any errors you're getting <3  
Line 6: Line 6:
 
----
 
----
  
'''The first thing you're gonna want to do, is get the Goonstation 2016 code and set up a branch.'''
+
===Setting Up Your Local Goonstation Branch===
 
<b>This guide is for terminal git! There might be more guides coming soon for other git interfaces, or you can ask for help in #imcoder regarding other git interfaces, setting them up, and using them!</b>
 
<b>This guide is for terminal git! There might be more guides coming soon for other git interfaces, or you can ask for help in #imcoder regarding other git interfaces, setting them up, and using them!</b>
  
Line 15: Line 15:
 
# The code should begin to download, and you should see a new folder on your desktop called "goonstation-2016"
 
# The code should begin to download, and you should see a new folder on your desktop called "goonstation-2016"
 
# Now you'll want to get the terminal open in that folder (either by right clicking inside of the folder and clicking the "open terminal here" option, or using the cd command in the terminal to navigate to that directory).
 
# Now you'll want to get the terminal open in that folder (either by right clicking inside of the folder and clicking the "open terminal here" option, or using the cd command in the terminal to navigate to that directory).
# Let me quick explain a few things about using git. So, there's four possible (afaik) file statuses. There's added, unadded, unmodified, and untracked. Currently (if you haven't touched any files since cloning) every single file in the goonstation directory is <b>unmodified</b>. As soon as you modify a file in any way, that file will become <b>unadded</b> and lose its unmodified status. If you type <syntaxhighlight line='none' enclose='none'>git status</syntaxhighlight> (git status will show you all added, unadded and untracked files in the branch you're working in, and the name f the branch you're working in), you'll see that file in an unadded files category with the file path in red text. Now, if you type <syntaxhighlight line='none' enclose='none'>git add your/file/path/yourfilename</syntaxhighlight>, your file will become <b>added</b>, and it'll be added to the list of files that will be committed. I'll talk about committing a bit later. If you (or byond) creates a new file in your goonstation directory, it'll be added as an <b>untracked</b> file. Both untracked and unadded files will persist between branches and commits. This is useful for some things, like editing config/admins.txt to include yourself as a host for testing purposes and then never adding the file so you'll always have an admin rank anytime you test, but it can also be problematic so make sure you're not leaving anything untracked or unadded that should either be committed or reverted.
+
# Next, you'll probably want to make a new branch for your feature that you're coding (or your map/setpiece that you're making, or your clothes you're spriting). You'll want to make sure you're on the master branch. If you're not, type <syntaxhighlight line='none' enclose='none'>git checkout master</syntaxhighlight> to get there. I suggest using prefixes for the different type of stuff you're working on, like feature/, map/ or  sprite/, and using either dashes "-" or underscores "_" to seperate words, <i>but not both!</i> This'll make it easier to sort and switch branches without having as much guesswork.  
# Now, you'll want to make a new branch for your feature that you're coding (or your map/setpiece that you're making, or your clothes you're spriting). You'll want to make sure you're on the master branch. If you're not, type <syntaxhighlight line='none' enclose='none'>git checkout master</syntaxhighlight> to get there. I suggest using prefixes for the different type of stuff you're working on, like feature/, map/ or  sprite/, and using either dashes "-" or underscores "_" to seperate words, <i>but not both!</i> This'll make it easier to sort and switch branches without having as much guesswork.  
+
#To make your new branch, type <syntaxhighlight line='none' enclose='none'>git checkout -b feature/crime-time-usa</syntaxhighlight>. Git will do a bit of work, and then you'll be pumped into your new branch!
#To make your new branch, type <syntaxhighlight line='none' enclose='none'>git checkout -b feature/crime-time-usa</syntaxhighlight>. Git will do a bit of work, and then you'll be pumped into your new branch!
 
#To list all of your branches, type <syntaxhighlight line='none' enclose='none'>git branch</syntaxhighlight>. If your list of branches is taller than your terminal window, use the arrow keys to navigate down the list. When you get to the bottom, press q to exit the weird no-typey mode so you can continue to do commands. 
 
  
'''Next, the Dream Maker'''
+
===Terminal Git Workflow, Useful Commands, Tips===
 +
<b>File Statuses</b>:
 +
So, there's four possible file statuses (not all the official names):
 +
*Added
 +
*Modified
 +
*Unmodified
 +
*Untracked
 +
Currently (if you haven't touched any files since you cloned goonstation, and haven't messed with compiling or hosting) every single file in the goonstation directory is <b>unmodified</b>. As soon as you modify a file in any way, that file will become <b>modified</b> and lose its unmodified status.
 +
If you type <syntaxhighlight line='none' enclose='none'>git status</syntaxhighlight> (git status will show you all added, modified and untracked files in the branch you're working in, and the name of the branch you're working in), you'll see that file in a modified files category with the file path in red text. Now, if you type <syntaxhighlight line='none' enclose='none'>git add your/file/path/yourfilename</syntaxhighlight>, your file will become <b>added</b>, and it'll be added to the list of files that will be committed.
 +
I'll talk about committing a bit later. If you (or byond, in the case of the weird hosting and compiling files) creates a new file in your goonstation directory, it'll be added as an <b>untracked</b> file. Both untracked and modified files will persist between branches and commits. This is useful for some things, like editing config/admins.txt to include yourself as a host for testing purposes and then never adding the file so you'll always have an admin rank anytime you test... but it can also be problematic so make sure you're not leaving anything untracked or modified that should either be committed or reverted.
 +
 
 +
<b>Branch Control:</b>
 +
To list all of your branches, type <syntaxhighlight line='none' enclose='none'>git branch</syntaxhighlight>. If your list of branches is taller than your terminal window, use the arrow keys to navigate down the list. When you get to the bottom, press q to exit the weird no-typey mode so you can continue to do commands.
 +
If you want to switch to a different branch, type <syntaxhighlight line='none' enclose='none'>git checkout feature/new-stuff-v3</syntaxhighlight>.
 +
If you want to create a new branch, type <syntaxhighlight line='none' enclose='none'>git checkout -b feature/new-stuff-v4</syntaxhighlight>
 +
 
 +
<b>Committing And You:</b>
 +
You can save changes to files, but one of the advantages of using git is that it has REALLY good version control. Say you commit some changes on a patch that's making a new jumpsuit, right? In your first commit which you made yesterday, you made the basics of the new jumpsuit, giving it a name, description and a sprite. But- egads! When you open up dreammaker today, your code is gone! Well, you can fix that by reverting to your earlier commit, where everything will be restored to exactly how it was when you committed yesterday.
 +
In order to commit, you'll want some files to commit. Add files you want to commit like how its shown in the file statuses section. Then, just type <syntaxhighlight line='none' enclose='none'>git commit -m "your commit log message here!!"</syntaxhighlight>
 +
This will commit all the files you told it to commit, and save that in the commit log along with your message.
 +
(
 +
 
 +
<b>Pushing Changes:</b>
 +
Just type <syntaxhighlight line='none' enclose='none'>git push origin feature/handholding</syntaxhighlight> to push your local changes on your local branch to your online version of the branch that other people can see and interact with.
 +
 
 +
===Tortoise Git Setup, Workflow, Commands, Useful Tips===
 +
(ask urs to fill this one out she seems to know some of this stuff)
 +
 
 +
===Using Dreammaker===
  
 
Now I'm going to show you how to edit, compile, and run code, using DreamMaker.
 
Now I'm going to show you how to edit, compile, and run code, using DreamMaker.
  
 
To open DreamMaker, open byond. Then navigate to the setting menu and click Open DreamMaker
 
To open DreamMaker, open byond. Then navigate to the setting menu and click Open DreamMaker
 +
[[File:Opendm.png]]
 +
===Introduction to DM as a language===
 +
(for this section, im gonna bother urs to spout of some smart sounding gunk. gist of it is, DM is an object oriented programming language, stuff has inheritance, its a simplified language that means its rather easy to pick up but cant do a ton of complex things)
 +
 +
===ATOMs and Datums===
 +
(talk about area, turf, object, mob, datum, how the inheritance works for all of them, examples, why you should use specific ones for specific things)
 +
 +
===Code Stuff You Should Know===
 +
(0 and false and null making ifs return false, basics of for/while loops, making new vars, overlays, adding basic procs, loc, src, usr, istype, switch, ..(), probably more lol)
 +
 +
===Code Conventions===
 +
(talk about stuff like variable/proc naming, whitespace, commenting, ettiquite, where to put your files)
 +
 +
===Spriting/Sprites===
 +
(talk about sprite stuff for code)
  
[[File:Opendm.png]]
+
===Tips, Tricks and Useful Strategies===
 +
(stuff like looking through the code to see if someone's done something you've already
 +
 
 +
===Submitting a Patch===
 +
(talk about compare vs pr, how to package up sounds, sprites, how to format a forum post, good resources for recording videos of patches)
  
 
== Supplementary Video ==
 
== Supplementary Video ==
 
<youtube>https://www.youtube.com/watch?v=_t0ZBAk72K8</youtube>
 
<youtube>https://www.youtube.com/watch?v=_t0ZBAk72K8</youtube>

Revision as of 19:54, 3 December 2019

So you want to learn how to code for SS13?

Well you've come to the right place. This page is dedicated to helping you learn the ins and outs of writing SS13 code. I'll assume you have an above average knowledge of computers. If you ever need help with any of this, feel free to visit the #imcoder channel in the goonstation discord! There's a bunch of helpful people in there who would love to help you learn or help you with any errors you're getting <3


Setting Up Your Local Goonstation Branch

This guide is for terminal git! There might be more guides coming soon for other git interfaces, or you can ask for help in #imcoder regarding other git interfaces, setting them up, and using them!

  1. You're going to need git, so download and install it from here
  2. Once you've installed that, open command prompt (win+r, type 'cmd', enter)
  3. In that terminal type cd %UserProfile%\Desktop to move to your desktop (then enter)
  4. Then in that terminal type git clone https://github.com/goonstation/goonstation-2016 and press enter
  5. The code should begin to download, and you should see a new folder on your desktop called "goonstation-2016"
  6. Now you'll want to get the terminal open in that folder (either by right clicking inside of the folder and clicking the "open terminal here" option, or using the cd command in the terminal to navigate to that directory).
  7. Next, you'll probably want to make a new branch for your feature that you're coding (or your map/setpiece that you're making, or your clothes you're spriting). You'll want to make sure you're on the master branch. If you're not, type git checkout master to get there. I suggest using prefixes for the different type of stuff you're working on, like feature/, map/ or sprite/, and using either dashes "-" or underscores "_" to seperate words, but not both! This'll make it easier to sort and switch branches without having as much guesswork.
  8. To make your new branch, type git checkout -b feature/crime-time-usa. Git will do a bit of work, and then you'll be pumped into your new branch!

Terminal Git Workflow, Useful Commands, Tips

File Statuses: So, there's four possible file statuses (not all the official names):

  • Added
  • Modified
  • Unmodified
  • Untracked

Currently (if you haven't touched any files since you cloned goonstation, and haven't messed with compiling or hosting) every single file in the goonstation directory is unmodified. As soon as you modify a file in any way, that file will become modified and lose its unmodified status. If you type git status (git status will show you all added, modified and untracked files in the branch you're working in, and the name of the branch you're working in), you'll see that file in a modified files category with the file path in red text. Now, if you type git add your/file/path/yourfilename, your file will become added, and it'll be added to the list of files that will be committed. I'll talk about committing a bit later. If you (or byond, in the case of the weird hosting and compiling files) creates a new file in your goonstation directory, it'll be added as an untracked file. Both untracked and modified files will persist between branches and commits. This is useful for some things, like editing config/admins.txt to include yourself as a host for testing purposes and then never adding the file so you'll always have an admin rank anytime you test... but it can also be problematic so make sure you're not leaving anything untracked or modified that should either be committed or reverted.

Branch Control: To list all of your branches, type git branch. If your list of branches is taller than your terminal window, use the arrow keys to navigate down the list. When you get to the bottom, press q to exit the weird no-typey mode so you can continue to do commands. If you want to switch to a different branch, type git checkout feature/new-stuff-v3. If you want to create a new branch, type git checkout -b feature/new-stuff-v4

Committing And You: You can save changes to files, but one of the advantages of using git is that it has REALLY good version control. Say you commit some changes on a patch that's making a new jumpsuit, right? In your first commit which you made yesterday, you made the basics of the new jumpsuit, giving it a name, description and a sprite. But- egads! When you open up dreammaker today, your code is gone! Well, you can fix that by reverting to your earlier commit, where everything will be restored to exactly how it was when you committed yesterday. In order to commit, you'll want some files to commit. Add files you want to commit like how its shown in the file statuses section. Then, just type git commit -m "your commit log message here!!" This will commit all the files you told it to commit, and save that in the commit log along with your message. (

Pushing Changes: Just type git push origin feature/handholding to push your local changes on your local branch to your online version of the branch that other people can see and interact with.

Tortoise Git Setup, Workflow, Commands, Useful Tips

(ask urs to fill this one out she seems to know some of this stuff)

Using Dreammaker

Now I'm going to show you how to edit, compile, and run code, using DreamMaker.

To open DreamMaker, open byond. Then navigate to the setting menu and click Open DreamMaker Opendm.png

Introduction to DM as a language

(for this section, im gonna bother urs to spout of some smart sounding gunk. gist of it is, DM is an object oriented programming language, stuff has inheritance, its a simplified language that means its rather easy to pick up but cant do a ton of complex things)

ATOMs and Datums

(talk about area, turf, object, mob, datum, how the inheritance works for all of them, examples, why you should use specific ones for specific things)

Code Stuff You Should Know

(0 and false and null making ifs return false, basics of for/while loops, making new vars, overlays, adding basic procs, loc, src, usr, istype, switch, ..(), probably more lol)

Code Conventions

(talk about stuff like variable/proc naming, whitespace, commenting, ettiquite, where to put your files)

Spriting/Sprites

(talk about sprite stuff for code)

Tips, Tricks and Useful Strategies

(stuff like looking through the code to see if someone's done something you've already

Submitting a Patch

(talk about compare vs pr, how to package up sounds, sprites, how to format a forum post, good resources for recording videos of patches)

Supplementary Video