Good question! Overall you'll want to use coroutines. The short pseudo code would be this:
Also, feel free to ask on our scripters Discord, as commonly that has more folks around to quickly answer things
https://discord.gg/EYtHHkE7tvfunction SpecialFunction(ship)
if ship == nil then return end
if not ship:isValid() then return end
async.run(function()
--shut off shields (write code here)
local n_seconds = 5
async.await(mn.waitAsync(n_seconds))
if ship ~= nil and ship:isValid() then
--re enable shields (write code here)
end
end)
end
engine.addHook("On Weapon Collision", function()
SpecialFunction(hv.Ship)
end,
{State="GS_STATE_GAME_PLAY", ["Weapon class"]="WEAPONCLASSNAME_from_weapons.tbl"}
)