[Duplicate] Allow formatted string in SetStateLabel (ZScript)

Moderator: Developers

Allow formatted string in SetStateLabel (ZScript)

Postby gwHero » Fri Nov 24, 2017 6:09 pm

Concerning setting state in ACS I could code this:
Code: Select allExpand view
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 allExpand view
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 allExpand view
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
gwHero
Be your own Siddhartha
 
Joined: 08 May 2017
Location: The Netherlands

Re: Allow formatted string in SetStateLabel (ZScript)

Postby Gutawer » Sat Nov 25, 2017 6:51 am

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
Gutawer
 
 
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

Re: Allow formatted string in SetStateLabel (ZScript)

Postby Rachael » Sat Nov 25, 2017 6:59 am

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
Rachael
QZDoom + Webmaster
 
Joined: 13 Jan 2004

Re: Allow formatted string in SetStateLabel (ZScript)

Postby gwHero » Sat Nov 25, 2017 7:38 am

Thanks for the attentiveness.
User avatar
gwHero
Be your own Siddhartha
 
Joined: 08 May 2017
Location: The Netherlands


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest