GetDefaultByType
static readonly<Actor> GetDefaultByType(class<Actor> type)
Note: This feature is for ZScript only. |
Use this to find the default property of a class, rather than those of any particular actor.
Note that this is sensitive to whether the caller has a backpack, so it is not necessary to specifically check for a backpack and backpackmaxamount - checking maxamount will cover both situations.
Class example { static void getImpRadius() { class<Actor> cls = "DoomImp"; int impRadius = Actor(GetDefaultByType(cls)).Radius; console.printf("Imp default radius is: %d", impRadius); } }
Custom property defaults can also be retrieved by using the name of the variable that the property refers to. This class retrieves the custom DropCategory property of the class that represents a treasure dropped by a monster:
class MonsterDrop : Inventory {
String myCategory;
property DropCategory: myCategory;
default {
MonsterDrop.DropCategory "Jewellery";
}
}
Class example { static void getMonsterDropCategory(String dropClass) { class<Actor> cls = dropClass; String dropCategory = MonsterDrop(GetDefaultByType(cls)).myCategory; console.printf("Drop category for %s is: %d", dropClass, dropCategory); } }
This article is issued from Zdoom. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.