Riain Posted March 2, 2009 Share Posted March 2, 2009 Hi, I have a script that may different object use. I know how to check if the object is equipped by using Player.GetEquipped [object ID] but that requires me defining the ID myself. I was wondering if you could reference the object running the script instead so that the script is more flexible. Something like ref MyObject set MyObject to ObjectRunningThisScript If Player.GetEquipped MyObject ... I tried using GetSelf but it didn't seem to work. Apparently Oblivion had something like: ref selfref myBaseset self to getSelfset myBase to self.getBaseObject But GetBaseObject is not a FO3 command, and I don't want to use FOSE if I can help it. Link to comment Share on other sites More sharing options...
Cipscis Posted March 2, 2009 Share Posted March 2, 2009 Firstly, inventory items aren't usually assigned RefIDs so GetSelf should never be called on an item while it is in an inventory. Luckily, you don't need to use GetSelf (in fact you really shouldn't be using it here) as you can simply use implied reference syntax:ref rBaseObject set rBaseObject to GetBaseObject if player.GetEquipped rBaseObjectKeep in mind that GetBaseObject is a FOSE function, so you'll need to run the GECK via FOSE in order to compile it correctly, and you'll need to run Fallout 3 via FOSE in order for the script to run. Unless you want to "hard code" the EditorID in the script, you have no choice but to use FOSE. There really isn't any reason to be afraid of it - it's an incredibly useful tool. Cipscis Link to comment Share on other sites More sharing options...
Riain Posted March 2, 2009 Author Share Posted March 2, 2009 Thanks, I will likely use it sometime but I wanted to create a version that does not require FOSE for those who don't want to hassle with. Link to comment Share on other sites More sharing options...
Cipscis Posted March 2, 2009 Share Posted March 2, 2009 If the item that you're checking is an armour, then you'd be better off using an Object Effect, as this can cause code to run only when the item is equipped without worrying about being broken by EquipItem. If it's a weapon, then you'd be better off using code like this:short sIsEquipped Begin OnEquip set sIsEquipped to 1 End Begin GameMode if sIsEquipped ; Do stuff endif End Begin OnUnequip set sIsEquipped to 0 EndIf you use GetEquipped, and there are multiple copies of the inventory item in the player's inventory, then multiple instances of the script will run. If this will never be the case, then you should be able to "hard code" the EditorID of the Base Object instead of having to rely on GetBaseObject. Cipscis Link to comment Share on other sites More sharing options...
Riain Posted March 3, 2009 Author Share Posted March 3, 2009 Wow... That seems so obvious now... It was staring me right in the face. Thanks :D And yes it is armor that I am working with. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.