Data Realms Fan Forums http://45.55.195.193/ |
|
Changing rate of fire via lua http://45.55.195.193/viewtopic.php?f=73&t=28151 |
Page 1 of 1 |
Author: | Zagzag [ Fri Dec 23, 2011 6:13 pm ] |
Post subject: | Changing rate of fire via lua |
Although my lua is pretty terrible I thought that this script would be easy to throw together, but am having unexplained problems with it. I am trying to make a gun which steadily fires faster and faster, and resets to the original speed when reloaded. I put together this: However this doesn't seem to be working in any meaningful way. I have changed many, many things about the script, and still can't get it to work in any form. I have put print lines in to check how far it gets, and none of the steps ever seem to trigger under any circumstances. Am I missing something obvious, or am I trying to do something that isn't actually possible? |
Author: | Roast Veg [ Fri Dec 23, 2011 6:27 pm ] |
Post subject: | Re: Changing rate of fire via lua |
I don't think what you're trying to do is possible in the way you're doing it. What you're probably going to have to do is replace the magazine (because I'm pretty sure the rate of fire is denoted by the magazine) at those values, instead of trying to alter a variable that doesn't exist to Lua. |
Author: | Zagzag [ Fri Dec 23, 2011 6:56 pm ] |
Post subject: | Re: Changing rate of fire via lua |
RateOfFire is a property of the weapon, and no similar property exists for the magazine. I had begun to suspect that you can't simply overwrite it with a new value, but I was hoping you could. Does that mean that there is no way of dynamically altering the rate of fire via lua? I suppose that if this is the case you could swap the gun for an identical one with a higher rate of fire, and the appropriate number of bullets in the magazine every time it needs to speed up, then revert to the original when it is reloaded, but this is sadly beyod my lua skills at the moment, without some serious messing around anyway! |
Author: | Roast Veg [ Fri Dec 23, 2011 8:16 pm ] |
Post subject: | Re: Changing rate of fire via lua |
Code: function update(self) self.RateOfFire = (100-self.RoundInMagCount)*5+200; print(self.RateOfFire); end Tell me what that does for you. |
Author: | Zagzag [ Fri Dec 23, 2011 8:33 pm ] |
Post subject: | Re: Changing rate of fire via lua |
I've just seen your post about 10 second before I have to go. I'll try it as soon as I get back and then I'll let you know. Thanks EDIT: It doesn't change the rate of fire, nor does it actually print anything. There are no lua console errors either. Removing the "end" does produce a lua console error, so that confirms that it is actually loading the right script and atempting to do something with it. This would seem to suggest that RateOfFire can't actually be rewritten by lua, which is rather disappointing. I'm sure there is a good reason why (if?) this is the case, but I for one can't see it... |
Author: | Kettenkrad [ Sat Dec 24, 2011 11:34 pm ] |
Post subject: | Re: Changing rate of fire via lua |
Shook had a lovely Dakka script that I'm sure he'd let you use. Run it by him first. Code: function Create(self) self.baseROF = 250 self.modROF = 0 end function Update(self) if self:IsActivated() then if self.modROF < 550 then self.modROF = self.modROF + 3; end else self.modROF = 0; end self.RateOfFire = (self.baseROF + self.modROF); end |
Author: | Zagzag [ Mon Dec 26, 2011 1:39 pm ] |
Post subject: | Re: Changing rate of fire via lua |
Thanks a lot for the help. Although that script wasn't exactly what I was trying to achieve, I have been able to use it for reference to create my own sctipt to do exactly what I originally wanted. It actually works better than my original script would have done! I still have absolutely no idea why my new sctipt works and my old one doesn't, but in situations like this it isn't usually best to complain when things work... |
Author: | Azukki [ Mon Dec 26, 2011 10:11 pm ] |
Post subject: | Re: Changing rate of fire via lua |
It looks like tossing in a self-existence-check made veg's script work. I dunno why. Code: function Update(self) if self.RootID ~= 255 then self.RateOfFire = (100-self.RoundInMagCount)*5+200 print(self.RateOfFire) end end |
Author: | Roast Veg [ Thu Dec 29, 2011 4:21 am ] |
Post subject: | Re: Changing rate of fire via lua |
That never even crossed my mind, nice catch azukki. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |