Data Realms Fan Forums
http://forums.datarealms.com/

Changing a gun's frame with lua
http://forums.datarealms.com/viewtopic.php?f=73&t=46063
Page 2 of 2

Author:  4zK [ Sun Jun 19, 2016 11:33 am ]
Post subject:  Re: Changing a gun's frame with lua

Did you try dropping the gun and picking it up again? If that works, it'd help explain what's wrong.

EDIT: If the latest change to the code doesn't do the trick, I'm close to being stumped.

Author:  Hoovytaurus [ Sun Jun 19, 2016 1:04 pm ]
Post subject:  Re: Changing a gun's frame with lua

4zK wrote:
Did you try dropping the gun and picking it up again? If that works, it'd help explain what's wrong.

EDIT: If the latest change to the code doesn't do the trick, I'm close to being stumped.


Good news! It works!

The frames go on and when they're at the right stage, the gun fires.

Bad news is, it stays at the same frame. Dropping and picking the gun back up won't do anything and charging up multiple times won't change it. It remains at the last frame, where the gun fired.

EDIT: While we're on the subject of animations...


Author:  Bad Boy [ Sun Jun 19, 2016 1:49 pm ]
Post subject:  Re: Changing a gun's frame with lua

Could be that "if self.Frame > self.FrameCount then" should be "if self.Frame >= self.FrameCount then", depends on whether FrameCount is the highest Frame or the total number of Frames (including Frame 0).
Either way, for some reason the code inside that if isn't being reached, you should drop in a couple prints and seeing what's going wrong.

Author:  Hoovytaurus [ Sun Jun 19, 2016 2:11 pm ]
Post subject:  Re: Changing a gun's frame with lua

Hm. It seems to never stop trying to advance the frames. I added a print under if self.animTimer:IsPastSimMS(delay) then and it won't ever stop. Once you start it, it just keeps printing. I think that basically traps the code.

I have some vague ideas of how to go around this but they're way too vague to actually talk about.

Author:  4zK [ Sun Jun 19, 2016 3:27 pm ]
Post subject:  Re: Changing a gun's frame with lua

Setting the number value to 0 should be the same as removing the number value, but it might not be the case. Checking whether the number value of the weapon is 0 rather than whether it exists might be the case if the former statement is true.

Also, I was hoping that the script would still recognize when the frames go beyond the FrameCount, even though frames beyond the count don't really exist. What BB said might fix it, but you'll have to add one extra frame at the end, which won't be seen.

Author:  Hoovytaurus [ Sun Jun 19, 2016 3:48 pm ]
Post subject:  Re: Changing a gun's frame with lua

4zK wrote:
Setting the number value to 0 should be the same as removing the number value, but it might not be the case. Checking whether the number value of the weapon is 0 rather than whether it exists might be the case if the former statement is true.

Also, I was hoping that the script would still recognize when the frames go beyond the FrameCount, even though frames beyond the count don't really exist. What BB said might fix it, but you'll have to add one extra frame at the end, which won't be seen.


I'll try to make it check if the number's 0 and add that extra frame, see what happens.

Also: my next reply MAY be late, as I am about to drive off for a road trip.

EDIT: Yeah, uh, the extra frame was simple enough.

Everything else is a bit too tough. How do you delete a number value, or how do I make it fetch the number and only act if it's above 0?

Page 2 of 2 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/