I'm a bit unsure how to write a condition which returns, how many instances of a certain type of model currently exist.
How is this done? Any ideas?

Moderator: Moderators
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" ViewportRatio="3" FileVersion="2">
<OnUpdate>
<KeyPress Keys="{" RepeatDelay="0.25">
<OnPressed>
<ZExpression>
<Expression>
<![CDATA[Foo.Position.X = App.MousePosition.X*7.36;
Foo.Position.Y = App.MousePosition.Y*4.14;
createModel(Foo);]]>
</Expression>
</ZExpression>
</OnPressed>
</KeyPress>
</OnUpdate>
<OnRender>
<RenderText TextFloatRef="FooCount" X="-0.9" Align="1"/>
</OnRender>
<Content>
<Model Name="Foo">
<OnSpawn>
<ZExpression Expression="FooCount++;"/>
</OnSpawn>
<OnRender>
<RenderSprite/>
</OnRender>
<OnRemove>
<ZExpression Expression="FooCount--;"/>
</OnRemove>
</Model>
<Variable Name="FooCount"/>
</Content>
</ZApplication>
I'm afraid not ... the engine doesn't track this ( internally ), so you need to do-it-yourself.jinxtengu wrote:Isn't there another way of doing it without adding and subtracting from a variable when you spawn or remove a model?