"How do I ZScript?"

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49182
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "How do I ZScript?"

Post by Graf Zahl »

You can't. Right now it's only a handful of types which I needed for internal definitions that are supported.
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: "How do I ZScript?"

Post by kodi »

Okay. Target.ACS_NamedExecuteAlways with a property changing script works until then.
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

@kodi: Which properties are you interested in, specifically? It may already be possible to alter them directly as variables.
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: "How do I ZScript?"

Post by kodi »

@nash PROP_TOTALLYFROZEN
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

An excerpt from my sidescroller game kit:

Code: Select all

            // set the player to totally frozen; we will customize the player
            // movement from scratch
            players[e.PlayerNumber].cheats |= CF_TOTALLYFROZEN;
 
The .cheats field is what you want to manipulate. The list of all CF_ flags is in constants.txt :)
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: "How do I ZScript?"

Post by kodi »

'preciate it!
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

Spoiler:
:lol: :lol: :lol: :lol: :lol: :lol: I don't even know where to begin. Sigh. Maybe I'll rest a few days...
Last edited by Rachael on Sun Mar 05, 2017 8:54 pm, edited 1 time in total.
Reason: spoilered
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: "How do I ZScript?"

Post by Graf Zahl »

You have to put a line 'version "2.4" into the first line of the main ZSCRIPT lump to get the non-actor related features, and maybe make a few other adjustments.
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

Yeah that's what I already did (it doesn't work with quotes BTW, eg, it only works with version 2.4, not version "2.4")

I guess it would be of great help if I just broke it down into smaller sections. I'll know what to do when I know how to fix one of them.

Code: Select all

Script error, ":zscript/engine/engine_physics.zsc" line 18:
Expression must be a modifiable value
Script error, ":zscript/engine/engine_physics.zsc" line 19:
Expression must be a modifiable value
Script error, ":zscript/engine/engine_physics.zsc" line 20:
Expression must be a modifiable value

class Z_Physics
{
    static void AlignToSlope(Actor self, double dAng, double dPitch)
    {
        vector3 fNormal = self.CurSector.FloorPlane.Normal;
        vector2 fNormalP1 = (fNormal.X != 0 || fNormal.Y != 0) ? (fNormal.X, fNormal.Y).Unit() : (0, 0);
        vector2 fNormalP2 = ((fNormal.X, fNormal.Y).Length(), fNormal.Z);
        double fAng = atan2(fNormalP1.Y, fNormalP1.X); // floor angle (not pitch!)
        double fPitch = -atan2(fNormalP2.X, fNormalP2.Y); // floor pitch
        double dDiff1 = sin(fAng - (dAng + dPitch));
        double dDiff2 = cos(fAng - dAng);
        self.Pitch = fPitch * dDiff2 + dPitch; ////////////////// <-- LINE 18
        self.Roll = fPitch * dDiff1;
        self.Angle = dAng;
    }
}

Code: Select all

Script error, ":zscript/bumi/time.zsc" line 100:
Can't call play function get from data context
Script error, ":zscript/bumi/time.zsc" line 101:
Unknown identifier 'bumi'

class FWorld : Thinker
{
    static FWorld Get()
    {
        ThinkerIterator it = ThinkerIterator.Create("FWorld", STAT_STATIC);
        let p = FWorld(it.Next());
        if (p == null)
        {
            p = new("FWorld").Init();
        }
        return p;
    }
}

class Z_Time
{
    /*
     * Gets current second of minute.
     */
    static int T_GetSecond(void)
    {
        let bumi = FWorld.Get(); /////////// <-- LINE 100
        return bumi.timeSecond;
    }



Just these for now. Any advice would be appreciated.

[I edited the post to show where the "get" function is coming from. This is the global thinker solution Graf Zahl gave me a while back]
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: "How do I ZScript?"

Post by Major Cooke »

Try replacing 'self' with something else. Self is a reserved word last I checked. If that still doesn't resolve it, maybe try a struct? I use structs all the time for global access to functions.

Also Nash, can you kindly put your long post in spoilers please? That's a lot of scrolling...
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: "How do I ZScript?"

Post by Major Cooke »

So Graf, how can we access the player via menus and/or manipulate them aside cvars? I would like to put things they purchase immediately into their inventory so the menus can self-update when attempting to visit it again.
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

Major Cooke wrote:maybe try a struct? I use structs all the time for global access to functions.
Minimal example please? Thanks
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: "How do I ZScript?"

Post by Graf Zahl »

Nash wrote:Yeah that's what I already did (it doesn't work with quotes BTW, eg, it only works with version 2.4, not version "2.4")
If that is the case the devbuild is not the latest commit and may also be the cause of other errors.
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

I have already double-checked and I am indeed on the latest commit. The version directive actually works with and without quotes. Sorry for the wrong information.

Will use quotes as per suggestion though.

However I am still getting my 187 errors. I've already posted my code fragments above. Please advise...
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: "How do I ZScript?"

Post by Graf Zahl »

Major Cooke wrote:So Graf, how can we access the player via menus and/or manipulate them aside cvars
You can't. That's the whole point of the subsystem separation and the discussion about this had been going on for quite some time already.
If you try to manipulate the game directly from the menu the game will lose any ability to be run in multiplayer or to have demos recorded. All changes the menus make to the playsim have to be routed through the network but that won't run game tics if the menu pauses the game. So running a "give item amount" command will work but feedback may be delayed.

Return to “Scripting”