Component Function

Share your ZGE-development tips and techniques here!

Moderator: Moderators

Post Reply
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Component Function

Post by Kjell »

:idea:

In case you don't like the syntax of calling a component, you can write your own classic C-style wrapper function using the ZLibrary component.

For example, when you want to delete a model using the RemoveModel component, you currently have to write the following expression.

Code: Select all

@RemoveModel(Model: myModel);
However, using a ZLibrary you can make this as follows.

Code: Select all

removeModel(myModel);
The only thing you have to do is to add a ZLibrary component containing the following function declaration in App:OnLoaded.

Code: Select all

void removeModel(model m)
{
  @RemoveModel(Model: m);
}
K
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Nice :). Similarly you could make saveToFile(filename,array)/loadFromFile functions that encapsulates File components etc. We could wrap it up in a "Useful" lib and add it to the Library.xml.
Post Reply