Vending Machine entity
Entity defined in entities/entities/cw_vendingmachine
Shared definition of the cw_vendingmachine entity (print name Vending Machine), with its stock, flash action and
flash time data table variables and ENT:GetStock.
Summary
Methods
Methods
ENT:CanTool(player, trace, tool)
server gamemodes/cwhl2rp/schema/entities/entities/cw_vendingmachine/init.lua:157Blocks every toolgun action on the machine.
Parameters
- player
- trace
- tool
Returns
- Boolean Always
false
ENT:CreateWater(activator)
server gamemodes/cwhl2rp/schema/entities/entities/cw_vendingmachine/init.lua:33Takes one can from the stock and dispenses a random Breen's water in front of the machine.
Dispenses a special Breen's water 1 time in 20, a smooth one 10 times in 20 and a regular one otherwise.
Parameters
- activator Player The buyer, recorded as the item entity's owner
Draws the machine with its status light.
The light is green when stocked, orange when empty, and while flashing blue after a sale or restock or red after a refused purchase.
ENT:GetDefaultStock()
server gamemodes/cwhl2rp/schema/entities/entities/cw_vendingmachine/init.lua:69Returns the stock the machine is refilled to on restock.
Returns
- Number The default stock, 0 when none was set
Returns how many cans the machine has left.
Returns
- Number The current stock
ENT:GiveStock(amount)
server gamemodes/cwhl2rp/schema/entities/entities/cw_vendingmachine/init.lua:75Adds to the machine's stock, clamped between 0 and the default stock.
Parameters
- amount Number Cans to add; negative to take some away
Sets up the soda machine model and physics with an empty stock.
ENT:PhysicsUpdate(physicsObject)
server gamemodes/cwhl2rp/schema/entities/entities/cw_vendingmachine/init.lua:116Keeps the machine still while nobody holds it and it is not constrained.
Parameters
- physicsObject
Refills the machine to its default stock with a flash and sound.
ENT:SetFlashDuration(duration, action)
server gamemodes/cwhl2rp/schema/entities/entities/cw_vendingmachine/init.lua:104Flashes the machine's status light.
Parameters
- duration Number How long the light flashes, in seconds
- action Boolean optional, defaults to
niltruefor a blue success flash; otherwise a red refusal flash with a sound
ENT:SetStock(amount, default)
server gamemodes/cwhl2rp/schema/entities/entities/cw_vendingmachine/init.lua:82Sets the machine's stock and optionally its default stock.
Parameters
- amount Number The new stock
- default Any optional, defaults to
nilA number to use as the default stock, ortrueto makeamountthe default
ENT:SetupDataTables()
shared gamemodes/cwhl2rp/schema/entities/entities/cw_vendingmachine/shared.lua:21Declares the stock, flash action and flash time data table variables.
ENT:UpdateTransmitState()
server gamemodes/cwhl2rp/schema/entities/entities/cw_vendingmachine/init.lua:24Always transmits the machine to every client.
ENT:Use(activator, caller)
server gamemodes/cwhl2rp/schema/entities/entities/cw_vendingmachine/init.lua:127Sells a Breen's water to a citizen for 8 tokens, or lets Combine restock an empty machine.
Citizens can buy once every 10 minutes; an empty machine, a player who cannot pay or one on cooldown gets a red flash. Uses are ignored within 3 seconds of each other and while the light flashes.
Parameters
- activator
- caller