ATG
Junior Member
Posts: 79
|
Post by ATG on Oct 4, 2020 1:04:19 GMT
I want to call a function from another file instead copy and paste so much codes to my script.
I am trying to use a open source crc32 lua file to generate checksum and verify it. the file from this link: https://gist.github.com/SafeteeWoW/080e784e5ebfda42cad486c58e6d26e4
if i put this in my script:
require (scriptPath() .. "lib/crc32.lua" ) I got Runtime error ".... not found: no field package.preload"
If use 'dofile'
dofile (scriptPath() .. "lib/crc32.lua" ) I got Runtime error "... attempt to index global 'LibDeflate'( a nil value)
if I do copied and pasted the crc32 codes to my script it will work
function verifyIDs() --hard code the user id to the script
userEmailCRC = xxx
s = getUserID() crc32 = LibDeflate:Crc32(s, 0) --< HERE IS GIVING ME ERRORS
if (userEmailCRC == crc32) then toast('VALID EMAIL ID\n\n\nContinue to run')
else scriptExit('INVALID EMAIL ID.\n\n\nYour Ankulua Pro ID is mismatch on the script.') end end
Please advise, how to fix or do that?
|
|
|
Post by Mercobots on Oct 4, 2020 2:10:21 GMT
hello for what i see on crc32.lua lib, just delete this
s="" t={} local table_insert = table.insert for i=1,10000 do table_insert(t, "12313213213jojelasdfj;askljfldasgfjd;sajf") end
s = table.concat(t)
print("string len: ", #s) t = os.clock()
crc32 = LibDeflate:Crc32(s, 0)
print("time took for crc32: ", os.clock() - t)
print("crc32: "..crc32)
print("---------------------------------------------")
is a test from the author, and add this line at the end
return LibDeflate
now at your code you need to point where this lib is
package.path = scriptPath() .. 'lib/?.lua;' .. package.path
to use it just do this
local LibDeflate = require('LibDeflate') print(LibDeflate:Crc32())
Note: in this scenario, lib file is called LibDeflate.lua and is located at root/lib/
|
|
ATG
Junior Member
Posts: 79
|
Post by ATG on Oct 4, 2020 2:44:00 GMT
followed your instructions and it is working for me
|
|