Data Realms Fan Forums
http://45.55.195.193/

ACrab Weapon Accessing via Pie menu (SOLVED)
http://45.55.195.193/viewtopic.php?f=73&t=31398
Page 1 of 1

Author:  Coops [ Wed Jul 04, 2012 6:42 pm ]
Post subject:  ACrab Weapon Accessing via Pie menu (SOLVED)

What exactly is the HDFirearm of an ACrab? I know it's part of the turret, but does that mean it's an attachable of an attachable of an actor?

I can't seem to access it through a pie menu action and I can't use aCrab.EquippedItem because it's not an equipped item, it's the turret that has it equipped.

This is what I have for the pie menu action

Code:
function AmmoMissile(actor)
   local MoEnt
   local crab = ToACrab(actor)
   for i = 1, MovableMan:GetMOIDCount()-1 do
      if MovableMan:GetRootMOID(i) == crab.RootID then
         MoEnt = MovableMan:GetMOFromID(i)
         if MoEnt.PresetName == "Crawler Mounted Launcher" then
            print(MoEnt.RootID.PresetName)
            local gun = ToHDFirearm(MoEnt);
            local magSwitchName = "Crawler Missile Launcher Magazine";
            if gun.Magazine == nil or (gun.Magazine ~= nil and gun.Magazine.PresetName ~= magSwitchName) then
               gun:SetNextMagazineName(magSwitchName);
               crab:ReloadFirearm();
            end
         end
      end
   end
end


From what I can tell it not reaching the first print, I've got a hunch it's not getting my ACrab. I don't know how the the actor argument works and what it does to get it or if the ACrab actor has any restrictions towards HDFirearm access.

I can't get the gun to change magazines, I need help :-(

Thanks.

Author:  Roast Veg [ Wed Jul 04, 2012 7:55 pm ]
Post subject:  Re: ACrab Weapon Accessing via Pie menu

Have you tried ToActor instead of ToAcrab?

Author:  Coops [ Wed Jul 04, 2012 8:22 pm ]
Post subject:  Re: ACrab Weapon Accessing via Pie menu

No go.

It does seem to be getting the weapon though, every single weapon though.

Author:  Bad Boy [ Wed Jul 04, 2012 8:42 pm ]
Post subject:  Re: ACrab Weapon Accessing via Pie menu

What is the script attached to and what is the actor in function AmmoMissile(actor) referencing? I may just be being an idiot here but to me you're calling ToACrab(actor) without specifying what actor is, which looks like it wouldn't work. Or am I missing something crucial?

Author:  Coops [ Wed Jul 04, 2012 8:47 pm ]
Post subject:  Re: ACrab Weapon Accessing via Pie menu

actor is the parameter of the function, of which is attached to a pie menu command, which is attached to a HDFirearm, which is attached to an ACrab.

I assume actor of the function is referencing to the actor holding the weapon.

EDIT: Actually, if that's true. Maybe I should check if it's getting the turret and not the ACrab itself. But even then, I'm asking for the RootID of the weapon, not what it's attached to.

Author:  Bad Boy [ Wed Jul 04, 2012 9:01 pm ]
Post subject:  Re: ACrab Weapon Accessing via Pie menu

Oh okay, it's for a pie slice so that makes sense then. Sorry, I should have read your first post more carefully.

Have you tried, as you suggested, print (crab)?
Other than that I'm not sure what's wrong, though it's possible you can just reference the actor in the function without doing ToACrab at all.
i.e.
Code:
for i = 1, MovableMan:GetMOIDCount()-1 do
      if MovableMan:GetRootMOID(i) == actor.RootID then
         MoEnt = MovableMan:GetMOFromID(i)
         etc.

Edit: Though looking at a few other ammo swapping scripts I'm pretty sure this isn't the case.

If you don't mind sharing it (via pm or posting here or whatever) I'd be happy to try to help properly, I find it difficult to properly figure things out without the ability to test ingame so I'm afraid I may not be much help if you don't want to share it. That said, it might not be worth the effort since I don't know what the problem is. Rather I'd just throw in enough prints to find the problem and try to work from there, which is obviously something you can easily do yourself.

Author:  Coops [ Wed Jul 04, 2012 9:28 pm ]
Post subject:  Re: ACrab Weapon Accessing via Pie menu

I got it.

I forgot the number one rule of accessing MOs.

Code:
GetsHitByMOs = 1


Thanks guys.

Author:  Roast Veg [ Wed Jul 04, 2012 9:39 pm ]
Post subject:  Re: ACrab Weapon Accessing via Pie menu (SOLVED)

I'll be interested to see mag swapping on the ACrab when it's done, is it for a new project or an existing one?

Author:  Coops [ Wed Jul 04, 2012 9:51 pm ]
Post subject:  Re: ACrab Weapon Accessing via Pie menu (SOLVED)

New project.

I've been working on it for a while now actually, been getting really anxious to finish this and release it.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/