Documentation

Exports & Events

Server events for shredder integrations.

General Information

Machine arguments are the id of a configured machine, or of a compact prop a player set up. Item names are inventory item names. identifier is the character identifier from zyke_lib, and coords is a plain {x, y, z} table.

Compact props have a kind: compact for the shredder, generator, or box. Events for loading, shredding, jamming, collecting, and refueling fire for both the scrapyard shredder and the compact set.

Types / Classes

All types / classes can be found in types/types.lua inside zyke_shredder.

Shredder currently has no exports. Integrations listen to the server events below.

#Server Local Events

These events are local server integration notifications. They are not network event entry points. Listen with AddEventHandler on the server. Default Discord logging for these events lives in server/unlocked/hooks.lua.

#On Part Loaded

Fires when a part is placed on the belt or dropped into a compact shredder's hopper. Its outputs are rolled at this point and land in the bin or catch crate once it is shredded.

Example:

lua
---@param data ShredderLoadedData
AddEventHandler("zyke_shredder:OnPartLoaded", function(data)
    print(data.identifier, data.machine, data.item, data.loadId)
end)

#On Part Unloaded

Fires when a part is taken back off the infeed. Its rolled outputs are removed from the bin. owner is the character who loaded it; this differs from the player only when bin.shared is enabled.

Example:

lua
---@param data ShredderUnloadedData
AddEventHandler("zyke_shredder:OnPartUnloaded", function(data)
    print(data.identifier, data.owner, data.item)
end)

#On Shredder Jammed

Fires when a part jams the cutters and they reverse. reversal is 1 the first time the part jams.

Example:

lua
---@param data ShredderJammedData
AddEventHandler("zyke_shredder:OnShredderJammed", function(data)
    print(data.machine, data.item, data.reversal)
end)

#On Item Shredded

Fires when a part has been shredded and its outputs are in the bin. source is the player who loaded it, or nil when it was loaded before a restart. The player may have left since.

Example:

lua
---@param data ShredderShreddedData
AddEventHandler("zyke_shredder:OnItemShredded", function(data)
    for _, output in ipairs(data.outputs) do
        print(output.item, output.amount)
    end
end)

#On Bin Collected

Fires when a player takes scrap from the bin or a catch crate. from lists whose pieces were taken; other characters' pieces appear only when the bin or crate is shared.

Example:

lua
---@param data ShredderCollectedData
AddEventHandler("zyke_shredder:OnBinCollected", function(data)
    print(data.identifier, data.machine, #data.items)
end)

#On Shredder Toggled

Fires when a machine starts or stops, including a portable generator. kind is line for a scrapyard shredder, or the compact prop's kind. source is absent when the machine started or stopped by itself; reason is then idle, fuel, overheat, restart, admin, power, or fumes.

Example:

lua
---@param data ShredderToggledData
AddEventHandler("zyke_shredder:OnShredderToggled", function(data)
    print(data.machine, data.kind, data.running, data.reason)
end)

#On Shredder Adjusted

Fires when an admin sets a machine's diesel or heat from the admin panel. setting is fuel or heat. For a compact shredder, fuel sets the tank of the generator plugged into it.

Example:

lua
---@param data ShredderAdjustedData
AddEventHandler("zyke_shredder:OnShredderAdjusted", function(data)
    print(data.machine, data.setting, data.previous, data.value)
end)

#On Generator Refueled

Fires when a player pours fuel into a generator. litres is the amount poured; fuel is the tank level afterward.

Example:

lua
---@param data ShredderRefuelledData
AddEventHandler("zyke_shredder:OnGeneratorRefueled", function(data)
    print(data.machine, data.item, data.litres, data.fuel)
end)

#On Recipe Changed

Fires when an admin saves, enables, disables, or deletes a recipe. action is save, setEnabled, or delete.

Example:

lua
---@param data ShredderRecipeChangedData
AddEventHandler("zyke_shredder:OnRecipeChanged", function(data)
    print(data.action, data.item, data.enabled)
end)

#On Scrap Sold

Fires when a player sells scrap to the buyer. Each sale lists the amount, the pieces paid in full toward the order, and the money paid. orderFilled is true when the sale completed every line of the character's order.

Example:

lua
---@param data ShredderScrapSoldData
AddEventHandler("zyke_shredder:OnScrapSold", function(data)
    print(data.identifier, data.total, data.orderFilled)
end)

#On Compact Placed

Fires when a prop of the compact set is set up, from its item or by an admin. bucket is the routing bucket key it stands in. docked is the shredder a crate docked to as it was set up, and fuel is the diesel a generator's item carried.

Example:

lua
---@param data ShredderCompactData
AddEventHandler("zyke_shredder:OnCompactPlaced", function(data)
    print(data.identifier, data.kind, data.machine, data.bucket, data.indoors)
end)

#On Compact Picked Up

Fires when a prop is packed back into its item, or taken away with the admin command. admin is true for the latter. fuel is the diesel a generator's item kept.

Example:

lua
---@param data ShredderCompactData
AddEventHandler("zyke_shredder:OnCompactPickedUp", function(data)
    print(data.identifier, data.kind, data.machine, data.admin)
end)

#On Compact Linked

Fires when a generator's cable is plugged into a compact shredder, or a crate docks to one. link is cable or box. item is the cable item that plugging it in took.

Example:

lua
---@param data ShredderCompactLinkData
AddEventHandler("zyke_shredder:OnCompactLinked", function(data)
    print(data.link, data.shredder, data.generator, data.item)
end)

#On Compact Unlinked

Fires when a cable is pulled out or a docked crate is taken away. item is the cable item handed back.

Example:

lua
---@param data ShredderCompactLinkData
AddEventHandler("zyke_shredder:OnCompactUnlinked", function(data)
    print(data.link, data.shredder, data.generator, data.item)
end)

#On Generator Fumes Stalled

Fires when a portable generator running indoors chokes on its fumes and stalls. machine is the generator, and shredder is the shredder it was powering.

Example:

lua
---@param data ShredderFumesStalledData
AddEventHandler("zyke_shredder:OnGeneratorFumesStalled", function(data)
    print(data.machine, data.owner, data.bucket, data.level)
end)

#On Action Refused

Fires when the server turns down a player action. attempt is load, unload, start, stop, collect, refuel, sell, place, pickup, link, or unlink. reason is the locale key sent to the player.

Example:

lua
---@param data ShredderRefusedData
AddEventHandler("zyke_shredder:OnActionRefused", function(data)
    print(data.attempt, data.reason, data.machine)
end)

#On Shredder Activity

Fires for every action recorded in the activity log, whether or not logs.enabled writes it to the database. action is loaded, unloaded, shredded, jammed, collected, refueled, started, stopped, refused, cooled, recipe, sold, admin, placed, packed, linked, unlinked, or fumes.

Example:

lua
---@param data ShredderActivityData
AddEventHandler("zyke_shredder:OnShredderActivity", function(data)
    print(data.action, data.machine, data.identifier)
end)

For custom permission rules, use Can-Check Hooks.