[No] ZScript - Allow # to replace single characters in sprite

Moderator: GZDoom Developers

ZScript - Allow # to replace single characters in sprite

Postby kevansevans » Wed Mar 10, 2021 3:18 pm

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 allExpand view
Fire :

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

Code: Select allExpand view
Fire :

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

Code: Select allExpand view
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 allExpand view
Fire :

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


Children Classes:
Code: Select allExpand view
Fire :

   ABCE A 0;
   goto Super::Fire;


Code: Select allExpand view
Fire :

   ABCF A 0;
   goto Super::Fire;


Code: Select allExpand view
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
kevansevans
Disciple of The Great God Imp
Spotlight Team
 
Joined: 05 Oct 2010
Github ID: kevansevans
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support

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

Postby Graf Zahl » Wed Mar 10, 2021 3:38 pm

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby Gez » Wed Mar 10, 2021 6:23 pm

For your use case:

Code: Select allExpand view
Fire :

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

Code: Select allExpand view
Fire :

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

Code: Select allExpand view
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 allExpand view
Fire :

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


Children Classes:
Code: Select allExpand view
Fire :

   ABCA D 0;
   goto Super::Fire;


Code: Select allExpand view
Fire :

   ABCA E 0;
   goto Super::Fire;


Code: Select allExpand view
Fire :

   ABCA F 0;
   goto Super::Fire;



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

How 'bout that?
Gez
 
 
 
Joined: 06 Jul 2007

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

Postby kevansevans » Thu Mar 11, 2021 11:47 am

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.
User avatar
kevansevans
Disciple of The Great God Imp
Spotlight Team
 
Joined: 05 Oct 2010
Github ID: kevansevans
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests