Jump to content




API Load not working


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

#1 gknova61

  • Members
  • 74 posts

Posted 28 November 2012 - 04:35 PM

I've had this problems on allot of my programs that load an API that does some higher-level things, what am I doing wrong?
Program:
http://pastebin.com/XR9C8z75

And the API it uses (must be in the apis/config path on your computer (it's where osloadapi is pointed to), not the rom!):
http://pastebin.com/fkcMT9CE

I keep getting the attempt to call nil error on the program when i'm using os load api and yes i've made sure that the config api is in my apis/config folder on my computer. The only way i can even use an API currently is to put it in my rom but i don't wana get into the habit of that since i normally play on a server without FTP access ;)

And for anyone with extra time, my other thread in 'Ask a Pro' on an unrelated problem with what looks to be the fs api is not exactly answered yet :(:
http://www.computerc...n-this-program/

#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 28 November 2012 - 06:48 PM

I see that you are trying to write to the "apis" folder. That's part of ROM, so it can't be modified with script. If you want to have an updateable API, you need to have it either go into root, or a designated directory that you create. And yes, you can do that, just lead the full path when loading the API. (such as: os.loadAPI("testDir/config"), and it will still retain the proper function call.)

I did fix your program, and it will run. The problem was that you were trying to write to the ROM....
Spoiler


#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 28 November 2012 - 06:56 PM

What? rom/apis is part of rom, but a folder called apis in the root of the drive isn't.

#4 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 28 November 2012 - 07:03 PM

I think that since apis is an alias for rom/apis, it might be having that problem. The program ran just fine without doing that. Although, my sleepless mind just realized that I did not test if apis was an existing directory. What you should do, if going through a user created apis foler, is this block of code somewhere before checking if apis/config exists:
if not fs.exists(apis) then
    fs.mkDir("apis")
end


#5 Luanub

    Lua Nub

  • Members
  • 1,135 posts
  • LocationPortland OR

Posted 28 November 2012 - 08:40 PM

Once the folder is created another good idea would be to use "/apis/config" as the path instead of "apis/config". That will ensure that it is pointing to the correct path.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users