"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 Matt » Wed Mar 01, 2017 6:17 pm

Xaser wrote:
ZZYZX wrote:Non-DECORATE-like features are not stable and not recommended to use, especially for a newbie.

Where is this idea coming from? What features in the current release build of GZDoom are considered "not stable and not recommended to use"?

I'm assuming "all ZScript not in the latest release"
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: "How do I ZScript?"

Postby ZZYZX » Wed Mar 01, 2017 6:24 pm

Xaser wrote:
ZZYZX wrote:Non-DECORATE-like features are not stable and not recommended to use, especially for a newbie.

Where is this idea coming from? What features in the current release build of GZDoom are considered "not stable and not recommended to use"?

Event handlers, menus, statusbar (if any yet).
Especially event handlers. They are somewhat fixed compared to the very first merged version, but render part is still not decided.
Menus are somewhat complete but still subject to random modification according to what Graf said about devbuilds.
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine
Discord: ZZYZX#1394
Github ID: jewalky

Re: "How do I ZScript?"

Postby Jaxxoon R » Wed Mar 01, 2017 6:41 pm

So uh... is there a way to get a parent actor's pitch? It's probably one of the zscript actor functions that does it, but there's so many that I don't know where to look. I was thinking of giving a disc-shaped flatsprite projectile some depth using warped actors. For one of them I was simply using A_Warp and the COPYPITCH and it works really well for that one, but for the second I'll need to roll it to match the parent's pitch.
User avatar
Jaxxoon R
 
Joined: 05 May 2014

Re: "How do I ZScript?"

Postby ZZYZX » Wed Mar 01, 2017 6:46 pm

You might want to use either my or Nash's code from this page that applies angle+pitch rotation to a flatsprite. It uses sector floor angle, but changing it to use angle/pitch variables from an actor is straightforward.
Also, parent's angles are received using master.angle/master.pitch/master.roll/whatever. Or target, or tracer, whatever you use for storing the parent pointer.
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine
Discord: ZZYZX#1394
Github ID: jewalky

Re: "How do I ZScript?"

Postby Matt » Wed Mar 01, 2017 7:17 pm

If I only need precision within 1 degree, but for possibly dozens of actors polling multiple times every tic, is it worth doing a lookup table for sine and cosine values? (I'm trying to keep a certain object directly in front of another at a fixed distance, or in other cases calculating a movement trajectory or a position relative to someone's FOV... well a lot of things really)
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: "How do I ZScript?"

Postby Xaser » Wed Mar 01, 2017 7:41 pm

ZZYZX wrote:Event handlers, menus, statusbar (if any yet).

I think the sentiment we ought to be expressing is "try to shy away from dev builds," then. "Non-DECORATE-like features" seemingly refers to a wide range of features (custom functions, structs, iterators, etc.) which are stable in the latest official build, and we certainly don't want to be discourage use and exploration of those.
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: "How do I ZScript?"

Postby ZZYZX » Wed Mar 01, 2017 7:50 pm

Yes. Sorry for the bad wording.
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine
Discord: ZZYZX#1394
Github ID: jewalky

Re: "How do I ZScript?"

Postby Xaser » Wed Mar 01, 2017 8:16 pm

It's cool -- we're on the same page, so all's well. I point these things out not to be a meanie-butt (though it probably comes across that way sometimes D:) but because we're kinda in that critical early phase where the adoption rate hasn't really taken off yet. I don't think ZScript's at any particular risk, but every bit helps.

*reminds self to continue working on his ZScript projects at some point.*
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: "How do I ZScript?"

Postby Ed the Bat » Wed Mar 01, 2017 8:43 pm

I know EventHandlers are new and still subject to change, and my grasp of them is very basic at this point anyway, but could I ask for help in making an event that plays with a keypress? For years now, I did this:
KEYCONF:
Code: Select allExpand view
addmenukey "Taunt" taunt
alias taunt "pukename MGTaunt"
ACS:
Code: Select allExpand view
script "MGTaunt"(void)
   {PlaySound(0,"*taunt",CHAN_VOICE);}

...and everything I can convert from ACS to ZScript is another victory in my book.
User avatar
Ed the Bat
I'm tired. I want to go home.
 
Joined: 03 May 2012
Location: Maryland, US

Re: "How do I ZScript?"

Postby Major Cooke » Wed Mar 01, 2017 9:00 pm

ZZYZX seriously needs to write something about that in the wiki, for whatever is good to go. Everything else it's understandable that they remain undocumented, a la the rendering stuff, since they're bound to change.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: "How do I ZScript?"

Postby Nash » Wed Mar 01, 2017 11:25 pm

Ed:

Download this file [ https://mantis.zdoom.org/file_download. ... 3&type=bug ] or if hot-linking doesn't work, go here and scroll down to the comments and download sprint key.pk3 [ https://mantis.zdoom.org/view.php?id=362 ]

(PS don't mind the bug thread, the bug is already fixed with the latest devbuilds, well at least from all my testing)

The jist of it is, you now bind your control to "event xxx" or "netevent xxx" (should be self-explanatory which is which I hope). You then create an EventHandler that checks for those things. Just look inside sprint key.pk3.

I forgot to setup a MENUDEF for it in my example WAD, so you have to bind the key yourself. Open the console and type bind Shift "netevent SprintKeyHandler". In a real project, you'd it up in the Controls menu in MENUDEF, or KEYCONF or whatever.

You must setup any event handlers you want to be enabled inside the MAPINFO. You can add as many EventHandlers as you want inside MAPINFO, it's not limited to just one.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: "How do I ZScript?"

Postby Ed the Bat » Wed Mar 01, 2017 11:27 pm

Excellent, thank you! I've got a working EventHandler right now that replaces my old ACS ENTER script, but I was less certain about where to go from there on more complex things. Thanks again!
User avatar
Ed the Bat
I'm tired. I want to go home.
 
Joined: 03 May 2012
Location: Maryland, US

Re: "How do I ZScript?"

Postby Nash » Wed Mar 01, 2017 11:52 pm

Graf Zahl wrote:Do I understand this correctly that you cannot access the fields of a function return value directly?


Code: Select allExpand view

class A 
: ZombieMan
{

    Vector2 v2;

    Vector2 GetVec2(void)
    {
        return v2;
    }

    void DoSomething(void)
    {
        Vector2 cool;
        Vector3 blah;

        cool = GetVec2();

        // not possible
        
blah = (GetVec2().XGetVec2().Y0);

    }

}


Correct. This doesn't work. Bug or not possible?
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: "How do I ZScript?"

Postby Xaser » Thu Mar 02, 2017 10:41 am

@Nash: While this indeed seems like a bug (and therefore worth fixing for sure), it's worth emphasizing that for your particular case, it's better to keep the local variable so you don't have the overhead of calling the get function (BumiHandler._W_GetWind(), in your proper case) twice.
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: "How do I ZScript?"

Postby Nash » Thu Mar 02, 2017 10:50 am

Alright, noted... just how expensive is calling the global thinker, by the way? Since the code only does the Init once and never again after that...
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: Player701 and 0 guests