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 Graf Zahl » Tue May 16, 2017 2:50 am

Illasera wrote:Your first two arguments would probably hold more water if zscript could store and load compiled data and not compile things at runtime.


A memset by its very design is dangerous. First, classes are being constructed, so you cannot memset them, it would clobber the internal data.
That leaves local variables - and stack is always zeroed before being used.

To sum it up: There is no need to memset, it would be a scripter's choice if done, but since memset doesn't have even the slightest sanity checks it's simply not going to happen.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby Xaser » Wed May 17, 2017 9:15 am

Got a couple of broad conceptual questions, since for some reason I've got some knowledge gaps:
  • What precisely causes the "ambiguous context pointer" error to be thrown? There's inevitably an extremely-obvious pattern here that I'm missing. :P
  • What precisely is the 'Name' datatype? Names and Strings seem to be almost interchangeable, but I'd rather use the correct types in code, even if it's nitpicky. Trying to avoid Javascript-esque "use whatever quotation marks you feel like" habits.
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: ZScript Discussion

Postby Gutawer » Wed May 17, 2017 9:54 am

For the second ones, Names aren't case-sensitive, so they are often used for stuff like class names (think stuff like if (actor is "someclassname")), and lump names (when applicable, such as creating a font variable). This also means that the case-insenstitive string comparison operator (~==) won't work, since there isn't any point to it on a Name.
User avatar
Gutawer
User Accounts Assistant
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

Re: ZScript Discussion

Postby Gez » Wed May 17, 2017 10:39 am

Xaser wrote:What precisely is the 'Name' datatype?

Internally a name is an index to a string table, so a name is a lightweight variable. That means that they're much faster than strings for whenever you've got tons of comparisons to make.
Gez
 
 
 
Joined: 06 Jul 2007

Re: ZScript Discussion

Postby Blue Shadow » Wed May 17, 2017 10:57 am

Sounds like strings in ACS.
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 Illasera » Thu May 18, 2017 11:20 am

Time for another question, Any support for C standard library math functions via callbacks on zscript? (sqrt, log and friends)
that should be safe to add i believe, I am talking about callbacks in zscript that are directly linked to the c standard library under gzdoom.

If so, how do i access them? if there is a wiki page on it? i did look for it , couldn't find it, do i access it as i would with a normal c function?

i can write them myself under zscript if they do not exist as of yet but i am afraid the overhead will be too great if i am to use them in a recursive manner,
some of them can be really expansive (Due to lack of optimization and prefetching), specially when handling functions that use division operator a lot (For those who don't know, dividing stuff , both integers and floating points can be very expansive on the x86 family of hardware, can span up to hundrads of cycles (SIMD excluded) not taking into account cache misses, but that's another topic).

As far as having a scripter writing them in zscript, Such functions do go through a lot of optimization under most C standard libraries, hence their version is better. a direct callback is preferable.

Thanks in advance for any answer towards the question above.
Illasera
Software Engineer
 
Joined: 11 May 2017

Re: ZScript Discussion

Postby Blue Shadow » Thu May 18, 2017 1:59 pm

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 Xaser » Thu May 18, 2017 2:18 pm

Gez wrote:Internally a name is an index to a string table, so a name is a lightweight variable. That means that they're much faster than strings for whenever you've got tons of comparisons to make.

Hmm, interesting -- presumably then, it'd also be the datatype to use for static strings in Default blocks (e.g. RenderStyle 'Add') and the like?

I'm mostly just worried about some scenario where I'm supplying type 'x' and it has to spend time internally converting to type 'y', unless the ZScript interpreter is doing this once-and-done on startup in some places. Molehills, I'm sure, but it's always good to know. :P
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: ZScript Discussion

Postby Illasera » Thu May 18, 2017 3:15 pm



Oh its in decorate, i was looking under zscript, THANK YOU!
yea i know its an extension to some degree but i forgot all about it, my bad.
Illasera
Software Engineer
 
Joined: 11 May 2017

Re: ZScript Discussion

Postby Graf Zahl » Fri May 19, 2017 9:57 am

Xaser wrote:
Gez wrote:Internally a name is an index to a string table, so a name is a lightweight variable. That means that they're much faster than strings for whenever you've got tons of comparisons to make.

Hmm, interesting -- presumably then, it'd also be the datatype to use for static strings in Default blocks (e.g. RenderStyle 'Add') and the like?


No. The render style is just translated to an actual style value. The string notation comes from a time when it couldn't be done with a symbolic constant, but why change it if it ain't broke.?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby Xaser » Fri May 19, 2017 10:28 am

Hmm, that one certainly falls in the "doesn't matter" camp, then. Maybe a better example would be something like Inventory.Icon -- since I'm not going to be doing any manipulation of the value, is this a case for a Name?
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: ZScript Discussion

Postby Graf Zahl » Fri May 19, 2017 10:35 am

No, that's a FTextureID internally.
Damage types get stored as a name, for example, as does species, but that's really everything, aside from a few oversights in third-party submissions.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby D2JK » Sat May 27, 2017 5:53 am

Are there any plans for making overlay states possible on monsters and other non-weapon actors? Perhaps "overlay" is a misnomer... actually I'm interested in the ability to make multiple states execute simultaneously, as with weapon actor overlays.

The secondary state(s) executing in the "background" could make something happen over time, for example.
D2JK
 
Joined: 30 Aug 2014

Re: ZScript Discussion

Postby Major Cooke » Sat May 27, 2017 12:34 pm

'simultaneously' is never really simultaneous. It's actually just one piece of code right after the other.

If you want to make something else happen at the same time, you can create a thinker subclass that does things. They're very light in comparison to actors and they cannot be 'spawned' per se. They have no presence in the world itself at all.

But yes, I would actually like overlays on non-players as well for the ability to use psprites upon.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript Discussion

Postby Illasera » Mon Jun 05, 2017 11:13 am

Quick question, Is there a way to debug zscript?

without debugging gzdoom project as a whole?
and without attempting to print out every variable i want to test?

What practices you guys use when it comes to writing zscript code and testing it?
Illasera
Software Engineer
 
Joined: 11 May 2017

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests