Hi,
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?
condition check for number of models
Moderator: Moderators
Re: condition check for number of models
Hi junxtengu,
Maybe something like this ( left-click spawns a clone ) ?
K
Maybe something like this ( left-click spawns a clone ) ?
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>
Re: condition check for number of models
Thanks Kjell, but Isn't there another way of doing it without adding and subtracting from a variable when you spawn or remove a model?
Re: condition check for number of models
Hi,
K
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?
K
Re: condition check for number of models
That's good to know, and It gives me peace of mind. I thought I might have missed something in the documentation.