Jump to content




How do you make an API on only 1 computer?


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

#1 Geforce Fan

  • Members
  • 846 posts
  • LocationMissouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension

Posted 29 October 2012 - 08:53 PM

Title says it all.

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 29 October 2012 - 09:09 PM

By only putting it on that computer? Use os.loadAPI() to load APIs that aren't in the API folder.

#3 Geforce Fan

  • Members
  • 846 posts
  • LocationMissouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension

Posted 29 October 2012 - 09:32 PM

 Lyqyd, on 29 October 2012 - 09:09 PM, said:

By only putting it on that computer? Use os.loadAPI() to load APIs that aren't in the API folder.
But how do you create the API?
ex. like how do you create what it;s going to load

#4 snoble2022

  • Members
  • 100 posts
  • LocationSomewhere near the local computer store?

Posted 29 October 2012 - 10:17 PM

I.E. Like this
Spoiler

EVERYTHING in the API must be a function or else when you load it or call from it, It will run it.

#5 Geforce Fan

  • Members
  • 846 posts
  • LocationMissouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension

Posted 30 October 2012 - 02:24 AM

How do you CREATE the api to load.

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 30 October 2012 - 02:25 AM

The post just before yours showed you how. It's a file full of functions.

#7 Geforce Fan

  • Members
  • 846 posts
  • LocationMissouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension

Posted 30 October 2012 - 02:33 AM

So just use the edit program
like "edit file" then do your API then to load it os.loadAPI("file") ;
?

#8 Luanub

    Lua Nub

  • Members
  • 1,135 posts
  • LocationPortland OR

Posted 30 October 2012 - 02:54 AM

Making an API is very simple if you can write a program you can write an API. The only difference is the API does not need to be code that runs, it just needs functions that you can call from another program and have them run.

If you're not sure what to do then either

A- look at an existing API, there are several in /rom/apis
B- Read the tutorial http://www.computerc...reating-an-api/

#9 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 30 October 2012 - 09:32 AM

1. Go into rom/apis and create a file.
2. The file must ONLY contain functions like this:
function derp()
  print("You called the derp function")
end
function readText(file)
  if fs.exists(file) then
    file = fs.open(file,"r")
    text = file.readAll()
    fs.close()
    print(text)
  else
    print(file.." does not exists!")
end
3. If it is in the rom/api, you will not need to use os.loadAPI("filename") to load it. Only use that if it is in the ID folder of the computer.
4. To use a function:
If the API file name is func, to use them you would do this:
	  func.derp()
	  func.readText("derp")
5. And that should be all!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users