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