ZScript Discussion

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
juizzysquirt
Posts: 126
Joined: Sun Jan 04, 2009 3:29 pm
Location: Knee-Deep in L.A. Meltdown

Re: ZScript Discussion

Post by juizzysquirt »

Can we still declare uninitialized ones like this?

Code: Select all

int x, y, z, angle;
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Code: Select all

int a1, a2, a3;
int b1 = 1, b2 = 2, b3 = 3;
Sounds like it'll be like this where the type must be the same for all within the commas, and they either all must be declared initialized or not, right?

(ninjasquirt... :P)
User avatar
Fishytza
Posts: 788
Joined: Wed Feb 23, 2011 11:04 am
Preferred Pronouns: No Preference

Re: ZScript Discussion

Post by Fishytza »

Just wondering one thing.

Is ZScript going to accept the following syntax?

Code: Select all

somevar = piff == 221 ? result1 : result2;
Or do I still have to rely on?

Code: Select all

if(piff == 221)
{
    somevar = result1;
}
else
{
    somevar = result2;
}
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

DECORATE supports ternary operators so I see no reason why zscript shouldn't.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

I'll make it sane (i.e the way C does it.)
I see no point explaining this insane construct as it won't survive the next hour... :twisted:.
Last edited by Graf Zahl on Wed Oct 19, 2016 4:54 am, edited 1 time in total.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Major Cooke wrote:DECORATE supports ternary operators so I see no reason why zscript shouldn't.

Well, of course it does.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Which means requiring them all to be declared initialized, and be at the top of the class.

Code: Select all

int a1 = 0, a2 = 0, a3 = 0;
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Graf Zahl wrote:Well, of course it does.
Oh snap, I just recalled ACS doesn't support ternary operators. That would explain why he asked.
User avatar
Fishytza
Posts: 788
Joined: Wed Feb 23, 2011 11:04 am
Preferred Pronouns: No Preference

Re: ZScript Discussion

Post by Fishytza »

I wasn't asking because of ACS. I was asking because, to me, it's a little more convenient to be able to declare

Code: Select all

f = some_expression ? r1 : r2;
EDIT:
Major Cooke wrote:DECORATE supports ternary operators
I had no idea. >_<
Last edited by Fishytza on Wed Oct 19, 2016 5:17 am, edited 1 time in total.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Ok then, now

Code: Select all

			int localint = 0, localotherint = 1, i, j;
is doing what any sane person would expect...
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

So initialized vars goes first, non-initialized last?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

No, you can freely mix them, now each one creates a separate node that includes both its name and value.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Okay, so auto detection for type is only for constants then, it appears.

On that note, I noticed you used the word "double" instead of "float" earlier. We're to use double then? Or are you allowing both words to translate into the same thing internally, or will they be truly different?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

The language has support for single precision floats. But for the time being these are disabled and if they ever come to pass, only in arrays, classes or structs. There's still people around who actually believe that having smaller sized versions of numeric types is a good idea (which I disagree with, let 'em burn!)
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Double it is! Wiki updated. I'm glad the naming convention is actually correct now, because for a while that did confuse me when the word 'float' translated into 'double' in DECORATE. (Even before that, it was fixed_t. So happy that's gone.)

On that note, assuming non-constant strings/names are/will be a thing, I'm assuming we'll have access to functions like stricmp, yes?

Return to “Scripting”