Ulysses

Ulysses Stuff => General Chat & Help and Support => Topic started by: Sir Klutch on April 05, 2017, 07:18:52 PM

Title: Attempt to call method 'find' a nil value
Post by: Sir Klutch on April 05, 2017, 07:18:52 PM
Hello, I am receiving this error from a custom ulx motd menu everytime you join the server.
Code: [Select]
[ERROR] addons/ulx/lua/ulx/modules/cl/motdmenu.lua:78: attempt to call method 'find' (a nil value)
  1. fn - addons/ulx/lua/ulx/modules/cl/motdmenu.lua:78
   2. func - addons/ulib/lua/ulib/client/cl_util.lua:22
    3. unknown - lua/includes/extensions/net.lua:32

The user who wrote this code is MrPresident. The code can be found here;
https://forums.ulyssesmod.net/index.php/topic,6113.msg29952.html#msg29952

The error is within
Code: [Select]
function ulx.rcvMotd( isUrl_, text )
isUrl = isUrl_
if not isUrl then
ULib.fileWrite( "data/ulx_motd.txt", text )
else
if text:find( "://", 1, true ) then
url = text
else
url = "http://" .. text
end
end
end

Help would be greatly appreciated!
Title: Re: Attempt to call method 'find' a nil value
Post by: MrPresident on April 05, 2017, 07:48:14 PM
This code is 4 years old. It's not surprising that it doesn't work.

What exactly are you trying to do?
Title: Re: Attempt to call method 'find' a nil value
Post by: Sir Klutch on April 05, 2017, 09:08:51 PM
Fix the error. Everything works as intended to.
Title: Re: Attempt to call method 'find' a nil value
Post by: MrPresident on April 05, 2017, 09:37:44 PM
You fixed it? What did you do to fix it?
Title: Re: Attempt to call method 'find' a nil value
Post by: Sir Klutch on April 05, 2017, 09:39:11 PM
Lol, sorry if you misunderstood. I did not fix the error, you asked 'What exactly are you trying to do?' and I said fix the error. I could probably gut it and everything would be fine. Also, I could perhaps add a conditional to make sure text exists, is a string, and has a .find method

Code: [Select]
if not ( ( text ) and ( type( text ) == "string" ) and ( text.find) ) then return end
Would most likely fix the error, yes. Although I cannot find where the function is being called.


Title: Re: Attempt to call method 'find' a nil value
Post by: Sir Klutch on April 05, 2017, 09:56:31 PM
I went ahead and gutted it.