View unanswered posts | View active topics It is currently Tue Apr 16, 2024 11:49 am



Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
 Changing self.Frame for an HDfirearm 
Author Message

Joined: Sun Jan 22, 2012 6:39 am
Posts: 12
Reply with quote
Post 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
Profile
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post 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
Profile
User avatar

Joined: Sat Nov 03, 2007 9:44 pm
Posts: 1916
Location: Flint Hills
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post 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
Profile
User avatar

Joined: Mon Apr 05, 2010 8:04 am
Posts: 149
Location: Under your bed
Reply with quote
Post 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
Profile YIM

Joined: Sun Jan 22, 2012 6:39 am
Posts: 12
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Changing self.Frame for an HDfirearm
Are you using tabs or spaces for your spacing?


Mon Jan 23, 2012 9:10 pm
Profile

Joined: Sun Jan 22, 2012 6:39 am
Posts: 12
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post 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
Profile

Joined: Sun Jan 22, 2012 6:39 am
Posts: 12
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Changing self.Frame for an HDfirearm
print should be
Code:
print("found!");

It's probably what's stopping your code from working.


Mon Jan 23, 2012 10:42 pm
Profile

Joined: Sun Jan 22, 2012 6:39 am
Posts: 12
Reply with quote
Post 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
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post 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
Profile

Joined: Sun Jan 22, 2012 6:39 am
Posts: 12
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 22 posts ]  Go to page 1, 2  Next

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.103s | 15 Queries | GZIP : Off ]