Ulysses

General => Developers Corner => Topic started by: easer7 on November 28, 2012, 07:43:24 PM

Title: Adding a new custom xgui function
Post by: easer7 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
Title: Re: Adding a new custom xgui function
Post by: LuaTenshi 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. :(
Title: Re: Adding a new custom xgui function
Post by: easer7 on November 29, 2012, 01:59:23 PM
Hey no worries! But once you can maybe you could help me out? (if you want)
Title: Question
Post by: easer7 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
Title: Re: Question
Post by: LuaTenshi 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.
Title: Re: Adding a new custom xgui function
Post by: JamminR 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.)
Title: Re: Adding a new custom xgui function
Post by: easer7 on December 01, 2012, 08:12:50 PM
I know advanced java and a few LUA tutorials so i have a pretty basic understanding
Title: Re: Adding a new custom xgui function
Post by: easer7 on December 01, 2012, 08:21:04 PM
And thanks fox =D I really appreciate it!
Title: Re: Adding a new custom xgui function
Post by: easer7 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.
Title: Re: Adding a new custom xgui function
Post by: LuaTenshi 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.
Title: Re: Adding a new custom xgui function
Post by: easer7 on December 02, 2012, 05:16:51 PM
do i need to put it in another also to add it to xgui?
Title: Re: Adding a new custom xgui function
Post by: Stickly Man! 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.
Title: Re: Adding a new custom xgui function
Post by: easer7 on December 03, 2012, 03:56:44 PM
thanks so much!