Jump to content




Cant Load API?


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

#1 Zenon

  • Members
  • 50 posts

Posted 20 July 2015 - 01:28 AM

Hi All! I made myself a few functions that I always seem to be using, and put them into a program that I am using as an API. My own computer that I made the API on will work, however any other computers will draw errors from it; "attempt to index nil ?" Run it and see for your self

Program Code:
Spoiler
"API" Code:
Spoiler

Anyone know whats up and how to fix it? Thanks!

#2 Waitdev_

  • Members
  • 432 posts
  • LocationAdelaide

Posted 20 July 2015 - 01:32 AM

you never loaded the api in the first place when you wrote 'os.unloadAPI()' from here:

View PosttheMCcm, on 20 July 2015 - 01:28 AM, said:

--------------------------------------------------
--API Load--
file = fs.exists("themccm")
if file == false then
fs.makeDir("themccm")
end
file = fs.exists("themccm/API")
if file == false then
shell.run("pastebin", "get", "5ww6Pb8i", "themccm/API")
end
os.unloadAPI("themccm/API") --you didn't load the api before this
os.loadAPI("themccm/API")

Edited by Wait_, 20 July 2015 - 01:34 AM.


#3 Zenon

  • Members
  • 50 posts

Posted 20 July 2015 - 01:36 AM

View PostWait_, on 20 July 2015 - 01:32 AM, said:

you never loaded the api in the first place when you wrote 'os.unloadAPI()' from here:

View PosttheMCcm, on 20 July 2015 - 01:28 AM, said:

--------------------------------------------------
--API Load--
file = fs.exists("themccm")
if file == false then
fs.makeDir("themccm")
end
file = fs.exists("themccm/API")
if file == false then
shell.run("pastebin", "get", "5ww6Pb8i", "themccm/API")
end
os.unloadAPI("themccm/API") --you didn't load the api before this
os.loadAPI("themccm/API")
That isnt the issue, even without unloading it if you are on another comp, even if it has the api, it wont work

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 20 July 2015 - 01:41 AM

So which line, exactly, is throwing the error?

Is your original computer still able to run the code ok after you reboot it?

#5 Zenon

  • Members
  • 50 posts

Posted 20 July 2015 - 01:44 AM

View PostBomb Bloke, on 20 July 2015 - 01:41 AM, said:

So which line, exactly, is throwing the error?

Is your original computer still able to run the code ok after you reboot it?
Any lines with the functions I defined in the API, starting with 38 but if I redifine the function that was causing the error in the program (in the case of line 38; clear()) it will work just fine.

Edit: No, the original cant after rebooting it either

Edited by theMCcm, 20 July 2015 - 01:49 AM.


#6 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 20 July 2015 - 01:55 AM

Lets see if I can list some errors.

Line 38+84: Should be API.clear() since you're loading the api as a table called API. Just calling clear will give you an attempt to call nil error.
Lines 78&79+87+95-98+101+115-116+119+121+125+131+132: Same error. API.lineUp()
Lines 90&91+111&113+128: API.lineDown()


The reason why the original computer worked and the others didn't: You ran your api code and the functions were loaded into the global environment.
If you notice, you can run the functions on the current code (Without the functions inside the code, the api functions) if you run the api program first.

#7 Zenon

  • Members
  • 50 posts

Posted 20 July 2015 - 01:57 AM

Wait! I figured it out, you need to do "API.clear()" etc. instead of "themccm/API.clear()"

View PostDragon53535, on 20 July 2015 - 01:55 AM, said:

Lets see if I can list some errors.

Line 38+84: Should be API.clear() since you're loading the api as a table called API. Just calling clear will give you an attempt to call nil error.
Lines 78&79+87+95-98+101+115-116+119+121+125+131+132: Same error. API.lineUp()
Lines 90&91+111&113+128: API.lineDown()


The reason why the original computer worked and the others didn't: You ran your api code and the functions were loaded into the global environment.
If you notice, you can run the functions on the current code (Without the functions inside the code, the api functions) if you run the api program first.

Thanks, figured that out just a second ago lol





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users