• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Rare error

Ovnyx

Member
Joined
Jul 25, 2017
Messages
163
Solutions
2
Reaction score
7
hi,
i was working on a script, and suddenly i got this error on server when trying to log in:




the thing is that i never touched login or logout .lua before this error occur any one know why is this happening

EDIT:i founded the problem and it is because in data/lib/lib.lua
i added:
Code:
dofile('data/lib/script.lua')

to use some methamethods i got there in a class and thats causing the error

is this the correct way to "include" my custom lib file to my server?


thanks in advice!

Ovnyx
 
Last edited:
Solution
the correct way is to dofile in lib/core/core.lua
but here's some code to load all files (other than core.lua itself) in the core folder
just replace everything from inside core.lua with this:
Lua:
for file in io.popen([[dir "data/lib/core" /b /aa]]):lines() do
    if file ~= "core.lua" and file:match("(%.lua)") then
        dofile("data/lib/core/".. file)
    end
end
the correct way is to dofile in lib/core/core.lua
but here's some code to load all files (other than core.lua itself) in the core folder
just replace everything from inside core.lua with this:
Lua:
for file in io.popen([[dir "data/lib/core" /b /aa]]):lines() do
    if file ~= "core.lua" and file:match("(%.lua)") then
        dofile("data/lib/core/".. file)
    end
end
 
Solution
thanks for your answer, i tried but i get the "error with isPriemium method, when calling its nil"
 
the code i gave will only work on windows, don't know if you're using windows
check your player.lua for Player.isPremium, if it's there then player.lua isn't loading for some reason
could also be that your lib has a syntax error which leads to global.lua not loading (which is what ultimately loads player.lua), that's probably why it says Player.isPremium is nil
OR your login.lua is actually using a nil object and trying to execute a method on it, make sure your function arguments for onLogin are onLogin(player), and make sure the isPremium call is player:isPremium()
 
ok going to check, so i can create a class and save it as lua in core folder then call it in core.lua? to create diferent instances of that object?

thanks in advice!
 
Back
Top