Skip to content

Client Hooks ​

Edit bridge/events/client.lua. The functions already exist with commented examples. Add your code inside their bodies. No event registration is needed.

These run for the local player. Put important permission checks in the server hook.

context contains stationId, recipeId, quantity, duration (seconds) and output (item and count). It is a copy; editing it does not change crafting. Keep hooks quick and do not use Wait.

CanCraftItem

Return false and a message to stop the craft. Return nothing to allow normal checks. An error in this hook blocks the request.

lua
function FSBridge.Events.CanCraftItem(context)
    -- return false, 'You cannot craft this item'
end
BeforeCraftingStart

Runs before asking the server to start. This does not confirm the server accepted it.

lua
function FSBridge.Events.BeforeCraftingStart(context)
    -- print('Starting recipe: ' .. context.recipeId)
end
CraftingInProcess

Runs at the start and about once per second. elapsed is seconds and progress is 0–100. Reaching 100 does not confirm a reward.

lua
function FSBridge.Events.CraftingInProcess(context, elapsed, progress)
    -- print('Crafting: ' .. math.floor(progress) .. '%')
end
CraftingEnd

Runs when an accepted session finishes, fails or is cancelled. success is true only for successful completion. reason contains the result message. Do not give items or XP again.

lua
function FSBridge.Events.CraftingEnd(context, success, reason)
    -- if success then
    --     print('Craft finished')
    -- else
    --     print(reason or 'Craft cancelled')
    -- end
end

Sequential crafting calls hooks for each craft. A batch uses one session. Rejected starts do not call CraftingEnd.

FWB Studio documentation.