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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Numnzel
Posts: 161
Joined: Wed Jul 18, 2012 6:17 pm
Location: Empty space

Custom properties resetting bug? (Zscript) [Resolved]

Post by Numnzel »

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.
_mental_
 
 
Posts: 3820
Joined: Sun Aug 07, 2011 4:32 am

Re: Custom properties resetting bug? (Zscript)

Post by _mental_ »

It's impossible to debug a screenshot. Post actual code please.
User avatar
Numnzel
Posts: 161
Joined: Wed Jul 18, 2012 6:17 pm
Location: Empty space

Re: Custom properties resetting bug? (Zscript)

Post by Numnzel »

Here goes the code as short as possible:

Abstract class:
Spoiler:
Actual weapon:
Spoiler:
User avatar
Player701
 
 
Posts: 1710
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Custom properties resetting bug? (Zscript)

Post by Player701 »

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 all

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
Numnzel
Posts: 161
Joined: Wed Jul 18, 2012 6:17 pm
Location: Empty space

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

Post by Numnzel »

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 all

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 all

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.
Post Reply

Return to “Scripting”