ZScript - Allow # to replace single characters in sprite

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: ZScript - Allow # to replace single characters in sprite

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

by 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.

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

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

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?

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

by 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.

ZScript - Allow # to replace single characters in sprite

by 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 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.

Top