Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
/VM/station wiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Understanding SS13 code
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==What is an object?== SS13 is coded in Byond, which is an object oriented programming language. Please note that by object here i do not mean an item or machine in-game. For this intro alone i will speak of objects as I'll define them here. An object can be any defined path in the game. Examples include: /obj/item/weapon/sword /turf/simulated/floor /area/ /atom/ An object is made out of both [[#Variables|variables]] and [[#Procs|procs]] Here's an example of an object: /turf/simulated/gold_spot var/spawned_gold = 0 name = "Gold Area" desc = "This plot may have spawned gold!" /turf/simulated/gold_spot/proc/spawn_gold() if(prob(50)) new/obj/item/stack/sheet/gold(src) spawned_gold = 1 /turf/simulated/gold_spot/New() ..() spawn_gold() === Hierarchy and Inheritance === Objects inherit all it's parent's variables and procs. This means that an object defined as /obj/item/weapon/storage/box has all the variables of /obj/item/weapon/storage, /obj/item/weapon, /obj/item, /obj and also /atom, but we'll get to that one later. Some procs are already defined for all objects, you can see these [http://www.byond.com/members/?command=reference&path=atom%2Fproc here]. In the above example, New() was an instance of a proc which was inherited from the parent object. This is why New() does not have the proc/ prefix, because it is already defined in the parent object. You should however know that New() was redefined here, so it no longer acts the same way as in the parent objects. An example of an inherited variable are the name and desc (description) variables. Both were redefined tho. spawned_gold, however, is a new variable. One which the parent proc does not have. If we define the following two objects... /turf/simulated/gold_spot/plot1 /turf/simulated/gold_spot/plot2 ...we just defined two child objects of /turf/simulated/gold_spot and they inherited all the procs and vars that /turf/simulated/gold_spot has including all those which /turf/simulated/gold_spot inherited from their parent (/turf/simulated). === ..() === ..() is something you will often see in the code. In other languages this is usually called super(), it calls the parent object's proc with the same name. Unlike some languages it is not automatically executed even if not added, nor is it required to be at the proc's start. These are usually added in New(), Del() and Attackby() procs to get to the original definition in the common parent. These common definitions usually ensure things are properly handled.
Summary:
Please note that all contributions to /VM/station wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
/VM/station wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width