Ulysses

General => Developers Corner => Topic started by: ambro on April 08, 2013, 02:02:09 PM

Title: Standalone addon, visibility to ULX functionality?
Post by: ambro on April 08, 2013, 02:02:09 PM
I have an addon for ULX I've been working that uses ULX functionality and is currently stored in /garrysmod/addons/ulx/lua/ulx/modules/sh/

I'd like to move it to: /garrysmod/addons/myaddonname/lua/autorun/mymodule.lua

I thought I did everything correctly but I'm getting:

[ERROR] addons/ambrosutilitymod/lua/autorun/ambro_util.lua:29: attempt to index global 'ulx' (a nil value)
  1. unknown - addons/ambrosutilitymod/lua/autorun/ambro_util.lua:29

Relevant line, pseudo code:

Code: [Select]
local CATEGORY_NAME = "Utility"

function ulx.rules( calling_ply, target_plys, command )
do stuff here....
end
local rules = ulx.command( CATEGORY_NAME, "ulx rules", ulx.rules, "!rules" )
rules:addParam{ type=ULib.cmds.PlayersArg }
rules:defaultAccess( ULib.ACCESS_ADMIN )
rules:help( "Broadcasts the server rules to the target(s)." )

How do I make this standalone addon have the same visibility let's say, fun.lua or utility.lua has without having the file in that directory?

The reason I want to do this is so that in the event I update ULX, I won't have to keep messing with copying the file back over, etc.

Thank you for the help.

Title: Re: Standalone addon, visibility to ULX functionality?
Post by: MrPresident on April 08, 2013, 02:10:30 PM
It doesn't work because ulx calls its modules, and by placing yours into a general lua/autorun directory its being called before ulx is loaded into memory. To fix this, just create a lua/ulx/modules/sh/ directory in you own add-on folder.
Title: Re: Standalone addon, visibility to ULX functionality?
Post by: ambro on April 08, 2013, 02:18:12 PM
Great,

Thank you!