Garbage Recycler - Plastic (entities) entity
Entity defined in entities/entities/cw_factory_garbage_plastic.lua
Single-file definition of the cw_factory_garbage_plastic entity (print name Garbage Recycler - Plastic), a machine
that turns plastic junk items into plastic items.
An idle recycler absorbs empty_tin_can and empty_plastic_bottle item entities placed on top of it, and the
Factories plugin's entity menu options call ENT:StartWork to run a 20 second cycle once the garbage count hits 8,
ENT:StopWork to pause it and ENT:Eject to move the collected garbage into the linked storage entity. The client
draws a status screen with the garbage count and cycle progress on the model, using the _GR_CMB_FONT_1 to
_GR_CMB_FONT_4 fonts created by the metal recycler's files. The same class is also defined by the
cw_factory_garbage_plastic/ folder, which the entity loader includes first, so this file's definition is the one
that stays registered.
Summary
Methods
plastic item at the product position.Methods
ENT:CanGarbageUsed(item)
server gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic.lua:109Returns whether the recycler accepts an item as garbage.
Parameters
- item Item The item to check
Returns
- Boolean Whether the item's unique ID is in
GARBAGE_ITEMS
Draws the recycler and its indicator screen with the status, garbage count and progress bars.
While the local player holds the toolgun, a marker also shows the product position.
Moves the collected garbage into the eject storage entity and empties the recycler.
The storage is found by the creation ID set with SetEjectStorage. Does nothing while working or
paused, when the storage does not exist or without the Storage plugin. Items that would push a known
container over its weight limit are dropped on top of it instead.
Finishes the cycle: stops the work sounds, uses up the collected garbage and spawns a plastic item at the
product position.
ENT:GetSearchPos()
server gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic.lua:119Returns the corners of the box above the recycler that garbage is collected from.
Returns
- List<Vector> The minimum and maximum corners, as passed to
ents.FindInBox
ENT:Initialize()
shared gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic.lua:32Sets up the recycler model, physics and empty garbage state on the server, and the indicator screen render target on the client.
Stops the recycler's work sound.
ENT:SetupDataTables()
shared gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic.lua:85Declares the product position, garbage count, working state, work timing, eject storage and stop time network vars.
ENT:SpawnFunction(ply, trace)
server gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic.lua:98Spawns a plastic recycler 25 units off the aimed surface.
Parameters
- ply
- trace
Returns
- Entity The spawned recycler
ENT:StartWork()
server gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic.lua:134Starts a recycling cycle, or resumes a stopped one where it left off.
A new cycle only starts once the garbage count has reached METAL_GARBAGE_COUNT_START
and lasts WORK_TIME seconds.
Pauses the current cycle, remembering the time left, and stops the work sounds.
Collects garbage, plays the work sounds and advances the recycling cycle every tick on the server.
Garbage cw_item entities inside ENT:GetSearchPos are taken while the recycler is idle and not full.
During a cycle the garbage count drains step by step and ENT:EndWork runs when the time is up.
ENT:Use(activator)
server gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic.lua:243Does nothing; the recycler is operated through its entity menu options.
Parameters
- activator