Author Topic: ULX Commands  (Read 20962 times)

0 Members and 1 Guest are viewing this topic.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: ULX Commands
« Reply #15 on: November 10, 2010, 01:40:13 PM »
Thanks for the help!  I'll get to working on this more possibly some time later today or tomorrow.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX Commands
« Reply #16 on: November 11, 2010, 05:59:39 PM »
You're welcome.
I've not been motivated this past year to contribute to the ULib codebase directly, and haven't been on Steam enough to indirectly contribute in discussions with Megiddo. (I miss you, man!)
ULib/Lua assistance like this help keep me sharp and exercise my brain.
I'd not even realized until helping you that repeat_min and _max had been added to the StringArg object.
Always enjoy learning our new toys.
:P
« Last Edit: November 11, 2010, 06:03:22 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: ULX Commands
« Reply #17 on: November 20, 2010, 09:35:50 PM »
Finally got around to adding the autocompletes.  Works well.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: ULX Commands
« Reply #18 on: March 14, 2011, 04:24:01 PM »
I think hint is just used for autocomplete and command syntax. Repeat min ensures that an argument is repeated at least n times (and also states that it CAN be repeated). This was mainly added for XGUI's benefit, but it's useful for ULX as well.

For example:
vote:addParam{ type=ULib.cmds.StringArg, hint="options", ULib.cmds.takeRestOfLine, repeat_min=2, repeat_max=10 }

That's a line from the ulx vote definition. It makes sure that there are at least 2 options given, and a maximum of 10. (I need to document repeat_max :P)

Is there a way to get all the values into a table without having a million arguments in the function?

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: ULX Commands
« Reply #19 on: March 14, 2011, 07:52:35 PM »
Is there a way to get all the values into a table without having a million arguments in the function?

They're optional, so only specify them if you need them. This is a named parameter design.
Experiencing God's grace one day at a time.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: ULX Commands
« Reply #20 on: March 15, 2011, 05:49:10 AM »
vote:addParam{ type=ULib.cmds.StringArg, hint="options", ULib.cmds.takeRestOfLine, repeat_min=2, repeat_max=10 }

I was talking about this portion.  I wouldn't want to create 10 extra arguments and check to see if a value was entered for each one.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: ULX Commands
« Reply #21 on: March 15, 2011, 06:25:00 AM »
I was talking about this portion.  I wouldn't want to create 10 extra arguments and check to see if a value was entered for each one.

I'm not sure what you mean
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX Commands
« Reply #22 on: March 15, 2011, 06:58:40 AM »
Aaron, even I have to admit, I'm a bit confused at what you're asking, and I'm normally pretty good at seeing the root question my team members miss.
Do you mean you set up the first one or two argument checks, then want a table of anything else typed in that you didn't account for?
Thats what the "takerestofline" bit is for. It's not a table, its a string, but if you think you'll really need it as a table, it can be converted using any normal string to table means.
http://ulyssesmod.net/docs/files/lua/ulib/shared/commands-lua.html#cmds.takeRestOfLine
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: ULX Commands
« Reply #23 on: March 15, 2011, 01:28:59 PM »
Instead of doing this...
Code: [Select]
function ulx.whatever( ply, string1, string2, string3, string4, string5, string6, string7, string8, string9, string10 )

Would it be possible to make it...
Code: [Select]
function ulx.whatever( ply, tableOfStrings )
Because I've only been able to do the first one.  I can't figure out any other way.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: ULX Commands
« Reply #24 on: March 15, 2011, 01:34:47 PM »
As JamminR said, use cmds.takeRestOfLine. If you'd like to split it into a table, use ULib.splitArgs
Experiencing God's grace one day at a time.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: ULX Commands
« Reply #25 on: March 15, 2011, 01:45:14 PM »
Maybe I'll just work out something else.  Thanks anyway.