View unanswered posts | View active topics It is currently Thu Dec 26, 2024 4:36 am



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

Joined: Sun Jan 22, 2012 6:39 am
Posts: 12
Reply with quote
Post Re: Changing self.Frame for an HDfirearm
You don't have to change it to another type other than MovableObject, do you? Or do you have any idea of any other problems with my script?


Tue Jan 24, 2012 3:26 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Changing self.Frame for an HDfirearm
Do
Code:
print(object.ID);

right after
Code:
object = MovableMan:GetMOFromID(i);

and tell me what you get.


Tue Jan 24, 2012 3:50 am
Profile

Joined: Sun Jan 22, 2012 6:39 am
Posts: 12
Reply with quote
Post Re: Changing self.Frame for an HDfirearm
Code:
PRINT: 1
PRINT: 2
PRINT: 3
PRINT: 4
PRINT: 5
PRINT: 6
PRINT: 7
PRINT: 8
PRINT: 9
PRINT: 10
PRINT: 11


I also tried telling it to print all the PresetNames and it did print names, it just didn't include "M249 Top".

Edit: It turns out for some reason if the attachable doesn't hit MOs or get hit by MOs (not sure which), it doesn't find it.


Tue Jan 24, 2012 3:59 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Changing self.Frame for an HDfirearm
Oh, MOs that are GetsHitByMOs = 0 don't get MOIDs.


Tue Jan 24, 2012 4:30 am
Profile

Joined: Sun Jan 22, 2012 6:39 am
Posts: 12
Reply with quote
Post Re: Changing self.Frame for an HDfirearm
Okay, now it's finding the attachable (had to move the searching code to Update(self) because it ran too soon to find the attachable in Create(self)), but when I try to make it change the frame, it doesn't do it (at least visually).

Edit: I made it print the frame that it was set to, and it is changing the value.

Could the problem be that there is no "Frame" property on MovableObjects, so I need to change the object to an MOSprite (and if so, how do you?)?

Edit again: I tried "ToMOSprite", and it didn't give an error, but it made no difference but to make the frame property's value never change at all. >.>

Edit again 2.0: It just magically started working! =D Now to make the script even fancier! =P

Editing the third time: I realized I forgot to try the RootID check (again), so I uncommented it, and it's not finding the attachable anymore.

Code:
      for i = 1, MovableMan:GetMOIDCount() - 1 do
         object = MovableMan:GetMOFromID(i);

         if object ~= nil and object.PresetName == "M249 Top" and object.RootID == self.ID then
            self.TopMO = ToMOSprite(object);
            print("M249 Top found!");
         end
      end


The problem *seems* to be that the soldier carrying the gun is the "root" of the attachable on the gun, and not the gun itself (only when a soldier is carrying the gun).

Edit AGAIN: I got it working perfectly now (here's hoping I don't find another problem =P)! I even managed to make the code work for more than 3 frames, with ping-pong motion. It's made so that it'll play it at a certain speed and then stop it at the "end" of the animation, and then play it backwards before the reload finishes (the only problem is that I had to make the script have a pre-defined ReloadTime value, since the one from the INI is inaccessible).



Tue Jan 24, 2012 4:42 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Changing self.Frame for an HDfirearm
That would be self.RootID, not self.ID


Tue Jan 24, 2012 9:23 pm
Profile

Joined: Sun Jan 22, 2012 6:39 am
Posts: 12
Reply with quote
Post Re: Changing self.Frame for an HDfirearm
Yeah, I noticed that (I did try it before, and for some reason it didn't work, but now it does)... it's working now (see my previous post in the edit above the spoiler).


Wed Jan 25, 2012 12:57 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 22 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.089s | 13 Queries | GZIP : Off ]