[Solved] ZScript global variables

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.

Re: ZScript global variables

Postby Graf Zahl » Fri Feb 24, 2017 6:25 pm

This will need a small change to the thinker system to declare a statnum whose contents do not get deleted between maps.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript global variables

Postby Major Cooke » Fri Feb 24, 2017 6:31 pm

That would be HIGHLY appreciated.

By the way, what are all the statnums? What do they do?
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript global variables

Postby Major Cooke » Sat Feb 25, 2017 8:55 am

Is STAT_TRAVELLING strictly for hubs?
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript global variables

Postby Graf Zahl » Sat Feb 25, 2017 10:14 am

The statnums are for sorting, ordering and categorizing thinkers.
For example, the player must tick before its inventory, and a few other things also need to have guaranteed order, e.g. light thinkers must tick before light transfer thinkers and earthquakes before normal actors, and normal actors before anything that can alter other actors' positions, e.g. actor movers and scripts.
There's also a few special statnums for things that need to be looked for frequently.
STAT_TRAVELLING shoud be off limits to mapping. This gets used to temporarily store a player and its inventory when a map gets changed, and once the transition is complete, everything that remains in there will be cleaned out - under normal circumstances the list will be empty, and if you put in your own stuff it won't survive long.

This is also the biggest reason why there's no chance ever to make ZDoom demo compatible, because Doom never had statnums, everything got into the same list and causing all sorts of small problems with subtle effects on the gameplay and often getting into the way of frame interpolation.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: [Solved] ZScript global variables

Postby Nash » Sat Feb 25, 2017 10:31 am

Thank you Graf !!!!! I will shut up about global variables from now on. :mrgreen: :mrgreen: :mrgreen:

To others: working example in first post viewtopic.php?f=3&t=55338#p979528
User avatar
Nash
Twitter/Facebook/Youtube: nashmuhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Twitch ID: nashmuhandes
Github ID: nashmuhandes

Re: [Solved] ZScript global variables

Postby Major Cooke » Sat Feb 25, 2017 12:09 pm

Graf: Should we combine STAT_STATIC with STAT_INFO or is that unnecessary?
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: [Solved] ZScript global variables

Postby Graf Zahl » Sat Feb 25, 2017 1:47 pm

These aren't flags, these are indices which are mutually exclusive. If you combine them you get undefined behavior because the resulting statnum is not what you'd expect.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: [Solved] ZScript global variables

Postby Matt » Tue Feb 28, 2017 9:01 pm

I think this should be added to HOERS.
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: [Solved] ZScript global variables

Postby Xaser » Wed Mar 01, 2017 9:00 am

Indeed -- here's a first pass at a library version, though it's still untested (my hands are tied with other things).
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: [Solved] ZScript global variables

Postby Blue Shadow » Fri May 05, 2017 11:21 am

Sorry for the bump, but the demo file in the opening post produces errors on launch (using GZDoom 3.0):

Code: Select allExpand view
zscript global variables.pk3:zscript.txt, line 32: Parent class EventHandler of WorldHandler not accessible to ZScript version 2.3.0
zscript global variables.pk3:zscript.txt, line 34: Type WorldEvent not accessible to ZScript version 2.3.0
zscript global variables.pk3:zscript.txt, line 34: Invalid type Type for function parameter
zscript global variables.pk3:zscript.txt, line 34: Attempt to override non-existent virtual function WorldTick

Here is a fixed version:

zscript global variables.pk3
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: [Solved] ZScript global variables

Postby Nash » Fri May 05, 2017 12:13 pm

Ah, yeah sorry, forgot about this thread... thanks, I'll add the fixed file to the OP.
User avatar
Nash
Twitter/Facebook/Youtube: nashmuhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Twitch ID: nashmuhandes
Github ID: nashmuhandes

Re: [Solved] ZScript global variables

Postby Blue Shadow » Sat Aug 05, 2017 12:21 am

I've encountered a rather serious bug with this, one that could destroy all the work that I have been doing on my mod for the past half a month or so.

With the attached file, start a new game. Fire your pistol a few times. Each time you do that, you get a message logged saying "Weapon: x", where x is the number of times you shot (this is a global variable). Now save the game and kill yourself. Load the save and check the console. You'll see two messages. The bottom one says "Weapon: 0", hinting at the fact that somehow the global variable's value got reset (or rather more accurately, the old global variable thinker is gone, so the engine is creating a new one). If you load the save a second time, the global variable thinker seems to be restored.

What's going on here?

gvar_test.pk3
You do not have the required permissions to view the files attached to this post.
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: [Solved] ZScript global variables

Postby Nash » Sat Aug 05, 2017 7:39 am

Blue Shadow wrote:I've encountered a rather serious bug with this, one that could destroy all the work that I have been doing on my mod for the past half a month or so.

With the attached file, start a new game. Fire your pistol a few times. Each time you do that, you get a message logged saying "Weapon: x", where x is the number of times you shot (this is a global variable). Now save the game and kill yourself. Load the save and check the console. You'll see two messages. The bottom one says "Weapon: 0", hinting at the fact that somehow the global variable's value got reset (or rather more accurately, the old global variable thinker is gone, so the engine is creating a new one). If you load the save a second time, the global variable thinker seems to be restored.

What's going on here?

gvar_test.pk3


Please make a bug report. This is serious stuff.
User avatar
Nash
Twitter/Facebook/Youtube: nashmuhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Twitch ID: nashmuhandes
Github ID: nashmuhandes

Previous

Return to Editing (Archive)

Who is online

Users browsing this forum: Caleb377 and 4 guests