View unanswered posts | View active topics It is currently Wed Dec 25, 2024 5:33 pm



Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
 Changing a gun's frame with lua 
Author Message
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post 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.


Sun Jun 19, 2016 11:33 am
Profile

Joined: Mon Dec 21, 2015 9:30 am
Posts: 89
Reply with quote
Post 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...



Last edited by Hoovytaurus on Sun Jun 19, 2016 1:57 pm, edited 1 time in total.



Sun Jun 19, 2016 1:04 pm
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post 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.


Sun Jun 19, 2016 1:49 pm
Profile

Joined: Mon Dec 21, 2015 9:30 am
Posts: 89
Reply with quote
Post 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.


Sun Jun 19, 2016 2:11 pm
Profile
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post 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.


Sun Jun 19, 2016 3:27 pm
Profile

Joined: Mon Dec 21, 2015 9:30 am
Posts: 89
Reply with quote
Post 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?


Sun Jun 19, 2016 3:48 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 21 posts ]  Go to page Previous  1, 2

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.101s | 13 Queries | GZIP : Off ]