Data Realms Fan Forums http://45.55.195.193/ |
|
EquippedItem Property Troubles [Solved] http://45.55.195.193/viewtopic.php?f=73&t=25528 |
Page 1 of 1 |
Author: | Azukki [ Thu Sep 15, 2011 10:52 am ] |
Post subject: | 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 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 |
Author: | CaveCricket48 [ Thu Sep 15, 2011 11:30 am ] |
Post subject: | Re: EquippedItem Property Troubles |
Instead of Code: self.operator = ToActor(self.rootofdevice) Try Code: self.operator = ToAHuman(self.rootofdevice) |
Author: | Azukki [ Thu Sep 15, 2011 11:40 am ] |
Post subject: | 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 |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |