May 13, 3:47 pm Procs ```proc/A() return 123 ``` Calling A will return 123 ```proc/A(a=321) return 123 + a ``` You're now creating arguments for the proc. By calling A() with no argument, it will default to 321 ```var i = A() // i = 444 ``` ```var i = A(3) // i = 126 ``` ```proc/ExampleFunction(a,b,c) return list(a,b,c) ``` The above example is a proc that takes 3 arguments. This proc will return a list, which contains said objects. If any arguments are not given, it will result in a null value in the list and arguments. ```mob/Login() var list/l = list(7,3,9,2,1,5) SortSmall2Big(l) for(var/i in l) world << iproc/SortSmall2Big(list/l) //This is a global proc, this can be called anywhere. var len = l.len // lists have a variable called len, it states the current length of the list. for(var/a = 1 to len) // Loop from 1 to the lists length for(var/b = 1 to len) // Do it again, but cooler. if(l[a] < l[b]) // Compare, is 9 > 3? Swap them! l.Swap(a,b) // Swapping the positions. This is a built-in function for lists. ```
 May 14, 12:23 am Type Inheritance ```mob/npc/var/tmp list/traitsmob/npc/kyle name = "Kyle" traits = list("Strong","Lazy") ``` We've defined a mob named Kyle under mob/npc ```mob/npc/proc/GetTrait(position) if(position > traits.len || 1 > position){return null} return traits[position] ``` The proc GetTrait() will grab the trait at whatever position you pass into the argument. ```mob/Login() var mob/npc/kyle/k = new // We create a variable that points to mob/npc/kyle // and give it the name k and create it via new world << k.GetTrait(1) // Outputs "Strong" via k's proc GetTrait() world << k.GetTrait(2) // Outputs "Lazy" via k's proc GetTrait() var mob/npc/d = new // can even create the base type and dynamically create things at run-time/compile-time. d.name = "Koz" d.traits = list("Lazy","Lazi but with an i") world << d.GetTrait(1) // Outputs "Lazy" via d's proc GetTrait() world << d.GetTrait(2) // Outputs "Lazi but with an i" via d's proc GetTrait() // Below won't work. // the variable name is defined under atom so it's inherited by everything. // the variables traits however only exists under /mob/npc, not /mob. // the same issue with the proc GetTrait(), it only exists under /mob/npc. // the code below will throw an error because of it at compile-time. var mob/m = new m.name = "Sugma" m.traits = list("Basket","Ballz") world << "[m.name] [m.GetTrait(2)]" ``` There's also datums, which are like the opposite of atom. ```color var r = 255 var g = 255 var b = 255mob/Login() var color/c = new world << "RGB: ([c.r],[c.g],[c.b])" ``` You use datums to encapsulate data, they can't be placed on the map and are purely data.