Garry's Mod

Garry's Mod

[v10] PVOX
san juanito  [developer] Aug 8, 2024 @ 8:49pm
How to make a PVOX pack (The New Way)
Making a PVOX pack

Making a PVOX pack is not difficult at all, as it was designed for the average user to make as many VOX modules as their heart desires.

Modules VS. Packs

The sentence you just read may have seemed a tad confusing, as the words 'module' and 'pack' are used interchangeably. However, there are some small differences worth noting.

  • A module is most likely referring to a file in the PVOX MODULES directory. This file contains functionality for making PVOX do certain actions and execute certain requests.
  • A VOX Pack is primarily a backward term to maintain the audience of individuals coming from VOX frameworks like TFA-VOX, as module is the primary terminology used in PVOX.

1.o - Prerequisites

When making a VOX pack, you may be recording your own VOX, or importing it from another game. In either case, it is very important to have:

  • Structure, as you can not simply throw voice files into different directories and call that a VOX pack
  • High Quality Audio, if you're going for immersion obviously. Otherwise you can ignore this. No harm in porting old game files :)
  • Actual Files with a Proper Sample Rate. Now this rule is for all the people interested in diving into the audio-works of Source Engine. The sweet-spot for audio files is a .wav file, with a 44100Hz sample rate.
  • A will to maintain it. (If you're into updates ;3): as PVOX is a relatively new mod, there will be more features added, and new addons will come out patching certain standard functionality and adding new things. If you want your module to come packed with even more features, it's recommended you check in every now and then for more updates and fixes.

1.1 - Making the Pack

Okay, okay, alright. It's time to stop blabberin'. Let's get to the nitty-gritty of PVOX.

For starters, your main functionality is in the bulk of the PVox class. This is a global class which is exposed to LUA through THIS MOD, which is why all the mods with PVOX in the name require this mod, as it contains abstractions and services to manage the audio files and modules.

To create a module, you first need to locate your garrysmod/addons directory. Other folders in this one will be marked as legacy addons, which is fine, as most if not every mod starts as legacy before, through either gmpublish.exe or gmpublisher, they are converted to .gma.

Create a new directory inside of it and name it whatever you want. This will be the ADDON NAME for your module. We'll call our's MyFunModule.

Inside of that directory, create a few new directories. To save time and writing, your structure must look like this:

MyFunModule/ MyFunModule/sound MyFunModule/sound/pvox/ MyFunModule/lua MyFunModule/lua/pvox_module

1.1.1 - Adding The Module Files

So now you have a module structure. Where do we go from here?

Simply, you create a new .lua file in the pvox_module directory you created earlier.

MyFunModule/lua/pvox_module/pvox_myfunmodule.lua

You can truly name it whatever you want, but for simplicity's sake, we'll call it pvox_MODULENAME.

1.1.2 - Implementing the Module

Now, here's where things get a bit complicated.

There's two ways to make a module, the OLD/manual method, and the NEW/procedural method. Both come with their flexibilty, however, this doc goes over the new way of making modules.

To start, open that .lua file you created earlier and write this code.

PVox:ImplementModule('MODULE_NAME', function(player) return true end)

And just like that. You've implemented your first module.

Here's the spiel- when using the procedural method to make modules (PVOX v5+), you are essentially leaving the bulk of your module's code in PVOX's hands. Your function can return two values, either a true value, or a table. And the table method, will contain your actiontable full of sounds, which, as you can already tell, can pile up very fast.

However, when returning true value, it saves time by loading your PVOX module from the sound/ directory.

So now, instead of writing all our .wav's in the LUA file, we can create new action directories.

MyFunModule/ MyFunModule/sound/pvox/MODULE_NAME this name must be exact to the first parameter MyFunModule/sound/pvox/MODULE_NAME/actions MyFunModule/sound/pvox/MODULE_NAME/actions/confirm_kill MyFunModule/sound/pvox/MODULE_NAME/actions/death MyFunModule/sound/pvox/MODULE_NAME/actions/enemy_killed MyFunModule/sound/pvox/MODULE_NAME/actions/enemy_spotted MyFunModule/sound/pvox/MODULE_NAME/actions/frag_out MyFunModule/sound/pvox/MODULE_NAME/actions/inspect MyFunModule/sound/pvox/MODULE_NAME/actions/no_ammo MyFunModule/sound/pvox/MODULE_NAME/actions/pickup_weapon MyFunModule/sound/pvox/MODULE_NAME/actions/reload MyFunModule/sound/pvox/MODULE_NAME/actions/take_damage MyFunModule/sound/pvox/MODULE_NAME/actions/take_damage_in_vehicle

The actions directory contains all the actions your VOX can play at a given event.

Now, actions like inspect technically aren't implemented by default, but added as a module. So that gives you a gauge of how easy it is to make new actions and have them actually work.

1.1.3 - The Long Haul

This is the least fun part, trust me.

You now need to copy .wav files for these respective actions into their directories. For example, if you have a vox_death_1.wav, you must put it into actions/death.

This is the last part of creating your module. Once you do this, restart your game and select your module from the PVOX Settings drop down menu.

1.1.4 - Binding a Player Model

Do keep in mind, this functionality is not as streamlined as an addon like TFA-VOX

To bind your module to a playermodel, use the PVox:RegisterPlayerModel function.

PVox:RegisterPlayerModel("models/player/kleiner.mdl", "MODULE_NAME")

1.1.5 - Final Steps

After you've created your module, you might want to touch up the LUA file, as sometimes, there's variables in your environment that are uncontrollable, and that's the way the world works.

Take the code you had earlier, and you may want to add...

if ! PVox then return end -- this stops the script EARLY if the PVox class isn't present. -- Made by YOUR_NAME PVox:ImplementModule('MODULE_NAME', function(_) return true end)

We made two changes, adding a check for the PVox class, and removing the unused player parameter.

2.o - Outro/What's Next

Now that you've made a module, you can play around with different modules and see how they implement their action sounds by decompiling them using Crowbar. It's a fun process overall, except for some parts... and you will overall enjoy an easy way to make your character talk.

If this was of use, leave a thanks in the comments. If not, then you don't need to do anything haha, I hope you still found this of use.

Kae D., PVOX Authors
Last edited by san juanito; Aug 8, 2024 @ 8:58pm