Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 1 | create() |
| 2 | ======== |
| 3 | |
| 4 | FUNKTION |
| 5 | -------- |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 6 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 7 | protected void create(); |
| 8 | void create(); |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 9 | |
| 10 | DEFINIERT IN |
| 11 | ------------ |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 12 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 13 | allen Standardobjekten |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 14 | |
| 15 | ARGUMENTE |
| 16 | --------- |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 17 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 18 | keine |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 19 | |
| 20 | BESCHREIBUNG |
| 21 | ------------ |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 22 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 23 | Diese Funktion wird aufgerufen, wenn ein Objekt geladen oder geclont |
| 24 | wird. |
| 25 | In dieser Funktion wird das Objekt initialisiert und konfiguriert. |
| 26 | Waehrend des create() kann es einen this_player()/this_interactive() |
| 27 | geben, muss aber nicht! |
| 28 | Im create() hat das Objekt noch kein environment(). |
| 29 | create() wird nur gerufen, wenn das Objekte geclont oder explizit geladen |
| 30 | wird. Wenn es aufgrund eines inherit in einem anderen Objekt vom Driver |
| 31 | geladen wird, wird das create() nicht ausgefuehrt (s. create_super()). |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 32 | |
| 33 | RUeCKGABEWERT |
| 34 | ------------- |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 35 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 36 | keiner |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 37 | |
| 38 | BEMERKUNGEN |
| 39 | ----------- |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 40 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 41 | Erbt man von anderen Objekten, so besteht die erste Aktion innerhalb |
| 42 | von create() normalerweise darin, in diesen Objekten create() |
| 43 | aufzurufen. |
| 44 | Die Funktion kann protected oder static sein (aber nicht private). Es |
| 45 | duerfte fuer die meisten Objekte sinnvoll sein, create() protected zu |
| 46 | deklarieren. |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 47 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 48 | Um Speicher zu sparen, kann man bei Blueprints von der Konfigurierung |
| 49 | absehen (siehe Beispiel). Dies sollte man allerdings nicht bei Objekten |
| 50 | machen, von denen keine Clones erzeugt werden sollen (zB. bei Raeumen). |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 51 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 52 | Man sollte bei Abbruch des create() in BP unbedingt set_next_reset(-1); |
| 53 | rufen, da sonst die (nicht konfigurierte) BP resetten kann und dann |
| 54 | buggt. |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 55 | |
| 56 | BEISPIELE |
| 57 | --------- |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 58 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 59 | Ein Gegenstand wuerde wie folgt konfiguriert: |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 60 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 61 | .. code-block:: pike |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 62 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 63 | inherit "std/thing"; |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 64 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 65 | #include <properties.h> |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 66 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 67 | create() |
| 68 | { |
| 69 | // Wenn wir die Blueprint sind: NICHT konfigurieren! |
| 70 | // Bei normalen Raeumen oder Transportern sind diese beiden |
| 71 | // Zeilen wegzulassen!!! |
| 72 | if (!clonep(this_object())) { |
| 73 | set_next_reset(-1); // wichtig, damit die BP nicht resettet. |
| 74 | return; |
| 75 | } |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 76 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 77 | // Ansonsten die allgemeinen Eigenschaften von /std/thing |
| 78 | // konfigurieren... |
| 79 | ::create(); |
| 80 | |
| 81 | // ...und nun unsere speziellen Eigenschaften: |
| 82 | SetProp(P_NAME, "Muell"); |
| 83 | SetProp(P_SHORT, "Muell"); |
| 84 | SetProp(P_LONG, "Voellig unnuetzer Muell!\n"); |
| 85 | SetProp(P_ARTICLE, 0); |
| 86 | SetProp(P_VALUE, 0); |
| 87 | SetProp(P_GENDER, MALE); |
| 88 | } |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 89 | |
| 90 | SIEHE AUCH |
| 91 | ---------- |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 92 | |
Bugfix | 95b19bc | 2018-10-27 23:22:21 +0200 | [diff] [blame] | 93 | :doc:`create`, :doc:`reset` |
| 94 | hook(C), create(H), create_ob(H), create_super(H, reset(H) |
| 95 | create(A), reset(A) |
Zesstra | 1862697 | 2017-01-31 10:38:27 +0100 | [diff] [blame] | 96 | |
| 97 | 22.10.2007, Zesstra |
| 98 | |