Lua Libraries.
2 posters
RigidChips :: Rigid-Chips :: Tutorials
Page 1 of 1
Lua Libraries.
Lua Libraries are a very helpful thing. They allow you to store functions, values, whatever you want, in files so that you don't have to write them in every model you make.
For example, the limit function:
Downloading:
Some members, (bwansy and I), have our Lua libraries up on the forums. Most models we release require our libraries, so you need them to use the models.
Most Lua libraries will come in .zip files, because they can be multi-filed. So, to install them, just extract the files, and make sure they are in the proper file path. I.e: Most people will supply a filepath when they release their libraries (mine is "Juz\<FILES>").See General Practice 1. And violĂ !
Using:
Using libraries is very simple. At the top line of your Lua code, place:
Creating:
Creating libraries is very simple. Put all of the things you want in the file, and save it in the file path you want.See General Practice 2.
General Practice:
For example, the limit function:
- Code:
function limit(val,min,max)
return math.min(math.max(val,min),max)
end
Downloading:
Some members, (bwansy and I), have our Lua libraries up on the forums. Most models we release require our libraries, so you need them to use the models.
Most Lua libraries will come in .zip files, because they can be multi-filed. So, to install them, just extract the files, and make sure they are in the proper file path. I.e: Most people will supply a filepath when they release their libraries (mine is "Juz\<FILES>").See General Practice 1. And violĂ !
Using:
Using libraries is very simple. At the top line of your Lua code, place:
- Code:
require("<FILE PATH\FILE>")
Creating:
Creating libraries is very simple. Put all of the things you want in the file, and save it in the file path you want.See General Practice 2.
General Practice:
- When releasing libraries, name the file path as either your name, or "Lua\<NAME>".
- Try and save the file as a *.lua file (you can save it as something else, but try not to).
- If your library has a lot of files, create a single file that requires all the others by itself (Mine is index.lua). Then you only have to require one file!
- If you have a library for something very specific, like drawing lines on the screen, then you can store all of those functions inside a table, to keep them organised.
JHaskly- Admin
- Posts : 235
Join date : 2010-07-16
Age : 28
Location : Brisbane
Re: Lua Libraries.
What about setting the file path so RC knows where to look? I want to say there was a .bat involved.
MrSparks- Tank
- Posts : 73
Join date : 2012-01-05
Age : 34
Location : Michigan
RigidChips :: Rigid-Chips :: Tutorials
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum