EVMxShowVendingMenu is the core function. It starts the vending routine with any container or NPC you point at:
call EVMxShowVendingMenu -1

 

EVMxVendingMachineScript is the container script, used in this mod. It can be attached to any container to transform it to a vending terminal.
Can be used as is: to disable random breakage – lock your container, to disable break-ins – set its lock level to 100 or 255.
Or make your own version of container script, calling EVMxShowVendingMenu.

Default vending machines ignore only money and TTW-added Liquid Nitrogen and Coolant Component. More items to ignore can be added to the EVMxExclusionList formlist. For better interoperability, clear it and add your items right before displaying the vending menu. To achieve this, use your own copy of EVMxVendingMachineScript, where you run ListClear EVMxExclusionList and then add your items with ListAddForm (see example below).

 

EVMxNPCVendorScript is an example of how this can work on NPCs. Attach this script to an NPC, and vending menu will open on activation. You may probably want to create a dialog and call EVMxShowVendingMenu there. NPCs use caps by default, add them to the NCR or Legion faction to change their currency.

 

Example

Default EVMxVendingMachineScript is a wrapper for EVMxShowVendingMenu, specific to vanilla vending machines with soft drinks. It implements:
– automatic locking for vanilla containers – we need this for compatibility with loot menus,
– features, togglable in MCM: random breakage, break-ins, repairs.

You are, probably, won’t be interested in breakage and/or break-ins for a weapon mods machine, for instance. I encourage you to make your own wrappers for EVMxShowVendingMenu and attach them to your containers. To disable break-ins AND provide loot menu compatibility, lock your containers at level 100 (Very Hard).

 

Here is a skeleton script:

scn EVMxMyWeaponModsVendingMachineScript

begin OnActivate

; We need this check, because NPCs can interact with vending machines.
If IsActionRef PlayerRef == 0
    return
endif

; Excluded items.
; ListClear EVMxExclusionList
; AddListForm EVMxExclusionList AmmoFlamerFuel

; This function also works as menu callback, therefore we pass a negative integer to avoid triggering any buttons.
call EVMxShowVendingMenu -1

end