ULX

Author Topic: This documentation...  (Read 1736 times)

0 Members and 1 Guest are viewing this topic.

Offline mark272

  • Newbie
  • *
  • Posts: 15
  • Karma: 5
This documentation...
« on: March 07, 2019, 10:35:51 AM »
I don't understand the documentation.
For example where is ulx.command like ulx.command( CATEGORY_NAME, "ulx bring", ulx.bring, "!bring" )
I only found cmds.addCommand
And why is the method not fully entered? In documentation: ucl.registerAccess but in real code it is ULib.ucl.registerAccess
Could someone help me out here? I am so confused.
Thanks.
« Last Edit: March 07, 2019, 10:37:30 AM by mark272 »

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 783
  • Karma: 54
    • Anonymous Gaming
Re: This documentation...
« Reply #1 on: March 07, 2019, 10:47:22 AM »
The method is being fully entered.

The syntax for ulx.command is
Code: Lua
  1. ulx.command("Category Name", "console command", function_name, "!chatcommand", hide_command, require_space)
  2.  

Where you have the category to sort the command into, the console command to use the command, the actual function to execute when using the command, and then three optional arguments: the chat command, whether or not the person using the command should have their use message show in chat (useful for things like !p where you don't want it to show), and whether or not to require a space between the chat command and the arguments (useful for asay (@message))

The documentation shows ucl.registerAccess because that's how it was in the source code.

At the very top of the file, they have this line:
Code: Lua
  1. local ucl = ULib.ucl
  2.  

Which just makes it easier for them to write. Referencing outside of that file is still "ULib.ucl.registerAccess", remember it's all contained under the main "ULib" table.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me a PM or Join my Discord!.
--==[ Links ]==--
Steam
YouTube
Steam Group (feel free to join!)
Discord

Offline mark272

  • Newbie
  • *
  • Posts: 15
  • Karma: 5
Re: This documentation...
« Reply #2 on: March 07, 2019, 10:58:39 AM »
Ah thanks  ;D
But where is ulx.command in the documentation? I may not see it but the search gives nothing (good).

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 783
  • Karma: 54
    • Anonymous Gaming
Re: This documentation...
« Reply #3 on: March 07, 2019, 11:05:49 AM »
There is no official documentation for ulx, just ULib (actually I was working on documentation for ulx a while ago but kinda forgot about it)

You can find the source for ulx.command here.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me a PM or Join my Discord!.
--==[ Links ]==--
Steam
YouTube
Steam Group (feel free to join!)
Discord

Offline mark272

  • Newbie
  • *
  • Posts: 15
  • Karma: 5
Re: This documentation...
« Reply #4 on: May 11, 2019, 01:23:34 PM »
Hello, sorry for the inconvenience.
Timmy I would appreciate it if you would continue filling up your docs. When you do them good, I may give you a donation via PayPal.

Offline Timmy

  • Ulysses Team Member
  • Full Member
  • *****
  • Posts: 217
  • Karma: 160
  • Code monkey
    • ULX Unofficial Documentation
Re: This documentation...
« Reply #5 on: May 11, 2019, 03:23:17 PM »
Hi Mark - It's in the pipeline. Is there anything in particular that you'd like to see?
“When given the choice between being right or being kind, choose kind.”  —Dr. Wayne Dyer

Offline mark272

  • Newbie
  • *
  • Posts: 15
  • Karma: 5
Re: This documentation...
« Reply #6 on: June 26, 2019, 08:35:58 AM »
I don’t really know but I would appreciate the basic stuff for command creation. Like rights and so on

Offline Timmy

  • Ulysses Team Member
  • Full Member
  • *****
  • Posts: 217
  • Karma: 160
  • Code monkey
    • ULX Unofficial Documentation
Re: This documentation...
« Reply #7 on: June 30, 2019, 12:07:36 PM »
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.
“When given the choice between being right or being kind, choose kind.”  —Dr. Wayne Dyer

Online JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8016
  • Karma: 380
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: This documentation...
« Reply #8 on: June 30, 2019, 07:47:49 PM »
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: [Select]
function ulx.<your_function>( calling_ply, parm1, parm2, parm...  )
-- Do code stuff with calling_ply and or parm1,2,...
end

Example psuedo command to call function
Code: [Select]
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>'>" )

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.
« Last Edit: June 30, 2019, 07:52:05 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Timmy

  • Ulysses Team Member
  • Full Member
  • *****
  • Posts: 217
  • Karma: 160
  • Code monkey
    • ULX Unofficial Documentation
Re: This documentation...
« Reply #9 on: July 01, 2019, 02:23:12 AM »
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.
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. :)
“When given the choice between being right or being kind, choose kind.”  —Dr. Wayne Dyer

Offline mark272

  • Newbie
  • *
  • Posts: 15
  • Karma: 5
Re: This documentation...
« Reply #10 on: July 01, 2019, 11:01:06 AM »
Timmy I love you <3

Offline mark272

  • Newbie
  • *
  • Posts: 15
  • Karma: 5
Re: This documentation...
« Reply #11 on: August 01, 2019, 07:46:23 AM »
Eh hello agian.

I have a problem. I can use #A (Actor) and #T (Target) in FancyLogAdmin but I need to show an integer. How could I do that?
E.g "#A gave #T INTEGER"

Offline Timmy

  • Ulysses Team Member
  • Full Member
  • *****
  • Posts: 217
  • Karma: 160
  • Code monkey
    • ULX Unofficial Documentation
Re: This documentation...
« Reply #12 on: August 01, 2019, 08:33:09 AM »
You can use #i (integer).

All the usual format specifiers are supported by ulx.fancyLogAdmin, but they start with # instead of %.

List of all format specifiers: http://www.cplusplus.com/reference/cstdio/printf/

Examples on how to format decimals: https://forums.ulyssesmod.net/index.php/topic,9609.msg49245.html#msg49245
“When given the choice between being right or being kind, choose kind.”  —Dr. Wayne Dyer