Skip to content

Gear Locks

shastaxc edited this page Jun 7, 2025 · 4 revisions

Gear locks expand upon GearSwap's enable/disable feature. This allows you to specify one or more slot names which will prevent any gear swapping in those slots until you re-enable them. That implementation has some limitations though. If you call the disable() function in code you can also re-enable it in game with //gs enable, but you may not want a manual command to be able to override your code's functionality, or vice versa. Some people will put enable/disable commands in a loop so that you are unable to control it with manual commands.

Example of GearSwap's enable/disable limitation: Imagine you have a loop that checks your buffs to see if you have 'Sleep' status, and then disables your neck slot so it can equip "Vim Torque". You need the piece to remain equipped for a few seconds in order to deal damage to you and wake you up. Then your code needs to re-enable the neck slot so it can continue swapping as normal. The problem is that to unlock the slot, it also runs in a loop to do "if I do NOT have 'sleep' status, enable neck" which just constantly re-enables the neck slot preventing you from disabling it in any way other than receiving the sleep status.

SilverLibs locks works on the principle that you can assign multiple locks to a slot, and as long as there is at least 1 lock then the slot will not swap gear. This way, you can create a lock named sleep_handler like in the example above, but you can still issue the //gs c lock neck command in-game which will apply a lock named manual. This puts 2 locks on the neck slot, so when the 'Sleep' status is removed from you and the sleep_handler lock is removed, the slot will continue to remain locked because it still has your manual lock on it.

Functions

  • lock
    • Locks slots to prevent gear swapping
  • unlock
    • Unlocks slots to allow gear swapping
  • clearlocks
    • Removes all locks on a slot to allow gear swapping

Usage

There are 2 ways to perform all the functions: in-game commands or code.

In-Game Commands

Lock //gs c lock <slots>

The <slots> can be either all or a list of slot names. If you don't include any slots, it defaults to all.

More than one slot can be specified with a space-separated list such as //gs c lock neck main hands.

When a lock is applied with an in-game command this way, the lock name manual is used. If you are also using locks via code, do NOT use manual for your lock name or you will break the ability to manage locks with in-game commands.

Unlock //gs c unlock <slots>

The <slots> can be either all or a list of slot names. If you don't include any slots, it defaults to all.

More than one slot can be specified with a space-separated list such as //gs c unlock neck main hands.

When a lock is removed with an in-game command this way, the lock name manual is used. If you are also using locks via code, do NOT use manual for your lock name or you will break the ability to manage locks with in-game commands.

Clearlocks //gs c clearlocks <slots>

The <slots> can be either all or a list of slot names. If you don't include any slots, it defaults to all.

More than one slot can be specified with a space-separated list such as //gs c clearlocks neck main hands.

When locks are removed with an in-game command this way, it removes all locks including ones applied via code.

Code

Lock silibs.lock(lock_name, ...)

The first parameter is the lock name. It is required, must be a string, and cannot be a slot name.

The remaining parameters must be either 'all', slot names, or blank (defaults to 'all').

Example: silibs.lock('sleep_handler', 'main', 'sub', 'ring1', 'right_ring')

Unlock silibs.unlock(lock_name, ...)

The first parameter is the lock name. It is required, must be a string, and cannot be a slot name.

The remaining parameters must be either 'all', slot names, or blank (defaults to 'all').

Example: silibs.unlock('sleep_handler', 'main', 'sub', 'ring1', 'right_ring')

Clearlocks silibs.clearlocks(...)

All parameters must be either 'all', slot names, or blank (defaults to 'all').

Example: silibs.clearlocks('main', 'sub', 'ring1', 'right_ring')

Clone this wiki locally