Author Topic: Adding a new custom xgui function  (Read 7508 times)

0 Members and 1 Guest are viewing this topic.

Offline easer7

  • Newbie
  • *
  • Posts: 24
  • Karma: 1
Adding a new custom xgui function
« on: November 28, 2012, 07:43:24 PM »
I want to make a new command on the xGUI list, called DamageLog.  I want it to be under utility.  When you open it I want to have a button that says "Print DamageLog" and when you press it, the damage log appears.  How it appears doesn't matter to me, whether in the console or in the GUI itself.  Can someone help me out? It would really be appreciated =3

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Adding a new custom xgui function
« Reply #1 on: November 29, 2012, 09:35:11 AM »
I want to make a new command on the xGUI list, called DamageLog.  I want it to be under utility.  When you open it I want to have a button that says "Print DamageLog" and when you press it, the damage log appears.  How it appears doesn't matter to me, whether in the console or in the GUI itself.  Can someone help me out? It would really be appreciated =3

Well the default command structure for ULX is some thing like this...

Code: [Select]
-- ULX spawn for ULX SVN/ULib SVN by HeLLFox_15
function ulx.spawn( calling_ply, target_plys, command )
for _, v in ipairs( target_plys ) do

if v:Alive() then v:KillSilent() else v:Spawn() end
v:Spawn()

end

ulx.fancyLogAdmin( calling_ply, "#A respawned #T", target_plys )
end
local spawn = ulx.command( CATEGORY_NAME, "ulx spawn", ulx.spawn, "!spawn" )
spawn:addParam{ type=ULib.cmds.PlayersArg }
spawn:defaultAccess( ULib.ACCESS_ADMIN )
spawn:help( "respawn a target(s)." )

You can learn more about it here... http://ulyssesmod.net/docs/files/ULib_readme-txt.html

I would find you the specific pages you need but I cant seem to access the wiki from this computer... http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4875.html?title=Main_Page
Also always cross refrence with this site and make sure the information is still valid, http://wiki.garrysmod.com/page/Main_Page (That is the official Gmod 13 wiki, you may acctually find what your looking for there but if you cant use the Gmod 12 wiki and cross refrence.)

Happy coding, and sorry I could not have been more help... internet restrictions suck. :(
I cry every time I see that I am not a respected member of this community.

Offline easer7

  • Newbie
  • *
  • Posts: 24
  • Karma: 1
Re: Adding a new custom xgui function
« Reply #2 on: November 29, 2012, 01:59:23 PM »
Hey no worries! But once you can maybe you could help me out? (if you want)

Offline easer7

  • Newbie
  • *
  • Posts: 24
  • Karma: 1
Question
« Reply #3 on: November 29, 2012, 02:48:59 PM »
After the function part, what would I type? Because all I want it to do is print the DamageLog.  The command is ttt_print_damagelog

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Question
« Reply #4 on: November 29, 2012, 11:55:18 PM »
After the function part, what would I type? Because all I want it to do is print the DamageLog.  The command is ttt_print_damagelog

Code: [Select]
function ulx.dlogs( calling_ply )
calling_ply:ConCommand("ttt_print_damagelog") -- This runs ttt_print_damagelog on the person who called the command (pressed the button or said !dlogs).

ulx.fancyLogAdmin( calling_ply, "#A is viewing the damage logs.", command, target_plys )
end
local dlogs= ulx.command( "Utility", "ulx dlogs", ulx.dlogs, "!dlogs" ) -- Makes the command be called dlogs and puts it in the Utility category.
dlogs:defaultAccess( ULib.ACCESS_ADMIN )
dlogs:help( "Shows the damage logs." )

Try the above code I just through it together so you may want to look for mistakes and or clean it up a bit.
I cry every time I see that I am not a respected member of this community.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Adding a new custom xgui function
« Reply #5 on: December 01, 2012, 02:38:16 PM »
Easer, let me make this clear for other coders here...you want someone else to write the code for you..is that what you mean by help?
Usually, when someone asks for help with code here, it means they have basic knowledge and are having challenge with what to do.
From the posts I see you make, it sounds as though it's not so much 'help' you need, as it is someone else to write the code?
(not necessarily a bad thing, making such a request, but hellfox is helping you in a way that makes it seem as though you would know what he's saying to begin with.)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline easer7

  • Newbie
  • *
  • Posts: 24
  • Karma: 1
Re: Adding a new custom xgui function
« Reply #6 on: December 01, 2012, 08:12:50 PM »
I know advanced java and a few LUA tutorials so i have a pretty basic understanding

Offline easer7

  • Newbie
  • *
  • Posts: 24
  • Karma: 1
Re: Adding a new custom xgui function
« Reply #7 on: December 01, 2012, 08:21:04 PM »
And thanks fox =D I really appreciate it!

Offline easer7

  • Newbie
  • *
  • Posts: 24
  • Karma: 1
Re: Adding a new custom xgui function
« Reply #8 on: December 01, 2012, 08:40:08 PM »
Fox what folder would I put this code in? I found multiple folders with similar code to this.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Adding a new custom xgui function
« Reply #9 on: December 02, 2012, 04:35:02 PM »
Fox what folder would I put this code in? I found multiple folders with similar code to this.

addons\YourAddonName\lua\ulx\modules\sh

Hope that helps you can also put it directly in the ulx addons folder, but I don't recommend it.
I cry every time I see that I am not a respected member of this community.

Offline easer7

  • Newbie
  • *
  • Posts: 24
  • Karma: 1
Re: Adding a new custom xgui function
« Reply #10 on: December 02, 2012, 05:16:51 PM »
do i need to put it in another also to add it to xgui?

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: Adding a new custom xgui function
« Reply #11 on: December 03, 2012, 01:24:26 AM »
do i need to put it in another also to add it to xgui?

Code: [Select]
local dlogs= ulx.command( "Utility", "ulx dlogs", ulx.dlogs, "!dlogs" ) -- Makes the command be called dlogs and puts it in the Utility category.
Because of this line of code, your command should show up in the Commands tab in XGUI, under the "Utility" category automatically, provided it gets installed correctly and is working.
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline easer7

  • Newbie
  • *
  • Posts: 24
  • Karma: 1
Re: Adding a new custom xgui function
« Reply #12 on: December 03, 2012, 03:56:44 PM »
thanks so much!