Component Function

Share your ZGE-development tips and techniques here!

Moderator: Moderators

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

Component Function

Post by Kjell » Sat Apr 26, 2014 7:47 am


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

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);

User avatar
Site Admin
Posts: 2172
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden

Post by VilleK » Sat Apr 26, 2014 4:37 pm

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