"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.

Re: "How do I ZScript?"

Postby Graf Zahl » Sun Mar 05, 2017 2:50 pm

You can't. Right now it's only a handful of types which I needed for internal definitions that are supported.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: "How do I ZScript?"

Postby kodi » Sun Mar 05, 2017 2:59 pm

Okay. Target.ACS_NamedExecuteAlways with a property changing script works until then.
User avatar
kodi
Proscrastinator
 
 
 
Joined: 06 May 2013

Re: "How do I ZScript?"

Postby Nash » Sun Mar 05, 2017 3:01 pm

@kodi: Which properties are you interested in, specifically? It may already be possible to alter them directly as variables.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: "How do I ZScript?"

Postby kodi » Sun Mar 05, 2017 3:04 pm

@nash PROP_TOTALLYFROZEN
User avatar
kodi
Proscrastinator
 
 
 
Joined: 06 May 2013

Re: "How do I ZScript?"

Postby Nash » Sun Mar 05, 2017 3:15 pm

An excerpt from my sidescroller game kit:

Code: Select allExpand view

            
// 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
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: "How do I ZScript?"

Postby kodi » Sun Mar 05, 2017 3:17 pm

'preciate it!
User avatar
kodi
Proscrastinator
 
 
 
Joined: 06 May 2013

Re: "How do I ZScript?"

Postby Nash » Sun Mar 05, 2017 6:34 pm

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
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: "How do I ZScript?"

Postby Graf Zahl » Sun Mar 05, 2017 6:40 pm

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: "How do I ZScript?"

Postby Nash » Sun Mar 05, 2017 6:53 pm

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 allExpand view

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.!= 0 || fNormal.!= 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 allExpand view

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
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: "How do I ZScript?"

Postby Major Cooke » Sun Mar 05, 2017 8:03 pm

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
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: "How do I ZScript?"

Postby Major Cooke » Sun Mar 05, 2017 8:27 pm

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
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: "How do I ZScript?"

Postby Nash » Mon Mar 06, 2017 2:04 am

Major Cooke wrote:maybe try a struct? I use structs all the time for global access to functions.


Minimal example please? Thanks
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: "How do I ZScript?"

Postby Graf Zahl » Mon Mar 06, 2017 2:09 am

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: "How do I ZScript?"

Postby Nash » Mon Mar 06, 2017 2:17 am

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
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: "How do I ZScript?"

Postby Graf Zahl » Mon Mar 06, 2017 2:51 am

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.
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: KaptainMicila, MFG38 and 0 guests