ULX

Author Topic: Tidbits for tools  (Read 2821 times)

0 Members and 1 Guest are viewing this topic.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Tidbits for tools
« on: January 20, 2008, 03:01:02 PM »
Ok, I've been tinkering. No major ULX updates like Megiddo is doing, just want to fix an annoying side effect of using spectate (and any other feature that uses our ULib.spawn(ply,true) that returns the player and always selects the .357 as the active weapon.

Selected weld tool.
Code: [Select]
] lua_run Msg(player.GetByID(1):GetActiveWeapon())
> Msg(player.GetByID(1):GetActiveWeapon())...
Weapon [101]

Selected material tool.

Code: [Select]
] lua_run Msg(player.GetByID(1):GetActiveWeapon())
> Msg(player.GetByID(1):GetActiveWeapon())...
Weapon [101]

Classname is always gmod_tool too.
Annoying.

My challenge was figuring out how to tell what tool was being used right before ULib.getSpawnInfo.
I found out that gmod_toolmode on the client side as a variable holds that tool.
And, even though gmod_tool is a classname, a command line execution of gmod_tool <convar:gmod_toolmode> would switch to last tool used.

I plan on using this as part of my ULib.getSpawnInfo and ULib.spawn enhancement/fix... but wanted to share with any coders out there who might find this handy somewhere down the line.

As ULib and ULX is in major flux right now, don't expect the enhancement this weekend. I'll wait until the Gmod update/ULX/ULib svn flux smooths out a bit.



« Last Edit: January 20, 2008, 03:03:36 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Tidbits for tools
« Reply #1 on: January 20, 2008, 03:09:45 PM »
Megiddo, I could possibly see this being used in 'spectate' to tell what actual tool is being used by the spectated player.
Currently, spectate only shows what the "Spectator" "gmod_toolmode" is when the "spectatee" changes to the gmod_tool weapon.
I've not looked to see how difficult it would be to update the spectate code, but perhaps when the gmod_tool weapon is chosen on the spectatee side, update the spectator's gmod_toolmode.

Again, I've not looked at the code. Might be more difficult than it sounds.
If possible though, I feel it would be of great benefit to know what players are doing/using more quickly than waiting and hoping whatever tool they're using shows itself off (duplicator, etc)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: Tidbits for tools
« Reply #2 on: January 20, 2008, 03:15:23 PM »
It would be more difficult than it's worth unfortunately. You'd have to keep tabs on what tool the user has out, since I don't think there's a hook for it...
Experiencing God's grace one day at a time.