ZScript - Allow # to replace single characters in sprite

Moderator: GZDoom Developers

Post Reply
User avatar
kevansevans
Spotlight Team
Posts: 420
Joined: Tue Oct 05, 2010 12:04 am
Graphics Processor: nVidia with Vulkan support
Contact:

ZScript - Allow # to replace single characters in sprite

Post by kevansevans »

Currently as it stands, ----/#### is used to adopt the previous sprite, but I would like to suggest that it would be greatly more flexible to have it adopt the previous characters instead.

The current use case I have for this is that I have a parent class that will have multiple children class that will behave similarly, where more or less the only differences would be the sprite animations.

Code: Select all

Fire :

   ABCD A A_SomeAction();
   ABCD B A_SomeOtherThing();
   ABCD C A_CoolFunctionHere();
   ABCD D A_Fire();
   ///blah blah blah

Code: Select all

Fire :

   ABCE A A_SomeAction();
   ABCE B A_SomeOtherThing();
   ABCE C A_CoolFunctionHere();
   ABCE D A_Fire();
   ///blah blah blah

Code: Select all

Fire :

   ABCF A A_SomeAction();
   ABCF B A_SomeOtherThing();
   ABCF C A_CoolFunctionHere();
   ABCF D A_Fire();
   ///blah blah blah
And for every child class that I need to make, I would have to type this code over and over. Alternatively, it could be more like this:

Parent class:

Code: Select all

Fire :

   ABC# A A_SomeAction();
   ABC# B A_SomeOtherThing();
   ABC# C A_CoolFunctionHere();
   ABC# D A_Fire();
   ///blah blah blah
Children Classes:

Code: Select all

Fire :

   ABCE A 0;
   goto Super::Fire;

Code: Select all

Fire :

   ABCF A 0;
   goto Super::Fire;

Code: Select all

Fire :

   ABCG A 0;
   goto Super::Fire;

While text data isn't that costly these days, I imagine this would also be decent for reducing file sizes as well.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49073
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript - Allow # to replace single characters in sprite

Post by Graf Zahl »

Sorry, but this cannot be done engine-side. A sprite internally is just a number and this cannot be represented efficiently. Using '####' is your only viable option.
Gez
 
 
Posts: 17835
Joined: Fri Jul 06, 2007 3:22 pm

Re: ZScript - Allow # to replace single characters in sprite

Post by Gez »

For your use case:

Code: Select all

Fire :

   ABCA D A_SomeAction();
   ABCB D A_SomeOtherThing();
   ABCC D A_CoolFunctionHere();
   ABCD D A_Fire();
   ///blah blah blah

Code: Select all

Fire :

   ABCA E A_SomeAction();
   ABCB E A_SomeOtherThing();
   ABCC E A_CoolFunctionHere();
   ABCD E A_Fire();
   ///blah blah blah

Code: Select all

Fire :

   ABCA F A_SomeAction();
   ABCB F A_SomeOtherThing();
   ABCC F A_CoolFunctionHere();
   ABCD F A_Fire();
   ///blah blah blah
Could be folded like this:

Parent class:

Code: Select all

Fire :

   ABCA # A_SomeAction();
   ABCB # A_SomeOtherThing();
   ABCC # A_CoolFunctionHere();
   ABCD # A_Fire();
   ///blah blah blah
Children Classes:

Code: Select all

Fire :

   ABCA D 0;
   goto Super::Fire;

Code: Select all

Fire :

   ABCA E 0;
   goto Super::Fire;

Code: Select all

Fire :

   ABCA F 0;
   goto Super::Fire;

Yep, just switching the frame latter with the sprite letter you want to change.

How 'bout that?
User avatar
kevansevans
Spotlight Team
Posts: 420
Joined: Tue Oct 05, 2010 12:04 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: ZScript - Allow # to replace single characters in sprite

Post by kevansevans »

I have a lot of sprites to go through, my example undersells it a little, haha. Much appreciated though.
On re-read I think i misread it, and suddenly this makes more sense, thank you!

Wait, nope, I take that back. I have way too many sprites at the moment for this trick to work.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”