Coding in BYOND - How do?

How, what and why to code in BYOND.
Locked
User avatar
Psyentific
Joined: Mon Apr 21, 2014 7:44 am
Byond Username: Psyentific
Location: Vancouver, Canada
Contact:

Coding in BYOND - How do?

Post by Psyentific » #6335

I've got a few things I might like to contribute to NTCode, but I've got no idea how to code in BYOND. How easy is it, what's something I can do out the gate, how can I set up a local server to test my code? Outside of universal programming concepts, finite/infinite loops, if/else statements, how does BYOND work? Will I need to create variables before I use them, Java style, or can I do it on the fly Python style? Is there a third-party IDE, or does everyone use dreamseeker? Are there any resources I should be looking at/for, in terms of BYOND in general but also SS13 specifically?

How would I go about creating a new item?
How would I edit the map, to put this new item in? Would that be what I would do, or would I be pestering Metacide/Whomever to put it in?
How would I create a new job, with its own equipment, office, and spawn location?

How can I go from nothing to coding?
Last edited by Psyentific on Fri May 16, 2014 6:44 pm, edited 1 time in total.
I haven't logged into SS13 in at least a year.
User avatar
Neerti
Rarely plays
Joined: Thu Apr 17, 2014 5:06 pm
Byond Username: Neerti

Re: Coding in BYOND - How do?

Post by Neerti » #6338

For variables, I'm not exactly sure what you mean, but variables need to be defined somewhere in order to actually use it.

Say if I wanted to add a variable called 'foo' to an object. Doesn't matter which object, completely arbitrary. I'd write something like this.

Code: Select all

/obj/item/weapon/bar
    name = "Foobar"
    desc = "I am an example!"
    var/foo = 0
You could put that spinet anywhere, but you'd preferable put it somewhere where it'd made sense, for organizational purposes. If you spawned that ingame, it would be invisble due to lacking an icon and icon_state variable.

Now, name and desc lack var/ because they're already defined in /obj/. Bar will also inherent variables defined in /obj/, and any variables you make will be inherited down the tree.
If I made a /obj/item/weapon/bar/test , then put 'Name = "Testing!", it would have the name Testing!. If I don't add a desc, however, it would have "I am an example!" because it inherited from it's parent.

You can define variables in procs (also called functions outside of byond) that only matter to the proc.

Most variables are not globals if defined in an object down a tree. If I made /obj/item/weapon/foo , and added foo = 1, the compiler would whine at me due to there being no var named foo defined there.

For IDEs, most people just use DM, since it gets the job done. I know a few people managed to make notepad++ work with code magic, compiling with a batch script.

There's no official reference for SS13 development, but BYOND has a reference available by pressing F1 in DM, which will be very useful. The closest thing to a manual for SS13 coding is coderbus/nanobus on IRC.

The wiki has a few guides for coding as well.
ImageImage
- Game Admin -
Feel free to PM me on the forums or IRC with questions, concerns, feedback, or just talk about stuff.
Have I not met my hitler quota this month?
User avatar
Remie Richards
Joined: Thu Apr 17, 2014 7:11 pm
Byond Username: CrimsonVision
Location: England, UK, Earth, Sol, Milky Way, Local Group, Virgo Supercluster, Known Universe
Contact:

Re: Coding in BYOND - How do?

Post by Remie Richards » #6370

The Wiki plus this Standards guide I compiled from Own knowledge and the myriad other guides we've had
https://github.com/NTStation/NTstation1 ... -Standards

If you're ever stuck, go to #coderbus, or #nanobus, Generally were friendly enough to assist!
私は完璧
miggles
Joined: Fri Apr 18, 2014 9:02 am
Byond Username: Miggles
Contact:

Re: Coding in BYOND - How do?

Post by miggles » #6706

i would recommend trying #coderbus first, as they have a larger number of people there and most of them are willing to help
dezzmont wrote:I am one of sawrge's alt accounts
dezzmont wrote:sawrge has it right.
Connor wrote:miggles is correct though
User avatar
paprika
Rarely plays
Joined: Fri Apr 18, 2014 10:20 pm
Byond Username: Paprka
Location: in down bad

Re: Coding in BYOND - How do?

Post by paprika » #6779

Paprika's guide to coding

1) Mirror the code on your desktop
2) Navigate to NTstation13\code\modules\projectiles\projectile\bullets.dm
3) Make all damage values 9999
4) Ask Miggles to merge it
Oldman Robustin wrote:It's an established meme that coders don't play this game.
Perakp
Joined: Sat Apr 19, 2014 2:45 pm
Byond Username: Perakp

Re: Coding in BYOND - How do?

Post by Perakp » #11862

Psyentific wrote:How easy is it
Byond coding in principle is fairly easy, comparable or a bit easier than java or C, maybe even a good starting language. Like with any project in any language, the hard part is not coming up with new code, but understanding the old code. It depends a lot on what part of the codebase you are looking to work on.
what's something I can do out the gate
After you got the code downloaded, ready in dreammaker and you've test compiled it, and you don't know much byond coding yet to build anything from scratch, you can do small edits on existing stuff or copypaste something and work from there. My first thing was creating new sec uniforms from some sprites that were laying around the forums. Most likely you'll want to spend a good while just browsing through the files, see what catches your interest.
Oh and remember to give yourself admin status for testing your work.
how can I set up a local server to test my code?
You can test your code by compiling and running it in dreammaker. To test interactions between characters you can use dreamseeker. Select the compiled .dme file and press 'go'. You can join with your byond account, log out and join again as a guest.
how does BYOND work?
Honestly I'm surprised we have as little lag as we have. Byond is magic.
Is there a third-party IDE, or does everyone use dreamseeker?
I heard someone used notepad++, someone edited stuff straight from github some way. But dreammaker is the only place to compile and run as far as I know, so you can write anywhere but need to use dreammaker for that. Might aswell do it all in dreammaker.
Are there any resources I should be looking at/for, in terms of BYOND in general but also SS13 specifically?
http://www.byond.com/docs/ref/
http://www.byond.com/docs/guide/
Our codebases aren't much documented, so you'll be searching through github a lot. It is educational to look through the revision history and old pull requests to see how things are done.
How would I go about creating a new item?
Define the /obj/item/yourItem and it's variables. If there are special interactions you use attack_hand(), attackby() etc. Obviously adding the icons is important unless you want your item to be invisible. Looking at /code/game/objects/items.dm is a good place to start.
How would I edit the map, to put this new item in? Would that be what I would do, or would I be pestering Metacide/Whomever to put it in?
Open the map file in dreammaker, the tools for adding stuff should appear, and your item should be there somewhere. Then you need to learn how to use the map merger tool before making a pull request.
How would I create a new job, with its own equipment, office, and spawn location?
Jobs are at /code/game/jobs/, so you'd start from there.
We have some pretty good mapping guides for all the things you need to remember to add, pipes, alarms, APC, etc. A spawn location is just another object you'd need to add to the map, modify the variables so that it's a spawn location for the new job. You'd need to add the job to the job selection interface, make sure the ID computer works for the new access levels, stuff like that.
How can I go from nothing to coding?
Have fun and don't look back.
Locked

Who is online

Users browsing this forum: No registered users