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
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: ZScript Discussion

Post by Nash »

Graf Zahl wrote:
Nash wrote:Please answer clearly - will there eventually be a way for UI classes to safely touch play classes?
You have to send the change request through the network. UI will never be able to safely touch play directly.
Best think about this like a strictly separated C/S architecture from the start, where the server data (play) is merely shadowed on the client side (UI) but changing it won't have any effect.

Realistically I have to say that all the intermingling of classes will only confuse people, to make this really clear it would be necessary to have server/play and client/ui run in completely different address spaces both with their own definitions of stuff that get tailored to each side's needs. Of course that cannot be implemented on realistic terms right now.

Maybe for GZDoom 4.0... :mrgreen:
ZZYZX wrote:EventHandler.SendNetworkEvent. See viewtopic.php?p=982446#p982446
And see various examples above on how to actually set it up.

Alright, thank you for the explanation, ZZYZX and Graf. I will learn how to use SendNetworkEvent.
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 »

Join the club, Nash. We have oreos. ;)
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: ZScript Discussion

Post by kodi »

Code: Select all

double f_moveang = (atan2(f_vely,f_velx)+360.0)%360.0; 
double f_angle = angle%360.0;
//double f_velangdif = max(f_angle, f_moveang) - min(f_angle, f_moveang) ;				
A_LogFloat( f_angle);
A_LogFloat( f_moveang);
For some reason, if I uncomment the commented line A_LogFloat(f_angle) will only update the number if f_velx or f_vely changes even if the actors angle has clearly changed. What am I missing?
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

edit: disregard what was here before, I didn't read the code properly.
You can launch GZDoom with -dumpdisasm command line argument and post the produced disasm.txt in mantis.zdoom.org (and don't forget to say the name of the function!)

Also, not sure if modulo operator works on floats properly in ZScript.
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: ZScript Discussion

Post by kodi »

The problem appears to lie in min() and max() since everything works just fine otherwise. Anyway on closer inspection, BOTH log calls appear to display the value of the "f_moveang" variable which should indeed not be changing.
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

Post disasm pls. This shoud help with esoteric stack fuckups.
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: ZScript Discussion

Post by kodi »

Straight from the WIP project so I don't know if you can make sense of this. If you need the zscript code as well I can PM it to you.

Download (file was too large for attaching even when 7zip'd
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

What's the function name that you have your code in? (the f_angle and min/max)
edit: apparently the relevant code is this and its severely broken

Code: Select all

00000030: 19020003 ldp     f2,a0,1288                   ;2,0,3
00000034: 19030004 ldp     f3,a0,1280                   ;3,0,4
00000038: b6020203 atan2   f2,f2,f3                     ;2,2,3
0000003c: a3020200 add     f2,f2,360.000                ;2,2,0
00000040: ad020200 mod     f2,f2,360.000                ;2,2,0
00000044: 19030005 ldp     f3,a0,120                    ;3,0,5
00000048: ad030300 mod     f3,f3,360.000                ;3,3,0 <--- angle%360 stored to f3
0000004c: b4030302 max     f3,f3,f2                     ;3,3,2 <--- max stored to f3
00000050: b2030302 min     f3,f3,f2                     ;3,3,2 <--- min stored to f3
00000054: a4040303 sub     f4,f3,f3                     ;4,3,3 <--- max-min is calculated improperly (f3-f3, XD) and stored to f4
00000058: 4f000300 param   a0                           ;0,3,0
0000005c: 4f000600 param   "Current angle:"             ;0,6,0
00000060: 52010200 call    [000001FBF111C9A0],2,0       ;1,2,0  [Actor.A_Log [Native]]
00000064: 4f000300 param   a0                           ;0,3,0
00000068: 4f000103 param   f3                           ;0,1,3
0000006c: 52020200 call    [000001FBF111CC70],2,0       ;2,2,0  [Actor.A_LogFloat [Native]]
00000070: 4f000300 param   a0                           ;0,3,0
00000074: 4f000601 param   "movement angle:"            ;0,6,1
00000078: 52010200 call    [000001FBF111C9A0],2,0       ;1,2,0  [Actor.A_Log [Native]]
0000007c: 4f000300 param   a0                           ;0,3,0
00000080: 4f000102 param   f2                           ;0,1,2
00000084: 52020200 call    [000001FBF111CC70],2,0       ;2,2,0  [Actor.A_LogFloat [Native]]
Resolution: min/max should use a new float register for result, wait for Graf. While I understand how is this broken, I'm not 100% sure how to fix it (50% sure it's done with Free() call, but the other 50% is idk) so won't do a PR.
Possible way to fix it for now:
double f_velangdiffang = f_angle;
double f_velangdiff;
f_velangdiff = max(f_velangdiffang, ...);
f_velangdiff -= min(f_velangdiffang, ...);
Last edited by ZZYZX on Wed Mar 08, 2017 3:22 pm, edited 10 times in total.
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: ZScript Discussion

Post by kodi »

An anonymous function in a looped state called "drive".

Edit: "severely broken" - have I managed to do something crazy or is it a bug do you think? I can pm you the code if you wish.
Edit 2: "bug in the compiler" - alright, then I can stop feeling like dumb and confused for a moment :wink: Thanks for being lenient with my less than professional bug reporting.
Last edited by kodi on Wed Mar 08, 2017 3:21 pm, edited 1 time in total.
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

It's a bug in the compiler.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49182
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

This looks like the arguments to the min instruction are not emitted properly.
Of course "max(x, y) - min(x, y)" is just the same as "abs(x-y)", so the given code isn't even optimal.

I'll have a look tomorrow what's going wrong here.
Elias79
Posts: 50
Joined: Mon Jan 30, 2017 6:09 am

Re: ZScript Discussion

Post by Elias79 »

As a beginner at Decorate and ACS the new Zscript looks very intimidating to any term of getting to grips with.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49182
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Fixed the min/max problem. It was missing a check for local variables but since I was working on the code I also did some optimizations.
Elias79
Posts: 50
Joined: Mon Jan 30, 2017 6:09 am

Re: ZScript Discussion

Post by Elias79 »

I have high hopes for this just not gonna learn it in a few years i think :P
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 »

It could take a while though, depending on how the documentation goes after 2.4 is out. Even now, 2.3 still has a lot of features undocumented due to very few folks bothering with the wiki.

I would continue working on it but I haven't had much time lately.

(Not to mention incorrectness in the documentation, there's always a chance for that.)

Return to “Scripting”