Custom properties resetting bug? (Zscript) [Resolved]

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.

Custom properties resetting bug? (Zscript) [Resolved]

Postby Numnzel » Sat Feb 20, 2021 4:40 am

Hello everyone.

I'm having a really strange bug right now.

I'm creating a new weapon that inherits from an abstract weapon class I did.
The abstract class has a custom property, let's call it X, and a Log function in it's Tick() function for debugging.

The bug is, that if I change the X value by using <self.X> in the new weapon, the Log function shows me the var value changes and resets to the default value in a loop, here's a self-explanatory image:
Spoiler:


So, IF I move the Log function into the Tick() of the new weapon class instead of the abstract, the reading is cohesive, shows that same variable has changed and does not reset / keeps the new value correctly.

And no, I'm not touching this variable from another place, I already checked that.

What is happening here?

I'm using gzdoom 4.5.0.
Last edited by Numnzel on Sat Feb 20, 2021 10:22 am, edited 1 time in total.
User avatar
Numnzel
 
Joined: 18 Jul 2012
Location: Empty space

Re: Custom properties resetting bug? (Zscript)

Postby _mental_ » Sat Feb 20, 2021 4:51 am

It's impossible to debug a screenshot. Post actual code please.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: Custom properties resetting bug? (Zscript)

Postby Numnzel » Sat Feb 20, 2021 6:47 am

Here goes the code as short as possible:

Abstract class:
Spoiler:


Actual weapon:
Spoiler:
User avatar
Numnzel
 
Joined: 18 Jul 2012
Location: Empty space

Re: Custom properties resetting bug? (Zscript)

Postby Player701 » Sat Feb 20, 2021 8:46 am

I'm unable to reproduce this with your code. The diagnostic messages are probably coming from different instances of the weapon. To be sure, print the value of Level.maptime in addition to the value of mirrorxx, like this:

Code: Select allExpand view
Console.Printf("%d, time = %d", mirrorxx, Level.maptime);

If you get more than one message with the same maptime value, it means they are not coming from the same instance. But if that's not the case, it's probably something else in your mod causing the issue.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Custom properties resetting bug? (Zscript) [Resolved]

Postby Numnzel » Sat Feb 20, 2021 10:22 am

Player701 wrote:I'm unable to reproduce this with your code. The diagnostic messages are probably coming from different instances of the weapon. To be sure, print the value of Level.maptime in addition to the value of mirrorxx, like this:

Code: Select allExpand view
Console.Printf("%d, time = %d", mirrorxx, Level.maptime);

If you get more than one message with the same maptime value, it means they are not coming from the same instance. But if that's not the case, it's probably something else in your mod causing the issue.


That function helped me vastly, didn't know it. I traced the actors doing this:
Code: Select allExpand view
Console.Printf("%d, time = %d, actor = %s", mirrorxx, Level.maptime, self.getClassName());

And saw that, of course, the placed weapons in the map were also generating their values.

As always, nothing new below the sky.

I marked the post as resolved. Thank you.
User avatar
Numnzel
 
Joined: 18 Jul 2012
Location: Empty space


Return to Scripting

Who is online

Users browsing this forum: Mikk- and 2 guests