Holdable Abilities
Sometimes, you want to create an ability that you can use for an unknown amount of time, depending on user input.
WCS introduces a whole new ability type for this case: HoldableSkill
, which you can specify the max hold time of and run the callbacks
whenever it ends like on a regular ability.
Let's make a file called block
and register a holdable ability:
- TypeScript
- Luau
block.ts
import { HoldableSkill, SkillDecorator } from "@rbxts/wcs";
@SkillDecorator
export class Block extends HoldableSkill {}
block.lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WCS = require(ReplicatedStorage.WCS)
local Block = WCS.RegisterHoldableSkill("Block")
return Block
Then set the max hold duration to undefined, so we could hold the block indefinitely.
- TypeScript
- Luau
block.ts
import { HoldableSkill, SkillDecorator } from "@rbxts/wcs";
@SkillDecorator
export class Block extends HoldableSkill {
public OnConstructServer() {
this.SetMaxHoldTime(undefined);
}
}
block.lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WCS = require(ReplicatedStorage.WCS)
local Block = WCS.RegisterHoldableSkill("Block")
function Block:OnConstructServer()
self:SetMaxHoldTime(nil)
end
return Block
note
You can determine if the ability is holdable or not by calling GetSkillType()
.