Jump to content




require() AMD for CC... an API to include APIs?!

api lua utility

7 replies to this topic

#1 comp500

  • Members
  • 66 posts

Posted 19 February 2015 - 09:08 AM

require()
This is a utility function that will make working with APIs so much easier. It doesn't replace os.loadAPI(), it enhances it. You can include many APIs at once, and they are stored in a local variable, reducing conflicts:
module1, module2, module3... = require(location1, location2, location3...)
It is only around 600B when minified and can be inserted at the top of your programs. It searches for APIs, so you don't have to specify exactly where they are. If you require an absolute path (with a trailing slash), require will look just in that directory. If you require a relative path (no trailing slash), require will search in the current directory and all directories above it, for example:
-- /superstuff/awesome/lol
module1 = require("superapi")
module1.test()
-- /superapi
function test()
print("this is super")
end
require() would search:
/superstuff/awesome/superapi
/superstuff/superapi
/superapi

Another great feature is that it works with every api that works with os.loadAPI, whch means you don't need to change apis or ask the author to change them. The way they are stored in a local variable makes it even easier to use the touchpoint API:
t = require("touchpoint").new()
t:add(...)
t:draw()

Want it? To see more information and where to download it, see the https://github.com/comp500/CCSnippets for the github repository.
If you don't care about github and just want a download, minified versions are available in the releases: https://github.com/c...ippets/releases
My utilities are under the MIT license, so feel free to fork and send pull requests on the CCSnippets repository, but don't remove the license and give credit.

Please note that ComputerCraft 1.63 is required, see the github readme for more details.

To-Do list:
  • Add support for some sort of lib/ directory

Edited by comp500, 20 February 2015 - 07:49 AM.


#2 comp500

  • Members
  • 66 posts

Posted 21 February 2015 - 08:19 PM

ok.... im taking it nobody wants this....

#3 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 21 February 2015 - 10:03 PM

Or, nobody has any comments on your function. Don't take it as 'nobody likes it', it's just how things usually work with good APIs, programs and utilities here. Nobody said anything because there isn't anything bad about your function, which is good. Also, there are no suggestion which means that there is nothing to suggest as there is everything here already. I see this as a very nice and simple function to load APIs and I think it is quite good. There are some quality-products here on the forums and you'll find that they also don't have that many replies. I believe it's just because of the audience here on CC forums. Anyway, don't stop on making these kind of things and posting them on the forums. I'm sure they will help you someday, and I'm not talking about just programming ;).

Keep up the good work! :)

Edited by MKlegoman357, 21 February 2015 - 10:05 PM.


#4 comp500

  • Members
  • 66 posts

Posted 22 February 2015 - 07:21 AM

View PostMKlegoman357, on 21 February 2015 - 10:03 PM, said:

Or, nobody has any comments on your function. Don't take it as 'nobody likes it', it's just how things usually work with good APIs, programs and utilities here. Nobody said anything because there isn't anything bad about your function, which is good. Also, there are no suggestion which means that there is nothing to suggest as there is everything here already. I see this as a very nice and simple function to load APIs and I think it is quite good. There are some quality-products here on the forums and you'll find that they also don't have that many replies. I believe it's just because of the audience here on CC forums. Anyway, don't stop on making these kind of things and posting them on the forums. I'm sure they will help you someday, and I'm not talking about just programming ;).

Keep up the good work! :)
Thanks! I found that my github traffic has a steady flow of visitors :D

#5 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 24 April 2015 - 03:15 PM

How do you minify the code?

#6 Lignum

  • Members
  • 558 posts

Posted 24 April 2015 - 03:36 PM

View PostCreator, on 24 April 2015 - 03:15 PM, said:

How do you minify the code?

Tools like luamin can do this. Here's an online minifier that uses luamin as its backend.

#7 comp500

  • Members
  • 66 posts

Posted 25 April 2015 - 06:01 AM

View PostLignum, on 24 April 2015 - 03:36 PM, said:

View PostCreator, on 24 April 2015 - 03:15 PM, said:

How do you minify the code?

Tools like luamin can do this. Here's an online minifier that uses luamin as its backend.
Yup. I used to use LuaMinify (by stravant on github), but I found out luamin actually minifies much better than LuaMinify.

#8 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 25 April 2015 - 08:04 AM

View Postcomp500, on 25 April 2015 - 06:01 AM, said:

Yup. I used to use LuaMinify (by stravant on github), but I found out luamin actually minifies much better than LuaMinify.

Hmmm, strange - I always found that luamin broke my code when I minified with it. LuaMinify works perfectly - the main issue is that it generates massive variable names, though you can change that.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users