ULX

Author Topic: Where do you put Derma code?  (Read 2312 times)

0 Members and 1 Guest are viewing this topic.

Offline OpticPotatOS

  • Jr. Member
  • **
  • Posts: 53
  • Karma: 0
  • GLaDOS
    • Gaming for Everyone
Where do you put Derma code?
« on: June 08, 2016, 08:15:56 AM »
So, I'm making a small module for my server that adds one command that opens a derma panel upon execution, but there's a slight problem.

I have no idea where you put the derma code.

Anyone know where you would put the derma code to be executed after a command is run? I know VGUI and Derma are client side, and I'm 99% sure that you stick modules with commands in them in /modules/sh/ or whatever (right? Excuse my apparent noobness). So, how do you get them to work together?
My website isn't my website, rather, it's the gaming network my sever is connected to.

ttt.gfe.nu

Unforeseen Consequences

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Where do you put Derma code?
« Reply #1 on: June 08, 2016, 08:17:39 AM »
You can put it in shared but you would need to specify if CLIENT then for the vgui to work. You could also make a thing in modules/cl and you wouldn't need to specify it there.

You could probably take a look at my CheckAFK to see how derma would work.
« Last Edit: June 08, 2016, 08:19:32 AM by iViscosity »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline OpticPotatOS

  • Jr. Member
  • **
  • Posts: 53
  • Karma: 0
  • GLaDOS
    • Gaming for Everyone
Re: Where do you put Derma code?
« Reply #2 on: June 08, 2016, 08:22:15 AM »
Cool, thanks  :)
My website isn't my website, rather, it's the gaming network my sever is connected to.

ttt.gfe.nu

Unforeseen Consequences

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Where do you put Derma code?
« Reply #3 on: June 08, 2016, 08:36:45 AM »
No problem. Let me know if you need more info.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Where do you put Derma code?
« Reply #4 on: June 08, 2016, 11:14:04 AM »
VGUI/Derma execution via command is a bit more difficult than simply making a clientside file. As iViscosity pointed out, you could put the file in either lua/ulx/modules/sh or lua/ulx/modules/cl. I would recommend putting the files in lua/ulx/modules/cl unless the file contains serverside code, as there's no reason to run it on the server if you don't need to.

If you want you could instead make it completely separate from ULX by simply putting it (your clientside lua file) somewhere in the (virtual) lua folder (preferably in a custom addon - no need to clutter up garrysmod/lua). You would then need to call it via a lua file placed in lua/autorun (again, preferably in an addon).

iViscosity's CheckAFK does include some examples for how to run clientside code (VGUI/Derma in this case) from a console command. The gist is that you use ULib.clientRPC to call your clientside derma-creating function. If you really want you could use the net library to get a bit 'closer to the metal' so to speak, but I'm not sure how useful that would be.

Oh, and please don't modify the ulx addon directly. e.g. if you want a file in garrysmod/addons/ulx/lua/ulx/modules/cl, just create your own addon (just a new folder in garrysmod/addons) and replicate the file structure: place the file in garrrysmod/addons/youraddon/lua/ulx/modules/cl. This way you can modify and extend ULX while still being able to update ULX with ease.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.