Is there a way to terminate a named script from the console?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
Gez
 
 
Posts: 17941
Joined: Fri Jul 06, 2007 3:22 pm

Is there a way to terminate a named script from the console?

Post by Gez »

You can terminate normal numbered script by running "special acs_terminate <scriptnumber> 0"; however this doesn't work for named scripts. Or you'd need a way to know the script's secret number (I believe it's a negative hash of its name) perhaps.
User avatar
The Zombie Killer
Posts: 1528
Joined: Thu Jul 14, 2011 12:06 am
Location: Gold Coast, Queensland, Australia

Re: Is there a way to terminate a named script from the cons

Post by The Zombie Killer »

I don't believe there's a built-in solution for this, but it can pretty easily be simulated with an event handler and a console alias:

Code: Select all

class ACS_NamedTerminateHandler : EventHandler
{
    const EventPrefix = "ACS_NamedTerminate::";

    override void NetworkProcess(ConsoleEvent e)
    {
        if (e.Name.Left(EventPrefix.Length()) == EventPrefix)
        {
            let script = e.Name.Mid(EventPrefix.Length());
            GetDefaultByType('Actor').ACS_NamedTerminate(script, e.Args[0]);
        }
    }
}

Code: Select all

alias acs_namedTerminate "netEvent %\"ACS_NamedTerminate::%1\" %2"
Post Reply

Return to “Scripting”