![]() ![]() """ def basetype_setup ( self ): """ Setup character-specific security. Here is whereĭefaultCharacter is imported from inside _init_.py:Ĭlass DefaultCharacter ( DefaultObject ): """ This implements an Object puppeted by a Session - that is, a character avatar controlled by an account. We could just look at the documenation to find out where we can lookĪt our DefaultCharacter parent. This file just basically imports useful things from all overĮvennia so you can more easily find them in one place. The intention is to make it easier to remember where to find stuff. Look at the contents of the evennia folder, there is no DefaultCharacter anywhere! This isīecause Evennia gives a large number of optional “shortcuts”, known as the “flat” API. Now, remember that our characters.py module did from evennia import DefaultCharacter. See this overview about the different ways to Need is usually easier and more readable. You would then have to enter the fullĮ(.) every time you use it. Want to import each component separately. This is practical if want a lot of stuff from that utils.py module and don’t You could also do from evennia.utils import utils. In your code youĬould then just call justify(.) to access its functionality. To, for example, import the text justify function fromĮvennia/utils/utils.py you would do from import justify. The structure of the library directly reflects how you import from it. Library is covered by our directory overview. It’s set up byĮvennia as a good place to find modules when the server starts. ![]() This is what you are accessing when you do from evennia import. There are some docs but most of those have to do with theĭistribution of Evennia and does not concern us right now. At the top of the file you findĮvennia / _init_. Without knowing that we won’t know what to override. ![]() Right now we don’t know much about DefaultCharacter Let’s go on an expedition up the inheritance tree. And those can in turn also have children … Have many different Character classes, all inheriting from DefaultCharacter but changing different The heavy lifting and only tweak the things we want to change. This is very practical: It means that we can let the parent do And if we add something that already existed in the parent, our child-version will The moment we add new things to Character, these will take ![]() Since our child, Character is empty, its functionality is exactly And that in turn may inherit codeįrom its parent(s) and so on. That the code is inherited from its parent, DefaultCharacter. The answer to the question “where is the code?” is Inheritance and is another fundamental concept. Means that the class Character is a child of the class DefaultCharacter. It is ignored completely by Python and is only useful to help guide a human to Producing online help about the function/method/class/module. Doc strings are read by Python and is used for When they appear on their own like this, at the top of a python module,Ĭlass or similar they are called doc strings. Those triple-quoted strings are used for strings that Read on.įirstly, in the same way as the little hello.py we did in the first part of the tutorial, this isĪn example of full, multi-line Python code. ‘emptiness’ is an illusion caused by something called inheritance. Has at least the key property and the method msg! Where is the code? The answer is that this But from what we have used already we know it Would think a Character had no functionality at all. There is Character, the last part of the path. """ (Doc string for module) """ from evennia import DefaultCharacter class Character ( DefaultCharacter ): """ (Doc string for class) """ pass Instructions) in a file editor or in a new terminal/console. Open and look at your game folder (named mygame if you exactly followed the Getting Started It starts looking at a place that Evennia has set up for you - namely Your hard drive (known as modules) as well as folders (known as packages) as objects that youĪccess with the. This is a path exactlyĭescribing where to find the python code describing this class. You’ll recognize this from when we imported world.test in part one. The string '' we got from the type() function is not arbitrary. You’ll be writing your own class soon! The important thing to know here is how classes and objects To start, all characters will be instances of They,Īs another example: “Christine is a Character”, or “Christine is an instance of There can be other dogs too, such as Butch and Fifi. Coders wouldĪlso say, “Fido is an instance of Dog”. So in “Fido is a Dog”, “Fido” is an object–a unique thing–and “Dog” is a class. Object: A thing, defined as an instance of a class. Class: A description of a thing, all the methods (code) and data (information) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |