This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
petsh's profile picture

A failed MD5 API

Started by petsh, 16 June 2015 - 05:38 PM
petsh #1
Posted 16 June 2015 - 07:38 PM
Hi, I started a project for an MD5 Hashing API and i'm getting some weird errors
the project devel went well, I tested my code successfully with Cygwin LUA compiler
the weird problem started when I tryed it with computercraft

The MD5 Api is http://pastebin.com/H0f0N1VL The api contains LuaBit v0.4 a bitwise operation lib for lua.

and the Startup is http://pastebin.com/8SF7AG51

The Result is :

startup:24: attempt to index ? ( a boolean value )
From there i'm lost, just, lost.

line 24 calls the MD5 Calculation function :

print(md5.CalcHash("pass"))
Lyqyd #2
Posted 16 June 2015 - 07:48 PM
The os.loadAPI function returns a Boolean value indicating success or failure of the loading of the API. It does not return a table of the functions in the API. Essentially, you're going to be unable to use the loaded API since your program will see that Boolean value you created after the API loaded. Remove the `md5 =` on the first line.
Creator #3
Posted 16 June 2015 - 09:02 PM
os.loadAPI does not behave like require. require would return the table. However, loadAPI load the table into the global environement. You just access it through md5.
petsh #4
Posted 17 June 2015 - 02:58 PM
Thank you :D/>
I didnt expect this to be the cause :D/>