Ulysses
Ulysses Stuff => Releases => Topic started by: LuaTenshi on July 08, 2016, 08:53:09 PM
-
Ever wanted to run the popular addon called LuaDev ( https://github.com/Metastruct/luadev )?
Hated not being able to use its chat commands?
Well fear no more, because I am here with an addon that will allow LuaDev to plugin to ULX!
local cmds = {}
if ulx and ulx.cmdsByCategory and not aowl then
aowl = {}
function aowl.cmdExsits(cmd)
local t = ulx.cmdsByCategory['Luadev Commands'] or {}
if t and #t >= 1 then
for i=1,#t do
if t[i].cmd == cmd then return true end
end
end
return false
end
function aowl.AddCommand(cmd, callback, group)
if istable(cmd) then
for k,v in pairs(cmd) do
aowl.AddCommand(v,callback,group)
end
return
end
cmds = cmds or {}
cmds[cmd] = {callback = callback, group = group or "players", cmd = cmd}
for _,v in next, cmds do
local concmd = "ulx ld"..v.cmd
ulx.luadev = ulx.luadev or {}
ulx.luadev[v.cmd] = v.callback
if not aowl.cmdExsits(concmd) then
local com = ulx.command( "Luadev Commands", concmd, ulx.luadev[v.cmd], "!"..v.cmd )
com:addParam{ type=ULib.cmds.StringArg, hint="script", ULib.cmds.takeRestOfLine }
com:defaultAccess( v.group == "developers" and ULib.ACCESS_SUPERADMIN or ULib.ACCESS_ALL )
end
end
end
function aowl.TargetNotFound(trg)
local trg = tostring(trg)
if trg == "notarget" then
return "No target found or target was invalid."
else
return "The target <"..tostring(trg).."> was not found or was invalid."
end
end
end
if SERVER then include("autorun/server/luadev_chatcmds.lua") end
How to use this code? Pretend your making a new ULX command. addons/ulxluadev/lua/ulx/modules/sh/luadevplugin.lua
( I was too lazy to put it in a nice zip. :( )( More server plugins will be available soon! )
-
Modifying the ulx addon itself is usually a bad idea, because you'll have to copy the changed and added files when you want to update ULX. Instead, you should create a separate addon if you want to modify or extend ULX functionality.
I've attached a zip file that contains an addon named "ulx_luadev". This can be extracted directly into the garrysmod/addons/ folder. It contains the code in the above post, in the correct location as to be loaded by ULX.
-
Thank you roastchicken.
All, even when you just want to post a bit of code, please instruct readers to create a new/thier own addon folder, not add files/code to our base.
-
Thank you roastchicken.
All, even when you just want to post a bit of code, please instruct readers to create a new/thier own addon folder, not add files/code to our base.
Fixed, in the main post.
-
Can I use EasyLua with this and import my own aowl commands?
-
Can I use EasyLua with this and import my own aowl commands?
Not exactly sure what you're asking. But if you're asking about converting other custom aowl commands into ulx commands using the code above, that should work too.
Just make sure this runs first then add your aowl commands like you normally would. Also you may want to change the "ulx ld" prefix on like line 27.
Adding commands live should work as well as this mimics the aowl globals for adding commands.
-
Not exactly sure what you're asking. But if you're asking about converting other custom aowl commands into ulx commands using the code above, that should work too.
Just make sure this runs first then add your aowl commands like you normally would. Also you may want to change the "ulx ld" prefix on like line 27.
Adding commands live should work as well as this mimics the aowl globals for adding commands.
Okay cheers, I just have an older version of aowl with some commands that I added and if I can use this to convert them to ULX with out having to rewrite them I'd be happy as.