Allow formatted string in SetStateLabel (ZScript)

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: Allow formatted string in SetStateLabel (ZScript)

Re: Allow formatted string in SetStateLabel (ZScript)

by gwHero » Sat Nov 25, 2017 6:38 am

Thanks for the attentiveness.

Re: Allow formatted string in SetStateLabel (ZScript)

by Rachael » Sat Nov 25, 2017 5: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.

Re: Allow formatted string in SetStateLabel (ZScript)

by Gutawer » Sat Nov 25, 2017 5: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.

Allow formatted string in SetStateLabel (ZScript)

by gwHero » Fri Nov 24, 2017 5:09 pm

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

Top