How do I create a new object?

How, what and why to code in BYOND.
Post Reply
Bamhalazam
Joined: Tue Aug 18, 2020 8:31 pm
Byond Username: Bamhalazam

How do I create a new object?

Post by Bamhalazam » #572778

Hello, absolutely clueless and hopeless 'coder' here.

I don't know anything about coding. I want to add two objects to the game: a fencing epee and bag. I have made the sprites but I do not know how to even start the process of converting the sprites into objects.

Any help would be appreciated!
Bamhalazam
Joined: Tue Aug 18, 2020 8:31 pm
Byond Username: Bamhalazam

Re: How do I create a new object?

Post by Bamhalazam » #572780

I also would like to know whether or not there is a test server since I am sure that no one would merge spaghetti code just for some test.
User avatar
oranges
Code Maintainer
Joined: Tue Apr 15, 2014 9:16 pm
Byond Username: Optimumtact
Github Username: optimumtact
Location: #CHATSHITGETBANGED

Re: How do I create a new object?

Post by oranges » #572782

User avatar
wesoda25
Joined: Thu Aug 10, 2017 9:32 pm
Byond Username: Wesoda25

Re: How do I create a new object?

Post by wesoda25 » #572807

Honestly I think the best short-term resource is looking at PRs on github. Look at prs that add items to the game, should give you some insight as to how you should go about it without attempting to navigate a large and potentially confusing guide.
[this space reserved]
User avatar
PKPenguin321
Site Admin
Joined: Tue Jul 01, 2014 7:02 pm
Byond Username: PKPenguin321
Github Username: PKPenguin321
Location: U S A, U S A, U S A

Re: How do I create a new object?

Post by PKPenguin321 » #572808

You'll want to fire up a test server on your own.
BYOND, which you need to have in order to play the game in the first place, comes with its own development environment called Dream Maker and a hosting tool called Dream Daemon. If you're running Windows you can just search for them in your taskbar and they should pop up.
Download our source code here: https://github.com/tgstation/tgstation/ ... master.zip
Then when you unzip it, open tgstation.dme to open the game code in Dream Maker. The code should be ready to go by default, and you can compile it by click Build > Compile. This will output a .dmb file in the same folder as the .dme, which you can double click to run or properly host with Dream Daemon.
Once you have a test server that you locally host, you'll automatically get access to admin tools. Among these tools is the ability to View Variables. Right click ANYTHING and find View Variables in the right click menu to open up a handy window that shows you the values of everything on an object/mob/whatever. For example, view the variables of a fire extinguisher and you can find the "force" variable to see exactly how much damage it does. Learning by experience like this is really handy for newbies.
Once you've played around with it for a bit, check out our code here: https://github.com/tgstation/tgstation You'll notice a search bar up at the top which you will probably make a lot of use of. If I search for fire extinguisher, my top result is extinguisher.dm, where you can see the object definition (line 1), variables being set (lines 2 through 18), new variables being declared and set (lines 19-28)... You'll notice that "force" is defined on line 13, and is equal to what the in-game View Variables window said! Also some variables are defined in weird ways, like "icon", which points to a ".dmi" file... If you open up that .dmi file in Dream Maker, you'll find where we store icons! Poke around a bit in there and you'll quickly find Dream Makers sprite editor.

Basically just poke around, see how things work, and go off of example. A new object that's just a weapon should be really easy, and what I've shown you here should be enough to help you figure out how to do it.
If you want to actually merge your code into our live codebase, you'll want to set up git, but that's a whole different tutorial. Cross that bridge when you get to it, it'll make your life easier if you're just starting out.
i play Lauser McMauligan. clown name is Cold-Ass Honkey
i have three other top secret characters as well.
tell the best admin how good he is
Spoiler:
Image
cacogen
Forum Soft Banned
Joined: Sat Jun 02, 2018 10:27 am
Byond Username: Cacogen

Re: How do I create a new object?

Post by cacogen » #572809

make it a child of an existing sword so it inherits that object's code and then modify its damage

you can see how a sabre is created here:
https://github.com/tgstation/tgstation/ ... isc.dm#L55

so like

Code: Select all

/obj/item/melee/sabre/epee
	name = "fencing epee"
	desc = "This is used to fence."
	icon_state = "epee"
   icon = 'icons/obj/items_and_weapons.dmi' //object sprite should go in this file, named as above (e.g. epee)
	inhand_icon_state = "epee"
	lefthand_file = 'icons/mob/inhands/weapons/swords_lefthand.dmi' //left inhand sprite should go in this file, named as above (e.g. epee)
	righthand_file = 'icons/mob/inhands/weapons/swords_righthand.dmi' //right inhand sprite should go in this file, named as above (e.g. epee)
	force = 2 //melee damage
	sharpness = SHARP_EDGED //i assume there's a define in the code for not sharp somewhere which you'd replace here to prevent embedding
	throwforce = 5 //thrown damage
	armour_penetration = 0 //i don't know how this works but i'm guessing you'd want it at 0 for a fencing sword
technokek wrote:Cannot prove this so just belive me if when say this
NSFW:
Image

Image
Post Reply

Who is online

Users browsing this forum: No registered users