General > Developers Corner
This documentation...
Timmy:
Hi Mark - It's in the pipeline. Is there anything in particular that you'd like to see?
mark272:
I don’t really know but I would appreciate the basic stuff for command creation. Like rights and so on
Timmy:
Gotcha, I am still drafting the page that will cover that. I am juggling a few projects, but I hope to add more content to the docs site soon.
JamminR:
I've no idea if it will help anyone code a new command that isn't already used to ULX command structure, but years ago, I wrote a comparison of 'old' pre ULX command setup versus 'new and upcoming' (at the time) command setup structure for a fun command MrPresident wrote.
Here's the link to the full write-up - https://forums.ulyssesmod.net/index.php/topic,4464.0.html
However, the part from it that may be most beneficial are the commented sections for 'new' command.
Posted again here for, hopefully, your need of assistance.
Example psuedo function-
--- Code: ---function ulx.<your_function>( calling_ply, parm1, parm2, parm... )
-- Do code stuff with calling_ply and or parm1,2,...
end
--- End code ---
Example psuedo command to call function
--- Code: ---local <name of object, best if same as function> = ulx.command( "<STRING- help category, ex Fun>", "<STRING - console command, example 'ulx <this>'>", <literal function name>, "<STRING - command used in chat to perform action>, <BOOLEAN-hide saychat or not>, <BOOLEAN-require spaces after command or not> )
<name of object>:addParam{ type=ULib.cmds.PlayersArg } -- allows and requires player to input one or more players.
<name of object>:addParam{ type=ULib.cmds.NumArg, min=<min number>, max=<max number>, default=<default number>, hint="<STRING to show during ULX's error assistance", ULib.cmds.optional--<, ULib.cmds.round } -- Add additional number argument, optional, with min/max, and default.
<name of object>:defaultAccess( ULib.ACCESS_ADMIN ) -- Register ULX minimum required default access. In this case, admin
<name of object>:help( "<STRING - command to show in help menu for those with access to this command>" ) -- show this in previously set (in ulx.command) "help" category
<name of object>:logString( "Formatted strnig - Example. "#1s did something to #2s with #3i numbers" ) -- ULX log file and chat. Yes, this can be tricky. Just remember that each addParam command you add is in order. #1, #2, .. above. #1 is always player performing action. #1s makes it a string (see the s after 1). #2 using this code block example is player being acted on, #2s = string. #3i = integer (see type=ULib.cmds.NumArg?)
ulx.addToMenu( ulx.ID_MCLIENT, "<STRING - show this in menu>", "<STRING - console command, example 'ulx <this>'>" )
--- End code ---
See link to full write up, or any number of functions in our ULX code, for true examples. (example, fun.lua is a good place to see)
EDIT - I'm 98% sure we no longer use addToMenu. It will natually get registered I think. SticklyMan, MrPresident, Timmy or Megiddo would have to comment on how ot make sure XGUI picks up commands.
Timmy:
--- Quote from: JamminR on June 30, 2019, 07:47:49 PM ---EDIT - I'm 98% sure we no longer use addToMenu. It will natually get registered I think. SticklyMan, MrPresident, Timmy or Megiddo would have to comment on how ot make sure XGUI picks up commands.
--- End quote ---
Yes, XGUI will automatically pick up commands. Just create them in a shared module (e.g.: lua/ulx/modules/sh/your_module.lua). No need to call ulx.addToMenu anymore.
I can not find a version of ULX that ever used <cmd object>:logString. It must have been introduced and ditched between ULX v3.40 and v3.50 in favor of ulx.fancyLogAdmin.
It is quite interesting to see how these older versions of ULX used to work. :)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version