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
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

Code: Select all

    Array<Line> Next()
    {
        Array<Line> loop;
        
        
        
        return loop;
    }
This function makes my GZDoom silently suicide on init. (closes without error, remains in the process list)
Replacing Line with anything else still causes it.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49184
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

It should print an error. You cannot return local stack variables.
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

Pls add either Actor.GetArg0Str() or more universal typecast from int to Name (since arg0str is Name(-args[0]), but that's not possible due to how VM works).
User avatar
Marrub
 
 
Posts: 1198
Joined: Tue Feb 26, 2013 2:48 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Arch Linux
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: ZScript Discussion

Post by Marrub »

With the new [wiki]ScriptCall[/wiki] function, would it be possible to call a function on the activator, rather than a static function?
Or, at least, some way to identify the activator in a way that a static function could find them.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49184
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Calling a function on the activator is not possible because the activator has no type and you cannot extend Actor.
Passing the activator should be doable later but will be tricly to implement safely.
User avatar
Marrub
 
 
Posts: 1198
Joined: Tue Feb 26, 2013 2:48 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Arch Linux
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: ZScript Discussion

Post by Marrub »

Doesn't the ZScript VM have RTTI? If so, couldn't you just look up the type from that?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49184
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

... which may bring us into even worse undefined situations if the function that gets called can differ, based on class, and ever require different parameters if you get two classes with the same method name but no relation to each other. Far too dangerous for my taste. A static function is always a well-defined entry point.
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: ZScript Discussion

Post by Nash »

I wonder if it's possible to hack Visual Studio or VS Code somehow to support ZScript? Having Intellisense on ZScript files would be cool to have.

EDIT: VS Code is promising. Just by installing the C++ extension and then opening your ZScript files as C++ (I had to change the ZScript file to have a .cpp extension) works quite well. You can do let <something> and autocompletion works (I see all my custom fields!), and most methods inside your class are recognized and can be peeked at, just like in Visual Studio.

What doesn't work yet is if you do MyClass.MyMethod. Need to figure this out.

I think with a little tweaking, a ZScript extension can be made to fully recognize it.
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: ZScript Discussion

Post by Nash »

let p = new("MyClass");

MyClass cannot be an Actor, otherwise the game crashes. Bug or by design?
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

Actor.Spawn
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: ZScript Discussion

Post by Nash »

I don't want it to be an Actor. It's just a data class.
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

In which case you shouldn't try to make an Actor-derived class using new().
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: ZScript Discussion

Post by Nash »

Man, I wish there was a way to only compile ZScript without actually running the game. I'm guessing the sum of the total accumulated time every time my ZScript fails to make the game start has reached hours by now, haha...
User avatar
Xaser
 
 
Posts: 10773
Joined: Sun Jul 20, 2003 12:15 pm

Re: ZScript Discussion

Post by Xaser »

Hmm, which brave soul is going to write ZSLint? :P


[official xasernotice: i'm non-volunteering for that D:]
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: ZScript Discussion

Post by Matt »

What's wrong with batch files/bash scripts and binding F10 to quit without dialogue?

Return to “Scripting”