Simple, you use the "AbilitySpecial" hook.
More information here:
https://wiki.srb2.org/wiki/Lua/Hooks#AbilitySpecial
Here's a tip though, if you want to make sure your ability doesn't act like your character has multiability, you should check if PF_THOKKED has already been set in the player's pflags (player.pflags) and, if not, set the PF_THOKKED flag after the ability has been used once. Landing on the ground will then remove the PF_THOKKED flag for you.
Here's an example:
// declare and define a function with a single parameter
// "p" is the player this function is being called for
local function AbilityExample(p)
if p.mo.skin != "sonic" // is this your skin?
return false // do whatever's normal if not
end
if (p.pflags & PF_THOKKED) // don't do anything if you've already used this
return true // override normal behavior (in case the character would normally have thok or something)
end
print("I just pressed jump in midair!") // make a print message (yes I'm using this as an example "ability" lol"
p.pflags = $ | PF_THOKKED // add this flag to prevent ability being used again this jump
return true // override normal behavior (in case the character would normally have thok or something)
end
addHook("AbilitySpecial", AbilityExample) // hook the function
This example Lua script will cause Sonic to print "I just pressed jump in midair!" in the console instead of using the thok. It will not affect any other character.
I've also attached the script to this post if you want to easily get it and play it in-game to see for yourself.