Data Realms Fan Forums http://45.55.195.193/ |
|
Changing An HDFirearm Sprite Using Lua http://45.55.195.193/viewtopic.php?f=73&t=31281 |
Page 1 of 1 |
Author: | kungfuchan13 [ Wed Jun 20, 2012 7:27 am ] |
Post subject: | Changing An HDFirearm Sprite Using Lua |
Old: New: I can't change the gun's sprite using Lua... Help please. |
Author: | kungfuchan13 [ Wed Jun 20, 2012 8:52 pm ] |
Post subject: | Re: Changing An HDFirearm Sprite Using Lua |
For some reason putting FCCALOG = 0 into the create function made it work. Anyways, does anyone know how to change the sprite of an HDFirearm using lua? |
Author: | Bad Boy [ Wed Jun 20, 2012 10:08 pm ] |
Post subject: | Re: Changing An HDFirearm Sprite Using Lua |
Your problem was that you referenced a (global) variable that had never been defined. By defining FCCALOG in the create function you allowed it to be referenced. To change the sprite just make multiple frames and set it to the frame you want. I can't say with 100% surety that this'll fix it but it'll definitely be neater, get rid of the line self.Frame = 0 in the update and add self.Frame = FCCA instead since frame and FCCA seem to always be the same. Also, I may be mistaken here since I'm not exactly sure what you're trying to achieve but you could probably simplify all the timer stuff to the following, though it may mess up the stuff at the end. Code: if self.timer:IsPastSimMS(250) then self.FCCA = self.FCCA + 1; self.Timer:Reset(); end Similarly, it probably makes more sense to check if the gun is firing before doing the timer stuff in the first place instead of resetting the timer whenever it's not but that's not a big deal I think. In general, when looking for errors I'd suggest throwing in prints to find the problem, printing for each timer change would probably help you out. Finally, note that since you're using global variables the script will affect every gun that uses it so when one fires they all change frames and the minimum distance of all of them will be affected. To get around that either use things like the gun's sharpness to determine stuff for the bullet or make a global table containing all the guns, sort through everything in that table for the closest gun and use its FCCALOG[i] value. Or maybe I'm looking at this in the wrong way and there's an easier solution, hard to say since I don't really know what the gun does. Long winded post aside, good luck, keep at it, I'm sure you'll figure it out. |
Author: | kungfuchan13 [ Fri Jun 22, 2012 4:47 am ] |
Post subject: | Re: Changing An HDFirearm Sprite Using Lua |
Thanks for the help. The thing is... HDFirearms don't take kindly to having their frames being changed through Lua. They only change frames when they're shot... (Which is probably through Lua... Or whatever, but that doesn't really matter.) Having something that says self.Frame = x on an HDFirearm doesn't change the frame... So... Kinda at a loss for this... Maybe... Create an MOSRotating right on top of the gun and have that MOSRotating have the same velocity as the gun? Meh. |
Author: | Arcalane [ Fri Jun 22, 2012 4:50 am ] |
Post subject: | Re: Changing An HDFirearm Sprite Using Lua |
Attachables. Unfortunately they're a pain to do, but it should be possible. Just tricky. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |