ID:265766
 
Okay, so lets take an objct, any object of your choice, got one? good, now imagine you wanted to add this item and it's paricular features into your brand spanking new BYOND game, what thought prosess or steps do you go through to do this?

I'm finding it difficult to think jut HOW i would even start coding something sometimes, i just wondered how other people did it, if you see what i mean.

If you want i can try to be clearer....
The simple answer is to first know how to do things with the language, and then figure out what you want to do. When you want to add said object to your game, you think of its properties and functions; what defines that object? What does that object do, and how does it interact with other objects?

Suppose I wanted to add a gun to a game. The first thing I want to do is ask myself what defines a gun. The specifics of its appearance can be covered with an icon, which seems pretty obvious. But what defines this gun? Perhaps the gun is defined by its rate of fire, number of rounds, or its accuracy. So if we want to include either of these properties in our game, we make these part of our gun definition. I'd rather keep this simple and and those details excluded from our example, which might look something like this by now:
obj/gun
icon = 'gun.dmi'
var/ammo = 6


Cool, now what do guns do? They shoot bullets, of course. And how do we make them fire? Guns provide an interface---the trigger---so we should probably continue modeling our real world object by providing a sort of trigger function:
    verb/Fire()
set src in usr
// ...To be continued


Great, now when a player has an /obj/gun type in his/her contents, they will have access to a Fire() verb. Now, what happens when we fire a gun? If there are any rounds left, a bullet comes flying out in the direction the gun is facing. So the Fire() verb should create a new bullet and send it flying in the appropriate direction. One way to do this is to create another object type, for the bullet. Ideally, this object would handle all of the specifics of being fired whenever it is created, and since it calls New() when it is created, it should provide such an interface in its New() proc. A simple example of such might be like so:
obj/bullet
New(bulletLoc, bulletDir)
dir = bulletDir
// TODO: Specifics of bullet movement

Now, of course, the "TODO" should be replaced with some code to make the bullet move in the appropriate direction, which may be as simple as walk(src, dir). When a bullet hits something it should do damage. When the object collides with something, it calls the Bump() proc. So when the Bump() proc is called, we should handle the specifics of what to do when something is shot. Altogether, we might have something like so:
obj
gun
icon = 'gun.dmi'
var/ammo = 6
verb/Fire()
set src in usr
if(ammo > 0)
--ammo
new/obj/bullet(usr.loc, usr.dir)

bullet
icon = 'bullet.dmi'
New(bulletLoc, bulletDir)
dir = bulletDir
// TODO: bullet-movement

Bump(damagedObject)
// TODO: just shot something!


Hiead
The first thing I do is decide just what aspects of this object are necessary to the game, what this object will do in the game, and how to best fit that function within my game's interface and style of control...

It is important to keep in mind that you almost never have to recreate a real-world item in any level of complexity/detail beyond this small list of necessary aspects...

For instance, if you wanted a "banana" food item in your game that also creates a banana peel trip hazard after it is eaten, you only need to give it the properties and functions necessary for those specific aspects... There's no need to include that bananas are high in potassium, or that they come in varying levels of ripeness, or that there are multiple varieties, or the average weight of a banana (that is, unless your game uses inventory weight limits or something), or any of the myriad of other traits that make up the real-world banana...

Your game just needs to know that obj/food/banana can be eaten to remove hunger (by a certain amount, varying from food item to food item), and doing so creates a dropped peel that causes people to trip when it is stepped on...

So it's always best to try to keep things as simple as possible... Only include the traits that are necessary for your game...
That is SO vague... how do you make an obj????

obj/Milk

done.