BASIC

Author Topic: How do I make and include Userlibs?  (Read 2813 times)

Offline Uncle

  • Mr. Drawsprite
  • **
  • Posts: 75
    • View Profile
    • www.urbaninteractive.net
How do I make and include Userlibs?
« on: 2009-Aug-09 »
Stoopid question alert! I've searched the forum but can't seem to find much info on UserLibs.  I was wondering what exactly are Userlibs, how can I create them, and how do I include them in my project?  Are these libraries written in GLB that I can include in my project e.g. if I wrote a sprite system UserLib I could just plug it into multiple projects?  Are these libraries completely separate from the source code they are plugged into i.e. I could have the same variable name in both the main source and userlibs, but they would be treated as two separate variables? 

Cheers for looking,

Unc


Offline trucidare

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1377
  • Bachelor of Fail
    • View Profile
Re: How do I make and include Userlibs?
« Reply #1 on: 2009-Aug-09 »
Open your Project then you userlib (gbal of other gbas) then rightclick and add to project. thats all. now you can use functions from userlibs and other source files.
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Offline amarliani

  • Mr. Polyvector
  • ***
  • Posts: 115
    • View Profile
Re: How do I make and include Userlibs?
« Reply #2 on: 2009-Aug-09 »
Quote
I was wondering what exactly are Userlibs, how can I create them, and how do I include them in my project?

Userlibs are simply GLB extension libs made by users themself. To create one, just write your code, than select "Tools/Compress file to Library" from  the GLB menu. (sorry, the menu might actually read a bit different, this is only a translation of my german menu options). Trudicare already explained how to use Userlibs in your projects.

Quote
Are these libraries written in GLB that I can include in my project e.g. if I wrote a sprite system UserLib I could just plug it into multiple projects?

Yes! Thats exactly what userlibs are intended for. 

Quote
Are these libraries completely separate from the source code they are plugged into i.e. I could have the same variable name in both the main source and userlibs, but they would be treated as two separate variables? 

The code is separated from your project, and even more interesting, even not available to any user. So you can hand over (sell?) libs without making your code readable for anyone. Variables: Ahh.. bit more complicated.  As long as your projects variables are LOCAL, yes, you can use the same names. If your project declares a GLOBAL variable with the same name, you will certainly run into problems. Therefore it would be wise to use some sort of unique naming conventions for your lib's variables, e.g. all starting with "usl_" or somthing like that.