Author |
Message |
Zaggy1024
Joined: Sun Jan 22, 2012 6:39 am Posts: 12
|
Changing self.Frame for an HDfirearm
I'm trying to make my gun change its sprite when it's reloading, but either the Lua can't change the self.Frame value for HDFirearms, or I'm missing something. Here's the code I've got so far: Code: function Create(self) end
function Update(self) if self:IsReloading() then self.Frame = 2 else self.Frame = 2 end end
|
Sun Jan 22, 2012 7:14 am |
|
|
Abdul Alhazred
DRL Developer
Joined: Tue Aug 11, 2009 5:09 am Posts: 395
|
Re: Changing self.Frame for an HDfirearm
I'm pretty sure you are correct. I do not think it is possible to override what frame to use for firearms with Lua.
|
Mon Jan 23, 2012 3:01 pm |
|
|
Azukki
Joined: Sat Nov 03, 2007 9:44 pm Posts: 1916 Location: Flint Hills
|
Re: Changing self.Frame for an HDfirearm
Can an attachable on a HDFirearm have its sprite changed either? Even a script for the attachable itself doesn't recognize "self" as valid, unless I'm doing it wrong. You can change the magazine's frame, but on any weapon that reloads, the mag's naturally absent during that time. So there's not even a decent work around for tweaking a gun's appearance, it seems. It would be great if SpriteAnimMode = 0 [don't animate] worked for HDFirearms, and would allow Lua to control the frames. It'd be helpful for developing future official content too, maybe one of the content devs would be so gracious as to put in a word about it to Data?
Last edited by Azukki on Tue Jan 24, 2012 12:52 am, edited 1 time in total.
|
Mon Jan 23, 2012 3:31 pm |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Changing self.Frame for an HDfirearm
You can change the frame of an attachable if the script is on the gun. I didn't know of 'self' not working with attachables, I'll talk to Data about that.
Edit: I just did some testing, 'self' works perfectly fine with scripts on attachables.
|
Mon Jan 23, 2012 4:43 pm |
|
|
blargiefarg
Joined: Mon Apr 05, 2010 8:04 am Posts: 149 Location: Under your bed
|
Re: Changing self.Frame for an HDfirearm
I can confirm what CC48 says. I'm working on a script attached to an HDFirearm, and so far everything works fine, can't say I've attempted to change the frame via Lua though.
|
Mon Jan 23, 2012 7:14 pm |
|
|
Zaggy1024
Joined: Sun Jan 22, 2012 6:39 am Posts: 12
|
Re: Changing self.Frame for an HDfirearm
Okay, I'm trying to make an attachable (assuming I know even an inkling of how to do it), and it's saying that it "could not match property" on the line which I put "FrameCount = 2". Code: AddEffect = Attachable InstanceName = M249 Top Mass = 0 HitsMOs = 0 GetsHitByMOs = 0 SpriteFile = ContentFile FilePath = M249.rte/M249Top.bmp FrameCount = 2 SpriteOffset = Vector X = 0 Y = 0 EntryWound = AEmitter CopyOf = Dent Metal Light ExitWound = AEmitter CopyOf = Dent Metal Light AtomGroup = AtomGroup AutoGenerate = 1 Material = Material CopyOf = Military Stuff Resolution = 4 Depth = 0 DeepCheck = 0 JointStrength = 50 JointStiffness = 0.6 JointOffset = Vector X = 0 Y = 0 DrawAfterParent = 1
Last edited by Zaggy1024 on Mon Jan 23, 2012 9:11 pm, edited 1 time in total.
|
Mon Jan 23, 2012 9:04 pm |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Changing self.Frame for an HDfirearm
Are you using tabs or spaces for your spacing?
|
Mon Jan 23, 2012 9:10 pm |
|
|
Zaggy1024
Joined: Sun Jan 22, 2012 6:39 am Posts: 12
|
Re: Changing self.Frame for an HDfirearm
Tabs. I got the attachable bit of the INI from the wiki which used spaces, though. So that can actually cause an error?
Edit: Okay, it's working (it was because of the spaces, INIs are weird =P)... Now I need to know how to find the attachable from the script in the HDFirearm...
|
Mon Jan 23, 2012 9:11 pm |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Changing self.Frame for an HDfirearm
Loop through all MOs, find one that has the PresetName of the attachable and has the same RootID as the HDFirearm.
|
Mon Jan 23, 2012 9:25 pm |
|
|
Zaggy1024
Joined: Sun Jan 22, 2012 6:39 am Posts: 12
|
Re: Changing self.Frame for an HDfirearm
Something like this? Code: function Create(self) self.TopMO = nil
for i = 1, MovableMan:GetMOIDCount() - 1 do object = MovableMan:GetMOFromID(i);
if object.InstanceName == "M249 Top" and self.TopMO.RootID == self.ID then print('found!') self.TopMO = object end end end Currently this doesn't find anything (even with the RootID check not in there).
|
Mon Jan 23, 2012 9:55 pm |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Changing self.Frame for an HDfirearm
print should be It's probably what's stopping your code from working.
|
Mon Jan 23, 2012 10:42 pm |
|
|
Zaggy1024
Joined: Sun Jan 22, 2012 6:39 am Posts: 12
|
Re: Changing self.Frame for an HDfirearm
No, both ways work fine for printing in the console and in the code...
I tried making it print all the InstanceNames it found, and all of them were nil, so I assume that means there is no property called InstanceName that the Lua can access. Am I right?
|
Mon Jan 23, 2012 10:58 pm |
|
|
Asklar
Data Realms Elite
Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
|
Re: Changing self.Frame for an HDfirearm
Wasn't InstanceName a temporal property that can't be read for future references? You should pick PresetName.
|
Mon Jan 23, 2012 11:32 pm |
|
|
Zaggy1024
Joined: Sun Jan 22, 2012 6:39 am Posts: 12
|
Re: Changing self.Frame for an HDfirearm
Changed it to PresetName (yes, in both the INI and the script), and it's still saying it's nil. Code: function Create(self) self.TopMO = nil
for i = 1, MovableMan:GetMOIDCount() - 1 do object = MovableMan:GetMOFromID(i);
if object.PresetName == "M249 Top" then-- and self.TopMO.RootID == self.ID print("found!"); self.TopMO = object; end end end Are you guys sure you can actually access an MO's name from Lua?
|
Tue Jan 24, 2012 12:24 am |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Changing self.Frame for an HDfirearm
Yes. I'm actually working on a mod that stores data in a magazine's PresetName, and it works fine.
|
Tue Jan 24, 2012 12:33 am |
|
|
|