[Scripting] Saving references in variables

Post » Mon Feb 01, 2016 4:44 am

Hi, I'm starting in scripting and modding in general (aside from minimods or edit already done mods to my tastes). I have only followed the Scripting for Beginners tutorial from the official GECK site, but I have some questions. I'm working in my first mod, and by the moment I'm doing a script that detect a power armor in the player's inventory and spawn a NPC in front of him with that armor (transfer the armor to the new NPC).

I wanted to create the script when the helmet and the armor are in the inventory (no matter if is the same set or not, the condition is that both need to be a power armor). Searching functions in vanilla geck, FOSE and NVSE and I didnt find any function to search in the player inventory items by the biped model parts. So I used this:

set rHelmet to Player.GetEquippedObject 0 ; 'Head'
set rTorso to Player.GetEquippedObject 2 ; 'Upper Body'

Well is not what I wanted, but at least if I equip the armor the script will search the helmet and the torso. But... how can I extract the reference of this variables and save them to reuse them later?. That would be useful not only for copy the power armor, but for do a copy of the last armor/clothing used prior to the power armor to reequip it when I transfer the power armor to the new NPC.

Also if I could save the reference of the armor, can I save it's current health too?

Can I make the script with a function that search the armor by the biped object part without equipping it?

I think I dont need this for this mods, but can I make a script that depend in another? How can I associate the 2 scripts?

What is the difference of using the operator '==' and using GetIsReference? GetiksReference is to compare 2 references? to replace the ==?

Here is what I have by the moment, not too much...

ScriptName 0xPowerArmorSearch
ref rHelmet
ref rTorso
ref rContainer
ref rActor
Begin GameMode
set rContainer to GetContainer
set rHelmet to Player.GetEquippedObject 0 ; 'Head'
set rTorso to Player.GetEquippedObject 2 ; 'Upper Body'
set rActor to 0xArmorActor ; Actor that will wear the armor.
if eval(rHelmet && rTorso IsPA)
; Here I would transfer the 2 pieces to the actor (maybe using RemoveItemTarget)
; Here I would equip the armor
Player.PlaceAtMe rActor 0

PD: I'm using notepad++ so I can save my work without having errors in geck when saving.

Can anybody help me with this?, any tips?

I would like to do it by myself, so if possible I want answers for my questions (and tips) not to solve my script. :P


User avatar
Isaiah Burdeau
Posts: 3431
Joined: Mon Nov 26, 2007 9:58 am

Post » Sun Jan 31, 2016 6:48 pm

NVSE Functions:

rHelmet.GetHealth gives the health of the reference.

rHelmet.GetEquipType should give you the slots used.

To access the inventory without equipping item, the easiest way is using a ForEach loop on a reference to the Container. Each iteration will return a temporary reference to one stack of inventory item. Warning the temporary reference will only be valid during the loop.

Check the OBSE documentation for those for more information.

User avatar
Jani Eayon
Posts: 3435
Joined: Sun Mar 25, 2007 12:19 pm

Return to Fallout: New Vegas