Allow formatted string in SetStateLabel (ZScript)

Moderator: GZDoom Developers

Post Reply
User avatar
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

Allow formatted string in SetStateLabel (ZScript)

Post by gwHero »

Concerning setting state in ACS I could code this:

Code: Select all

str stat = StrParam(s:"Cyclus", d:phase);  // phase has a value of 0-27
SetActorState(moonTID, stat);
In ZScript in the code of the actor I have to use this ugly switch for 28 different states:

Code: Select all

switch (phase)
{
	case 0: SetStateLabel("Cyclus0"); break;
	case 1: SetStateLabel("Cyclus1"); break;
	case 2: SetStateLabel("Cyclus2"); break;
	case 3: SetStateLabel("Cyclus3"); break;
 etc. (you get the idea :))
instead of just coding this:

Code: Select all

string stat = string.format("%s%d", "Cyclus", phase);
SetStateLabel(stat);
which is not allowed ('cannot convert string to statelabel').
So, it would be nice to allow setting statelabel with a formatted string like in the example (for at least actors with no monster-AI like the ACS function).
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: Allow formatted string in SetStateLabel (ZScript)

Post by Gutawer »

It seems to me that this is essentially the same feature request as this one - viewtopic.php?f=15&t=56590&p=999932.
As far as I'm aware, GZDoom converts strings to StateLabels at compile time and there's no way to convert them to a StateLabel during runtime. If that feature was added in, this would work too.
User avatar
Rachael
Posts: 13530
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Allow formatted string in SetStateLabel (ZScript)

Post by Rachael »

Gutawer wrote:It seems to me that this is essentially the same feature request as this one - viewtopic.php?f=15&t=56590&p=999932.
Correct. Thank you for pointing that out.
User avatar
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

Re: Allow formatted string in SetStateLabel (ZScript)

Post by gwHero »

Thanks for the attentiveness.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”