View unanswered posts | View active topics It is currently Mon Oct 21, 2019 11:15 am



Reply to topic  [ 3 posts ] 
 EquippedItem Property Troubles [Solved] 
Author Message
User avatar

Joined: Sat Nov 03, 2007 9:44 pm
Posts: 1916
Location: Flint Hills
Reply with quote
Post EquippedItem Property Troubles [Solved]
So I'm trying to improve the scripts for visible inventory. These scripts are applied to attachables, the root object of which are AHumans. But if I try to access the EquippedItem property on a pointer to the root MO, it comes up as nil even when the actor is holding something.

An example of one of my attempts to access it:
Code:
function Update(self)
   self.rootofdevice = MovableMan:GetMOFromID(self.RootID)
   if self.rootofdevice then
      if self.rootofdevice:IsActor() then
         self.operator = ToActor(self.rootofdevice)
         print(ToHDFirearm(self.operator.EquippedItem).PresetName)
      end
   end
end
ERROR: call of overloaded function '(nil)' is ambiguous
none of the overloads have a best conversion:(Entity*)
(const Entity*)

A functional example from the vanilla human AI:
Code:
AimPos = ToHDFirearm(self.EquippedItem).MuzzlePos


Last edited by Azukki on Thu Sep 15, 2011 11:40 am, edited 1 time in total.



Thu Sep 15, 2011 10:52 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 11845
Location: Here
Reply with quote
Post Re: EquippedItem Property Troubles
Instead of
Code:
self.operator = ToActor(self.rootofdevice)

Try
Code:
self.operator = ToAHuman(self.rootofdevice)


Thu Sep 15, 2011 11:30 am
Profile
User avatar

Joined: Sat Nov 03, 2007 9:44 pm
Posts: 1916
Location: Flint Hills
Reply with quote
Post Re: EquippedItem Property Troubles
Thanks a million, that did the trick.

Functional example for anyone who comes across this thread with the same issue:
Code:
function Update(self)
   self.rootofdevice = MovableMan:GetMOFromID(self.RootID)
   if self.rootofdevice then
      if self.rootofdevice:IsActor() then
         self.operator = ToAHuman(self.rootofdevice)
         self.holding = self.operator.EquippedItem
         if self.holding then
            print(self.holding.PresetName)
         end
      end
   end
end


Thu Sep 15, 2011 11:40 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

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