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. Surprisingly, it worked well on the very first try.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).
ZScript Discussion
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!)
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!)
-
- Posts: 13791
- Joined: Tue Jan 13, 2004 1:31 pm
- Preferred Pronouns: She/Her
Re: ZScript Discussion
Last edited by Rachael on Thu Dec 01, 2016 1:30 pm, edited 1 time in total.
-
- Posts: 2059
- Joined: Tue Jan 13, 2009 4:13 pm
- Graphics Processor: ATI/AMD with Vulkan/Metal Support
- Location: Somewhere in the future
Re: ZScript Discussion
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.
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.
-
- Posts: 8196
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: ZScript Discussion
And if I recall correctly, Unreal Script is what Randi wanted it to look like from the get-go. Kinda.
-
-
- Posts: 17465
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: ZScript Discussion
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.
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.
-
- Posts: 545
- Joined: Sat Aug 30, 2014 8:21 am
Re: ZScript Discussion
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?
-
-
- Posts: 1682
- Joined: Wed May 13, 2009 3:15 am
- Graphics Processor: nVidia with Vulkan support
Re: ZScript Discussion
I should probably agree that the following code should not compile:
and indeed it doesn't:
However, the following one also fails:
Eh?
Let's try something simpler:
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.
Code: Select all
class Test : Actor
{
State A_Test()
{
bool x = true;
return ResolveState(x ? "Test" : null);
}
}
Code: Select all
Incompatible types for ?: operator
Code: Select all
class Test : Actor
{
State A_Test()
{
bool x = true;
return ResolveState(x ? "Test1" : "Test2");
}
}
Code: Select all
Cannot convert String to StateLabel
Let's try something simpler:
Code: Select all
class Test : Actor
{
State A_Test()
{
return ResolveState("Test");
}
}
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.
-
- Posts: 5032
- Joined: Sun Nov 14, 2010 12:59 am
Re: ZScript Discussion
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.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?
-
-
- Posts: 1355
- Joined: Mon May 06, 2013 8:02 am
Re: ZScript Discussion
This gives me an error:
"THINGSPEC_Switch" is apparently an unknown identifier. If I comment just that one out it loads properly.Activation THINGSPEC_ThingTargets| THINGSPEC_ThingActs|THINGSPEC_NoDeathSpecial|THINGSPEC_Switch;
-
- Lead GZDoom+Raze Developer
- Posts: 49182
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: ZScript Discussion
Yes, someone only added them to the DECORATE parser but not to the constant table.
-
- Posts: 8196
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: ZScript Discussion
So I'm trying to change a var via CustomInventory's use state:
But it keeps complaining about abortions (no pun intended). How do I do this properly?
Code: Select all
MyPlayer plr = MyPlayer(Owner);
if (plr && plr.CheckClass("MyPlayer"))
{
plr.user_chasecam = 0;
plr.user_cc = 0;
}
-
- Posts: 5032
- Joined: Sun Nov 14, 2010 12:59 am
Re: ZScript Discussion
In the casting bit, would using self instead of Owner work?
-
- Posts: 8196
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: ZScript Discussion
Huh... That actually worked. But that's also kinda screwy, when the owner is supposed to be doable... Graf, any explanation for this?
-
- Lead GZDoom+Raze Developer
- Posts: 49182
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: ZScript Discussion
Custom inventory state chains, like weapons run in the context of the item's owner. So this is normal behavior.
-
- Posts: 2246
- Joined: Tue Feb 28, 2012 12:55 pm
Re: ZScript Discussion
Is there any particular reason why youzdoom.wiki wrote:ZScript lump can include the names of other lumps for processing similar to DECORATE, but no #include word is used.
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.
-
- Lead GZDoom+Raze Developer
- Posts: 49182
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: ZScript Discussion
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.
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.