Ulysses

General => Developers Corner => Topic started by: bender180 on May 22, 2013, 03:05:11 PM

Title: ulx.convar
Post by: bender180 on May 22, 2013, 03:05:11 PM
okay so these convars are killing me i can for the life of me figure out whats going on

heres the code
Code: [Select]
local Reports_Enabled = "1" -- Set this to 0 if you want to disable this script
local Reports_In_Logs = "1" -- Set this to 0 if you don't want to log reports in daily logs
local Reports_Interval = "120" -- The player can only report once then he need to wait this interval (seconds) before reporting again. 0 = no delay (not recommended)
local Reports_Folder = "ulx_logs" -- By default, in the same folder as others log files
-- End of config

local Reportenabled = ulx.convar( "ReportEnabled", Reports_Enabled, "<0-1> - Set this to 0 if you want to disable the report command.", ULib.ACCESS_SUPERADMIN)
local ReportInLogs = ulx.convar( "ReportInLogs", Reports_In_Logs, "<0-1> - Set this to 0 if you don't want to log reports in daily logs.", ULib.ACCESS_SUPERADMIN)
local ReportInterval = ulx.convar( "ReportInterval", Reports_Interval, "<time> - Time between 2 reports from the same player. Set this to 0 to disable.", ULib.ACCESS_SUPERADMIN)
local ReportFolder = ulx.convar( "ReporTFolder", Reports_Folder, "<folder> - The folder where to save the reports file.", ULib.ACCESS_SUPERADMIN)

The console is spitting out this error
Code: [Select]
[ERROR] addons/ulx/lua/ulx/modules/sh/report.lua:13: attempt to call field 'convar' (a nil value)
  1. unknown - addons/ulx/lua/ulx/modules/sh/report.lua:13
   2. include - [C]:-1
    3. unknown - addons/ulx/lua/ulx/cl_init.lua:17
     4. include - [C]:-1
      5. unknown - addons/ulx/lua/ulib/modules/ulx_init.lua:4
       6. include - [C]:-1
        7. unknown - addons/ulib/lua/ulib/cl_init.lua:23
         8. include - [C]:-1
          9. unknown - addons/ulib/lua/autorun/ulib_init.lua:5

Title: Re: ulx.convar
Post by: Megiddo on May 22, 2013, 05:17:49 PM
Are you setting ulx to something before hand? Because it's saying the function doesn't exist.
Title: Re: ulx.convar
Post by: bender180 on May 22, 2013, 05:29:27 PM
im sorry but im not sure what you mean...
Title: Re: ulx.convar
Post by: Megiddo on May 22, 2013, 07:59:54 PM
I'm trying to say something else is wrong in your file. It works fine if you run those commands in console:

Code: [Select]
lua_run  Reports_Enabled= "1"-- Set this to 0 if you want to disable this script
> Reports_Enabled= "1"-- Set this to 0 if you want to disable this script...
lua_run Reportenabled = ulx.convar( "ReportEnabled", Reports_Enabled, "<0-1> - Set this to 0 if you want to disable the report command.", ULib.ACCESS_
SUPERADMIN)
> Reportenabled = ulx.convar( "ReportEnabled", Reports_Enabled, "<0-1> - Set this to 0 if you want to disable the report command.", ULib.ACCESS_SUPERA
DMIN)...
Title: Re: ulx.convar
Post by: JamminR on May 22, 2013, 08:20:43 PM
Perhaps his script is somehow running before ulx.convar function has been set up in ULX init?
Title: Re: ulx.convar
Post by: Megiddo on May 23, 2013, 08:36:51 AM
He has it as a module correctly though, and I can see that from the stack trace. I even verified that I didn't flub something in the ULX module loading order.
Title: Re: ulx.convar
Post by: bender180 on May 23, 2013, 12:08:05 PM
could the error be that i didnt put it with in a function its just at the top of the file?
Title: Re: ulx.convar
Post by: Megiddo on May 23, 2013, 01:44:14 PM
Don't think so. Please attach the file so we can look at it closer.
Title: Re: ulx.convar
Post by: Megiddo on May 23, 2013, 01:45:32 PM
Wait... I think I know what the problem is. That function doesn't exist on the clientside. Wrap the ulx.convar() bits in a "if SERVER then ... end".
Title: Re: ulx.convar
Post by: bender180 on May 23, 2013, 04:23:59 PM
Thanks that fixed it.
Title: Re: ulx.convar
Post by: bender180 on May 23, 2013, 04:43:19 PM
Unrelated but what did ulx.OnDoneLoading() become after the rewrite?
Title: Re: ulx.convar
Post by: Megiddo on May 24, 2013, 08:08:12 AM
It became a hook -- which is what it should have been to start with. I think we only kept ulx.OnDoneLoading() for as long as we did for backward compatibility's sake. The hook name is "ULXLoaded".