Jump to content




Check the whole drive for a file named "Newapi", and import it as an API


  • You cannot reply to this topic
3 replies to this topic

#1 Lua.is.the.best

  • Members
  • 76 posts

Posted 08 April 2014 - 02:00 AM

I couldn't do it the normal way.
I got:

Quote

File not found
testprg:2: attempt to index ? (a nil value)
Running dir:

Quote

Newapi testprg
The one underlined is the one I tried to load.
testprg:
os.loadAPI("Newapi")
Newapi.getInfo()
Newapi.getExtendedInfo()
--While loop constantly checking a number
while true do
wait(5)
Newapi.launchNumberGen(21,29,37,45,66,"Lucky!","Unlucky!")

I have all 3 defined (and launchNumberGen is supposed to have all those variables :o)
If you need to I would probably get the Newapi source code from its file :P

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 08 April 2014 - 02:36 AM

previously I had a similar problem which I solved by making a file system iterator.

Usage:
for path,file in fileSystemIter() do
  if file == "newapi" then
	os.loadAPI(path..file)
  end
end

Edited by theoriginalbit, 08 April 2014 - 02:37 AM.


#3 Lua.is.the.best

  • Members
  • 76 posts

Posted 08 April 2014 - 09:48 PM

Added 6 lines "if not http", 2 lines (get and load the iterator as an API), and 5 lines (usage).
13 lines added :P
I owe you a 32e*924e(12481284182481284*23857239587239587) TB SSD!
xD just joking, but you really deserve 48 of the world's largest and fastest SSD :P
Edit: I deny that now.. It errored on line 8..
Also a file not found..
Edit: Aha, probably because I loaded it as an API :o

Edited by Lua.is.the.best, 08 April 2014 - 09:55 PM.


#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 09 April 2014 - 12:35 AM

oh oops, sorry, was so long ago I forgot, you'd do this
for fullpath,file in fileSystemIter() do
  if file:lower() == "newapi" then
	os.loadAPI( fullpath )
  end
end

the first variable returned is the full path including filename. the second is the filename so you can easily check.

Edited by theoriginalbit, 09 April 2014 - 12:43 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users