Require(Basic.Flammable) register_type{Basic.Flammable; name = "Brazier", namespace = Default,OK, so right off the bat we can see the difference: there's an extra bit before the name, the name of the Flammable class delimited by a ";". This means that the object we are about to specify inherits from this class. You can specify multiple values here, separated by commas, but we'll talk about that later. Let's continue:
profile = { invincible = 1, reflect = 1, bump_size = 20, bump_dampen = 0.0, model = "brazier.md2", skins = { normal = Skin{ name = "Just a brazier", texture = "brazier.bmp", icon = "b_icon.bmp" } } } }Pretty simple, right? But wait, where's all the complicated particle stuff we need to set up for flames? It's all in the Flammable class. If you look at the Torch class, you'll see the same thing, just a name and a profile. How does that work? Occasionally someone will look at a class find out what its values are. For example, the engine often needs to know whether a class has an alert handler or not, and what it is. When this happens to a class that inherits from another, the engine will look in that other class if it doesn't find what it needs in the first one. So for example, the engine might look at the Torch to see if it handles the particle_bumped alert -- the torch doesn't do this itself, but it inherits from Flammable, which does. This also applies to methods; the following will work, even if the Torch type doesn't define an "ignite" method itself:
foo = Torch(...) foo:ignite()It will work for a Brazier as well, the way we've defined it above. Which brings us to the point: the Flammable class defines a "new" method that starts the burning process, and since our Brazier doesn't define that method, the engine reverts to the one that Flammable provides. -- ElminI - 13 Apr 2004
Topic ZippyInheritanceGuide . { Edit | Attach | Ref-By | Printable | Diffs | r1.1 | More } |
Revision r1.1 - 13 Apr 2004 - 22:18 GMT - ElminI Parents: WebHome > MakingZippyObjects > ZippyScriptingGuide |
Copyright © 1999-2003 by the contributing authors.
All material on this collaboration platform is the property of the contributing authors. Ideas, requests, problems regarding EgoWiki? Send feedback. |