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!
==Code components== ===Variables=== [http://www.byond.com/members/?command=reference&path=var reference] Variables are intended to store data. Variables are created like this: (creates variable with no defined value) var/i To define a value in declaration do this: var/i = 5 or var/i = "Hello World" Once a variable has been defined, you cannot define another one with the same name: var/i i = 2 i = 6 i = 12 ==== List ==== [http://www.byond.com/members/?command=reference&path=list reference] A list can be defined as either of the three, but special variables associated with lists (such as len for length) will only be available if you use the first declaration. var/list/a var/a[9] var/a = list() ==== Other Types ==== If you wish to store a coin in somewhere in the variables of an object and use the coin's defined procs or variables, you'll have to define the variable in which you store the coin as a coin. The second example also creates a variable called D and sets it to a new coin. var/obj/item/weapon/coin/C var/obj/item/weapon/coin/D = new/var/obj/item/weapon/coin(src) ==== Included variables ==== Variables which are built into byond itself and are not defined anywhere in code: <br>[http://www.byond.com/members/?command=reference&path=atom%2Fvar Atom vars] <br>[http://www.byond.com/members/?command=reference&path=client%2Fvar Client vars] <br>[http://www.byond.com/members/?command=reference&path=datum%2Fvar Datum vars] <br>[http://www.byond.com/members/?command=reference&path=mob%2Fvar Mob vars] ===== Direction (dir) var ===== [http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Fdir reference] '''North:''' 1<br> '''South:''' 2<br> '''East:''' 4<br> '''West:''' 8<br> '''Northeast:''' 5 (1 + 4)<br> '''Southeast:''' 6 (2 + 4)<br> '''Northwest:''' 9 (1 + 8)<br> '''Southwest:''' 10 (2 + 8)<br> They are numbered like this because dir uses the 'bitflag' methodology. You can read more about bitflags [[Binary_flags|here.]] It is defined in binary, so... '''0001''' is north<br> '''0010''' is south<br> '''0100''' is east<br> '''1000''' is west Combining these numbers yields north-east (0101), north-west (1001), south-east (0110) and south-west (1010). Tho other combinations (east-west(1100), north-south (0011), north-east-west (1101) and such) are possible for special uses. Smoothwall code is an example. ===== Atom vars ===== These apply to all /obj, /turf, /area, /mob -type objects. '''[http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Fcontents Contents]: '''List of objects which are inserted into another object. (plasma tanks in radiation arrays, ore in the smelter, etc.) <br>'''[http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Fdensity Density]: '''0/1 - 0 means your mob can pass through (or over), 1 means you cannot <br>'''[http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Fdesc Desc]: '''string - Description, displayed upon examine <br>'''[http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Fdir Dir]: '''1-10 - the direction the object is facing <br>'''[http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Ficon Icon]: '''The .dmi file which contains the sprite for the icon <br>'''[http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Ficon_state Icon_state]: '''The name of the sprite in the file from Icon <br>'''[http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Foverlays Overlays]: '''A list of images which are overlayed on the item. <br>'''[http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Flayer Layer]: '''If two objects are on the same tile and one has a higher layer number than the other, the one with the higher will be shown as above the one with the lower <br>'''[http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Floc Loc]: '''The X,Y,Z positioning of an item <br>'''[http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Fluminosity Luminosity]: '''How much does it glow? <br>'''[http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Fname Name]: '''The name, displayed when you hover your mouse over the item <br>'''[http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Fopacity Opacity]: '''Can you see through it? <br>'''[http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Fpixel_x Pixel_x], [http://www.byond.com/members/?command=reference&path=atom%2Fvar%2Fpixel_y pixel_y]: '''Set if the item on the map is nudged a few pixels to either side. Used with APC's, Request Consoles, Fire alarms, etc. <br>'''[http://www.byond.com/members/?command=reference&path=datum%2Fvar%2Ftype Type]: '''Type is the path of the object. A coin would have it's type variable set to: /obj/item/weapon/coin === Included instructions === Reference guides for included instructions (proc-s) can be found at the following links: <br>[http://www.byond.com/members/?command=reference&path=area%2Fproc Area procs] <br>[http://www.byond.com/members/?command=reference&path=mob%2Fproc Mob procs] <br>[http://www.byond.com/members/?command=reference&path=obj%2Fproc Obj procs] <br>[http://www.byond.com/members/?command=reference&path=obj%2Fproc Turf procs] === Conditionals === Conditionals are statements which determine how the code will be executed, depending on a condition. The most common conditional is the IF statement ==== = vs. == ==== var/a a = 14 if (a == 14) world << "A has the value [a]" else world << "A is not 14" As in the example above, the single = means you assign the value on the right to the variable on the left. In the example above, the variable a was assigned the value 14 (a = 14) The double == is used to compare two values. It's most commonly used in the if statement. In the example above you can see we compared the variable a to 14 (a == 14). This determines how the if will react. Comparison Operators [http://www.byond.com/members/?command=reference&path=proc%2Fif reference] The example shows a simple if statement. If statements work by first checking if the statement in the brackets, in the case above a == 14, is true or not. If it's true, it will proceed to execute the code, which is further indented from the if (in the case above: world << "A has the value [a]"). In the other case, if the statement is not true, it will jump to the else statement and execute the code, which is indented from that. It will only jump to the else statement if one is present. In the example, if a was not 14, it would execute world << "A is not 14" Comparison operators include: <br>'''==''' Is Equal To <br>'''!=''' Is Not Equal To <br>'''<''' Less than <br>'''>''' More than <br>'''<=''' Less or equal <br>'''>=''' More or equal ==== Switch-case statement ==== [http://www.byond.com/members/?command=reference&path=proc%2Fswitch reference] === Loops === ==== While ==== [http://www.byond.com/members/?command=reference&path=proc%2Fwhile reference] ==== For ==== [http://www.byond.com/members/?command=reference&path=proc%2Ffor%2Floop reference] ==== For (foreach) ==== [http://www.byond.com/members/?command=reference&path=proc%2Ffor%2Flist reference] === Procs === [http://www.byond.com/members/?command=reference&path=proc reference]
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