ULX

Author Topic: Standalone addon, visibility to ULX functionality?  (Read 2046 times)

0 Members and 2 Guests are viewing this topic.

Offline ambro

  • Newbie
  • *
  • Posts: 21
  • Karma: 2
Standalone addon, visibility to ULX functionality?
« 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.


Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Standalone addon, visibility to ULX functionality?
« Reply #1 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.

Offline ambro

  • Newbie
  • *
  • Posts: 21
  • Karma: 2
Re: Standalone addon, visibility to ULX functionality?
« Reply #2 on: April 08, 2013, 02:18:12 PM »
Great,

Thank you!
« Last Edit: April 08, 2013, 02:25:16 PM by ambro »