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.

Re: ZScript Discussion

Postby Rachael » Thu Dec 01, 2016 1:24 pm

Nash wrote:My general advice to everyone: stop being scared and just write your first simple ZScript actor. The syntax isn't that much different from DECORATE, you just have to adhere to the new format (like adding semicolons etc, which is already written on the wiki).

I had to do that when Graf removed native support from DECORATE - pretty sure GZDoom's light actors would've stopped working, so I figured I might as well convert them to ZScript. :P Surprisingly, it worked well on the very first try.
Last edited by Rachael on Thu Dec 01, 2016 1:30 pm, edited 1 time in total.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: ZScript Discussion

Postby Zanieon » Thu Dec 01, 2016 1:25 pm

Well i'm not going to touch ZScript until Zandronum also adopts it despite me wanting to convert my mod to it to nullify some ACS/DECORATE trickery, but this will take its time to be done so until there...

And from what i'm seeing this resembles Unreal Script so, it is not being hard to me interpret the examples given in the wiki already.
User avatar
Zanieon
A Tamer of The Dark
 
Joined: 13 Jan 2009
Location: Somewhere in the future
Discord: Zanieon#3177
Twitch ID: Zanieon
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Re: ZScript Discussion

Postby Major Cooke » Thu Dec 01, 2016 1:28 pm

And if I recall correctly, Unreal Script is what Randi wanted it to look like from the get-go. Kinda. :P
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript Discussion

Postby Nash » Thu Dec 01, 2016 1:38 pm

The ZDoom community is very good with self-documentation. Just look at how detailed the wiki is today. I can tell you, as a person who's been here from the start (more or less), the ZDoom wiki started out very bare and empty compared to what you see today.

I'd say the quality of information available on the ZDoom wiki is on par with the bigger wikis like Unreal Engine 4's. Have faith in the community... before long, everything related to ZScript will be detailed in the wiki. It naturally will be, due to how active the ZDoom community is.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: ZScript Discussion

Postby D2JK » Thu Dec 01, 2016 2:08 pm

I have a script that occasionally increases player's spawnhealth, but GetSpawnHealth() seems to ignore this incrementation. In this case, do I have to return to calling an ACS script that returns the proper value, or is there a way to do this in ZScript?
D2JK
 
Joined: 30 Aug 2014

Re: ZScript Discussion

Postby Player701 » Thu Dec 01, 2016 2:31 pm

I should probably agree that the following code should not compile:

Code: Select allExpand view
class Test : Actor
{
  State A_Test()
  {
    bool x = true;
    return ResolveState(x ? "Test" : null);
  }
}

and indeed it doesn't:

Code: Select allExpand view
Incompatible types for ?: operator


However, the following one also fails:

Code: Select allExpand view
class Test : Actor
{
  State A_Test()
  {
    bool x = true;
    return ResolveState(x ? "Test1" : "Test2");
  }
}

Code: Select allExpand view
Cannot convert String to StateLabel

Eh?

Let's try something simpler:

Code: Select allExpand view
class Test : Actor
{
  State A_Test()
  {
    return ResolveState("Test");
  }
}

Success!

I can draw the following conclusion from this: apparently, the literal passed to ResolveState walks like a string and quacks like a string but it is not really a string. This is quite surprising indeed.
User avatar
Player701
 
Joined: 13 May 2009
Location: Russian Federation
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: ZScript Discussion

Postby Blue Shadow » Thu Dec 01, 2016 3:09 pm

D2JK wrote:I have a script that occasionally increases player's spawnhealth, but GetSpawnHealth() seems to ignore this incrementation. In this case, do I have to return to calling an ACS script that returns the proper value, or is there a way to do this in ZScript?

Try GetMaxHealth(). Keep in mind though that this function is native to the PlayerPawn class, not the Actor class. So you might need to do some casting.
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: ZScript Discussion

Postby kodi » Thu Dec 01, 2016 3:16 pm

This gives me an error:
Activation THINGSPEC_ThingTargets| THINGSPEC_ThingActs|THINGSPEC_NoDeathSpecial|THINGSPEC_Switch;

"THINGSPEC_Switch" is apparently an unknown identifier. If I comment just that one out it loads properly.
User avatar
kodi
Proscrastinator
 
 
 
Joined: 06 May 2013

Re: ZScript Discussion

Postby Graf Zahl » Thu Dec 01, 2016 4:06 pm

Yes, someone only added them to the DECORATE parser but not to the constant table.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby Major Cooke » Fri Dec 02, 2016 6:50 am

So I'm trying to change a var via CustomInventory's use state:

Code: Select allExpand view
         MyPlayer plr = MyPlayer(Owner);
         if (plr && plr.CheckClass("MyPlayer"))
         {
            plr.user_chasecam = 0;
            plr.user_cc = 0;
         }


But it keeps complaining about abortions (no pun intended). How do I do this properly?
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript Discussion

Postby Blue Shadow » Fri Dec 02, 2016 7:58 am

In the casting bit, would using self instead of Owner work?
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: ZScript Discussion

Postby Major Cooke » Fri Dec 02, 2016 8:06 am

Huh... That actually worked. But that's also kinda screwy, when the owner is supposed to be doable... Graf, any explanation for this?
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript Discussion

Postby Graf Zahl » Fri Dec 02, 2016 11:41 am

Custom inventory state chains, like weapons run in the context of the item's owner. So this is normal behavior.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby MaxED » Fri Dec 02, 2016 11:50 am

zdoom.wiki wrote:ZScript lump can include the names of other lumps for processing similar to DECORATE, but no #include word is used.

Is there any particular reason why you
1. introduce inconsistency (DECORATE, ACS, GLDEFS, SBARINFO and probably some other text lumps use #include).
2. make the life of editing tools programmers harder. To parse "regular" #include, all you have to do is to look for "#include" token and use the word right after it. To parse ZScript include, you'll need to recognize all top level ZScript keywords (such as "class", "struct", "enum", "const", "#define", "extend" etc.) and also update the parser when new top level keywords are introduced.
User avatar
MaxED
 
Joined: 28 Feb 2012

Re: ZScript Discussion

Postby Graf Zahl » Fri Dec 02, 2016 12:45 pm

Because the grammar cannot recursively include other lumps. For that it'd need a full preprocessor.
This is a spot that definitely needs some work. I don't like it either but so far it was ok for testing this stuff. It's also one of the main reasons why I haven't merged it yet. This definitely needs a proper fix before going officially public.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests