WhiteThunder
Customize monument vending machines

Supported Games
depends on

Video tutorial

Video Tutorial

Features

  • Allows customizing items sold at monument vending machines
  • Supports vanilla monuments, custom monuments, train tunnels, and underwater labs (via Monument Finder)
  • Saves customizations for future restarts and wipes, based on the vending machine's relative position to the monument
  • Synchronizes edits with copies of the vending machines at duplicate monuments
  • Compatible with NPC vending machines spawned at monuments by plugins such as Monument Addons
  • Supports blueprints, as well as items with custom skins and names
  • Supports attachments and other child items
  • Supports ammo type and amount

Required plugins

How it works

When you open an NPC vending machine at a monument, if you have permission, you will see an edit button. Clicking that edit button will reveal a container UI where you can customize the vending machine.

  • Change which items are sold, and their prices, by adding and removing items from the container
  • Change display order by rearranging items in the container
  • Change stock settings by editing the note next to each item
  • Toggle whether the map marker is enabled by clicking on the broadcast icon (green = on, gray = off)
  • Change the shop name by clicking on the bottom-right note and editing its contents (supports multiple lines)
  • Save the changes by clicking the "SAVE" button

Permissions

  • customvendingsetup.use -- Allows editing NPC vending machines at monuments.

Screenshots

Configuration

Default configuration:

{
  "Override item max stack sizes (shortname: amount)": {}
}
  • Override item max stack sizes (shortname: amount) -- This section allows you to override the max stack size that players can get when purchasing items, by item short name. This is intended to allow players to get larger stacks of items from vending machines than they could get from other sources.
    • This feature only applies to vending machines customized by this plugin.
    • This feature might not work with every stack size plugin. Worst case, editing these settings may have no effect.

Example of overriding stack sizes:

{
  "Override item max stack sizes (shortname: amount)": {
    "wood": 10000,
    "stones": 5000
  }
}

Localization

{
  "Button.Save": "SAVE",
  "Button.Cancel": "CANCEL",
  "Button.Edit": "EDIT",
  "Button.Reset": "RESET",
  "Info.ForSale": "FOR SALE",
  "Info.Cost": "COST",
  "Info.Settings": "SETTINGS",
  "Settings.RefillMax": "Max Stock",
  "Settings.RefillDelay": "Seconds Between Refills",
  "Settings.RefillAmount": "Refill Amount",
  "Error.CurrentlyBeingEdited": "That vending machine is currently being edited by {0}."
}

FAQ

Can I sell more than 7 items?

No. At most 7 items can be sold per vending machine. It's not possible to sell more due to UI limitations in the vanilla game.

How do I setup custom monuments?

As a prerequisite, the custom monument must use the monument marker prefab and have a unique name. Then, you must configure the monument's bounds in Monument Finder to envelope the monument so that Custom Vending Setup can accurately determine whether a given vending machine is within that monument.

Developer API

API_IsCustomized

bool API_IsCustomized(NPCVendingMachine vendingMachine)

Returns true if the vending machine has been customized by this plugin, else false.

API_RefreshDataProvider

void API_RefreshDataProvider(NPCVendingMachine vendingMachine)

Removes the vending machine's currently assigned data provider and calls the OnCustomVendingSetupDataProvider hook again. If no plugin responds to that hook, the vending machine will fall back to using a monument based data provider.

Developer Hooks

OnCustomVendingSetup

bool? OnCustomVendingSetup(NPCVendingMachine vendingMachine)
  • Called when this plugin wants to internally register a monument vending machine to allow it to be edited
  • Returning false will prevent the vending machine from being edited
  • Returning null will allow the vending machine to be edited

OnCustomVendingSetupDataProvider

Dictionary<string, object> OnCustomVendingSetupDataProvider(NPCVendingMachine vendingMachine)
  • Called when this plugin wants to internally register a vending machine, before checking if it's at a monument
  • Returning a valid dictionary will override where the plugin retrieves/saves data
  • Returning null will result in the default behavior

The dictonary should contain the following keys.

  • "GetData" -- A method that Custom Vending Setup will call to retrieve data for this vending machine.
    • Type: System.Func<JObject>
  • "SaveData" -- A method that Custom Vending Setup will call to save data after the vending machine offers have been edited or reset.
    • Type: System.Action<JObject>

If you intend for multiple vending machines to share the same data, make sure you return the same dictionary instance for all of them.

Example:

class PluginData
{
    [JsonProperty("VendingProfile")]
    public object VendingProfile;
}

PluginData _pluginData;

void Init()
{
    _pluginData = Interface.Oxide.DataFileSystem.ReadObject<PluginData>("Test_VendingProfile") ?? new PluginData();
}

Dictionary<string, object> OnCustomVendingSetupDataProvider(NPCVendingMachine vendingMachine)
{
    if (vendingMachine.net.ID == 123456)
    {
        return new Dictionary<string, object>
        {
            ["GetData"] = new System.Func<JObject>(() =>
            {
                return _pluginData.VendingProfile as JObject;
            }),
            ["SaveData"] = new System.Action<JObject>(data =>
            {
                _pluginData.VendingProfile = data;
                Interface.Oxide.DataFileSystem.WriteObject("Test_VendingProfile", _pluginData);
            }),
        };
    }

    return null;
}

Credits

  • misticos, the original author of this plugin (v1)
MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Collaborators
  • misticos
    Developer