RiftWorks
Найти
Персональное меню
Вы не представились системе
user-interface-preferences
Персональные инструменты
Обсуждение
Вклад
Создать учётную запись
Войти
Параметры
notifications
Редактирование:
Understanding SS13 code
(раздел)
associated-pages
Статья
Обсуждение
Просмотры
Читать
Править
Править код
История
Внимание:
Вы не вошли в систему. Ваш IP-адрес будет общедоступен, если вы запишете какие-либо изменения. Если вы
войдёте
или
создадите учётную запись
, её имя будет использоваться вместо IP-адреса, наряду с другими преимуществами.
Анти-спам проверка.
Не
заполняйте это!
==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.
Описание изменений:
Обратите внимание, что все изменения в RiftWorks рассматриваются как выпущенные на условиях лицензии Creative Commons Attribution-NonCommercial-ShareAlike (см.
RiftWorks:Авторские права
). Если вы не хотите, чтобы ваши тексты свободно распространялись и редактировались любым желающим, не помещайте их сюда.
Вы также подтверждаете, что являетесь автором вносимых дополнений или скопировали их из источника в общественном достоянии или под совместимой лицензией.
Не размещайте без разрешения материалы, защищённые авторским правом!
Отменить
Справка по редактированию
(в новом окне)