ULX

Author Topic: Changing how Gmod detects idles in TTT  (Read 1956 times)

0 Members and 1 Guest are viewing this topic.

Offline Seph

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Changing how Gmod detects idles in TTT
« on: September 27, 2017, 02:39:26 PM »
I'm new to gmod coding, and I'd like a bit of help with something.

Gmod detects idles using the CheckIdle() function in terrortown/gamemode/cl_init.lua, based on their viewing angle, mouse movement, and position. I'd like to, at the very least, get rid of that last method of tracking, because occasionally an idle will get crowbar pushed, and that annoyingly resets the idle timer. Ideally, I'd like to add keyboard inputs as the main way that idleness is tracked.

That said... I don't really want to just edit the cl_init file, because if I start changing the gamefiles themselves I'll eventually lose track of the changes I've made. I'd rather somehow have the change be an addon in the addon folder. But I don't know how to override GM functions (or, more generally, I'm not too clear on inheritance and file-structure shenanigans in general).

Any tips on how I can override a GM function in addons? Is there a better way of doing this that I don't know about? Pls be gentle.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: Changing how Gmod detects idles in TTT
« Reply #1 on: September 28, 2017, 10:17:13 AM »
Since it's a global function, you can define it yourself anywhere you'd like to override the original function (as long as your version is loaded after the cl_init.lua file but before InitPostEntity is called).
Experiencing God's grace one day at a time.

Offline Seph

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Changing how Gmod detects idles in TTT
« Reply #2 on: October 01, 2017, 08:37:51 AM »
Thanks for the advice, but I figured out something pretty dead simple. Friend told me to simply copy the file-path of the file I want to overwrite in the addons folder. Sooo: addons/afk_detect/gamemodes/terrortown/gamemode/cl_init.lua. And then I can change the cl_init.lua file to whatever I want.

Not sure if this is something I missed in the "Baby's First Addons" memo but there it is.

Offline monkeymacman

  • Newbie
  • *
  • Posts: 44
  • Karma: 13
Re: Changing how Gmod detects idles in TTT
« Reply #3 on: October 02, 2017, 09:37:23 PM »
If at all possible you should *really* try to avoid that, because if the cl_init file of TTT is ever changed at all, that one file will be out of date and could likely break everything. If possible, just try to override the function, or disable and recreate the effect.