ZScript Discussion

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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.

Re: ZScript Discussion

Postby juizzysquirt » Wed Oct 19, 2016 5:50 am

Can we still declare uninitialized ones like this?

Code: Select allExpand view
int x, y, z, angle;
User avatar
juizzysquirt
 
Joined: 04 Jan 2009
Location: Knee-Deep in L.A. Meltdown

Re: ZScript Discussion

Postby Major Cooke » Wed Oct 19, 2016 5:51 am

Code: Select allExpand view
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
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: ZScript Discussion

Postby FishyClockwork » Wed Oct 19, 2016 5:52 am

Just wondering one thing.

Is ZScript going to accept the following syntax?
Code: Select allExpand view
somevar = piff == 221 ? result1 : result2;

Or do I still have to rely on?
Code: Select allExpand view
if(piff == 221)
{
    somevar = result1;
}
else
{
    somevar = result2;
}
User avatar
FishyClockwork
 
Joined: 23 Feb 2011

Re: ZScript Discussion

Postby Major Cooke » Wed Oct 19, 2016 5:53 am

DECORATE supports ternary operators so I see no reason why zscript shouldn't.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: ZScript Discussion

Postby Graf Zahl » Wed Oct 19, 2016 5:54 am

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 5:54 am, edited 1 time in total.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby Graf Zahl » Wed Oct 19, 2016 5:54 am

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



Well, of course it does.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby Major Cooke » Wed Oct 19, 2016 5:55 am

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

Code: Select allExpand view
int a1 = 0, a2 = 0, a3 = 0;
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: ZScript Discussion

Postby Major Cooke » Wed Oct 19, 2016 5:56 am

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
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: ZScript Discussion

Postby FishyClockwork » Wed Oct 19, 2016 6:01 am

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 allExpand view
f = some_expression ? r1 : r2;


EDIT:
Major Cooke wrote:DECORATE supports ternary operators

I had no idea. >_<
Last edited by FishyClockwork on Wed Oct 19, 2016 6:17 am, edited 1 time in total.
User avatar
FishyClockwork
 
Joined: 23 Feb 2011

Re: ZScript Discussion

Postby Graf Zahl » Wed Oct 19, 2016 6:02 am

Ok then, now

Code: Select allExpand view
         int localint = 0, localotherint = 1, i, j;


is doing what any sane person would expect...
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby Major Cooke » Wed Oct 19, 2016 6:03 am

So initialized vars goes first, non-initialized last?
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: ZScript Discussion

Postby Graf Zahl » Wed Oct 19, 2016 6:08 am

No, you can freely mix them, now each one creates a separate node that includes both its name and value.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby Major Cooke » Wed Oct 19, 2016 6:11 am

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
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: ZScript Discussion

Postby Graf Zahl » Wed Oct 19, 2016 6:16 am

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
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby Major Cooke » Wed Oct 19, 2016 6:32 am

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?
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: No registered users and 2 guests