Named scripts

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
Enjay
 
 
Posts: 26946
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Named scripts

Post by Enjay »

I suppose this kind of pertains to editing...

I don't know how many people keep an eye on the changelog but this has been an often requested feature so I'm surprised that it hasn't been talked about yet. Randy has been busy adding support for named scripts plus a few associated features/improvements. The relevant changelog entries are copied below. Personally, I think that this will be a very useful feature and make it much easier to avoid clashing script numbers/names and so on.

Thank you kindly Randy. :D

R3358
Added support for named scripts. (Of course, without engine support, it doesn't matter. :)
Increase the maximum script number from 999 to 32767.
Only create dummy scripts for scripts WadAuthor's error checker might be interested in: If its number doesn't fit in a byte, WadAuthor doesn't need to know about it, because you can't call it directly from a Hexen-format map.

R3359
Added support for loading named ACS scripts. You can't run them directly at the moment, but you can still use them for automatically executed script types (like open and enter).
Change the DACSThinker::RunningScripts array into a TMap so that it can catalog the new range of ACS scripts (up to 32767).

R3363
Make deferred scripts work with named scripts.
Added ACS_Named* function variants of the ACS_* specials that take script names instead of numbers. As these are functions and not specials, they can only be used from inside ACS.

R3364
Added action functions that work with script names instead of script numbers. They are named the same as their ACS function equivalents. e.g. From DECORATE, you can now use ACS_NamedExecuteAlways to run a script with a name.
User avatar
printz
Posts: 2648
Joined: Thu Oct 26, 2006 12:08 pm
Location: Bucharest, Romania
Contact:

Re: Named scripts

Post by printz »

If we get to have new args that aren't limited to numbers it will be awesome. Imagine all the power! :grr:
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Named scripts

Post by randi »

printz wrote:If we get to have new args that aren't limited to numbers it will be awesome.
Sorry, variables in ACS are all numeric-based, so it isn't going to happen.

Anyway, aside from maybe UDMF support, this should be feature-complete now. (I will probably end up having to add an arg0string property, since arg0 has to be an integer, going by the UDMF spec. But should I add new specials to go with them? Technically, I could use the existing ACS specials and use the name if arg0string is present on the line, but I don't know if that would present difficulty to editors.)

A concrete example:

Code: Select all

script "A script with a name" (void)
{
    printbold(s:"This script has a name, and you ran it!");
} 
Then call it like this:

Code: Select all

// From DECORATE or ACS:
ACS_NamedExecuteAlways("A script with a name", 0);

// From the console:
pukename "A script with a name"
(Or make it OPEN and let the world run it on map load.)

Hopefully this should make using ACS in game mods much more convenient.
User avatar
printz
Posts: 2648
Joined: Thu Oct 26, 2006 12:08 pm
Location: Bucharest, Romania
Contact:

Re: Named scripts

Post by printz »

Oh, scripts are named that way? I thought they're supposed to look like identifiers. Heh.
randy wrote:(I will probably end up having to add an arg0string property, since arg0 has to be an integer, going by the UDMF spec. But should I add new specials to go with them? Technically, I could use the existing ACS specials and use the name if arg0string is present on the line, but I don't know if that would present difficulty to editors.)
That's what I meant!
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Named scripts

Post by randi »

printz wrote:Oh, scripts are named that way? I thought they're supposed to look like identifiers.
Nope. People already use #define to give scripts symbolic names, so they have to be strings, or all the people who had #defined names for their scripts will have their scripts break if they compile them with the new ACC.
printz wrote:That's what I meant!
Oh.
User avatar
Nash
 
 
Posts: 17487
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Named scripts

Post by Nash »

... HOLY CRAP I CAME
Blzut3
 
 
Posts: 3202
Joined: Wed Nov 24, 2004 12:59 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: Named scripts

Post by Blzut3 »

randy wrote:Sorry, variables in ACS are all numeric-based, so it isn't going to happen.
What about adding support for more than 3 arguments?
Gez
 
 
Posts: 17938
Joined: Fri Jul 06, 2007 3:22 pm

Re: Named scripts

Post by Gez »

randy wrote:Anyway, aside from maybe UDMF support, this should be feature-complete now. (I will probably end up having to add an arg0string property, since arg0 has to be an integer, going by the UDMF spec. But should I add new specials to go with them? Technically, I could use the existing ACS specials and use the name if arg0string is present on the line, but I don't know if that would present difficulty to editors.)
Nah, the same logic ("use arg0string if it's not its default value of "", use arg0 if it is") isn't incredibly difficult to implement.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49223
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Named scripts

Post by Graf Zahl »

So...

Next step could be some functions that would allow ACS to work as a cheap substitute for Doomscript...
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Named scripts

Post by NeuralStunner »

Graf Zahl wrote:Next step could be some functions that would allow ACS to work as a cheap substitute for Doomscript...
I don't think it will get that far.

Named scripts will improve libraries and Decorate integration, but as a whole the avaialble features are still too high level. I always got the impression that DoomScript (ZScript?) would be much more low level, to the point of modifying action functions (for example) without requiring an EXE modification.

As it is, now the primary argument against using ACS in your Decorate mods (the other being in effect "I don't want to learn ACS") will be gone. Aside from agreeing that an expanded argument count would be nice, I'm satisfied with the current state of integration.
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Named scripts

Post by randi »

New ACC is up: ACC 1.51
Blzut3 wrote:What about adding support for more than 3 arguments?
I think that would be a bit more involved than giving scripts names.

My first idea was, rather than named scripts, to give DECORATE the ability to execute ACS functions directly. However, there's just too much in ACS that depends on having a script running to do anything. Allowing for direct execution of functions looks like a lot of work for not enough gain. In the end, I went with named scripts, which required fairly minimal changes and still addresses the primary complaint against using ACC for mods: script number conflicts.
User avatar
Kinsie
Posts: 7402
Joined: Fri Oct 22, 2004 9:22 am
Graphics Processor: nVidia with Vulkan support
Location: MAP33
Contact:

Re: Named scripts

Post by Kinsie »

AaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAA!!!!!

This is perfect! I can't wait to use it!
User avatar
Enjay
 
 
Posts: 26946
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Named scripts

Post by Enjay »

Kinsie wrote:This is perfect! I can't wait to use it!
It looks like Randy's last couple of revisions added UDMF support so I guess it's feature complete now. I'll have a build of r3372 up on the DRD server in about 10 minutes.
User avatar
printz
Posts: 2648
Joined: Thu Oct 26, 2006 12:08 pm
Location: Bucharest, Romania
Contact:

Re: Named scripts

Post by printz »

Will there also be for GZDoom? :wub:
User avatar
Jimmy
 
 
Posts: 4726
Joined: Mon Apr 10, 2006 1:49 pm
Preferred Pronouns: He/Him
Contact:

Re: Named scripts

Post by Jimmy »

CAKE YEAH! You guys rule! :D
Locked

Return to “Editing (Archive)”