Jump to content

Auto-Sorting Script Issue


GeneralGred

Recommended Posts

I'm making a large personal home mod and of course this comes complete with auto-sorting containers. I have no issue making the scripts to sort items into their respective containers, but I'm currently having trouble finding a way to leave equipped gear alone. ATM I'm trying to have the script identify the currently equipped items in each slot, remove all the specific items into the container, and then taking the identified gear back out of the container and reequipping them. My main problem with this is I cannot seem to find a proper function to identify and store a equipped item into a variable. If anyone can help me with this or even better know a way to have the auto-sorting script ignore the equipped items entirely I would be very grateful.

 

I am using both NVSE and JIP LN NVSE in the mod and have tried to no avail:

- GetEquippedObject

- GetEquippedItemRef

 

I am currently using these to try and store the gear as reference variables

Link to comment
Share on other sites

  • Replies 47
  • Created
  • Last Reply

Top Posters In This Topic

There are mods that do this already. You should be able to look at them and get a good script that you can change to suit your purpose. My first thought would be to use GetEquippedData on each of the body slots and add each result to the same array, then do any number of things with that information. How have you been approaching it?

Link to comment
Share on other sites

So I've been hard at work all morning using the information you guys gave me and I have made some headway with it. So to clarify my mod has two separate systems of Auto-Sorting items.

 

1) The master system takes all items from the player and sorts them into their respective containers around the house.

2) The specific system only takes items from the player the pertain to that specific container (eg: Pistols, Rifles, Faction Armor, etc.)

 

Now thanks to Mktavish I've made good progress on the master system using GetAllItemRefs to create an array variable of non-equipped gear, however I cannot find a proper function to use the array. RemoveItemTarget cannot use array variables and RemoveAllTypedItems only uses the array as an exemption list. So i need a function that can treat an array like an item to move from one container to another.

 

Unfortunately this doesn't do much for my specific system. Array variables only encompass entire types of items when I need only specific items of that type. So far I have this going and like I said earlier I believe the issue here is the script isn't storing the equipped item into the reference variable.

 

scn GMArmoryArmorContFactionsScript

short EquipDetection
ref ItemBody

Begin onActivate
if (player.IsSneaking == 0)
activate
elseif (player.IsSneaking == 1)
set ItemBody to player. GetEquippedItemRef 2
set EquipDetection to 1
endif
End

Begin Gamemode
if (EquipDetection == 1)
player.removeItemTarget ArmorBoomerWeldingHelmet GMArmoryArmorContFactionsRef
player.removeItemTarget OutfitBoomer1 GMArmoryArmorContFactionsRef
player.removeItemTarget OutfitBoomer2 GMArmoryArmorContFactionsRef

 

.........more specific item removal scripting etc.

set EquipDetection to 2
endif

if (EquipDetection == 2)
if (GetItemCount ItemBody >= 1)
RemoveItemTarget ItemBody player 1
set EquipDetection to 3
elseif (GetItemCount ItemBody == 0)
set EquipDetection to 0
endif
endif

if (EquipDetection == 3)
if (player.GetItemCount ItemBody >= 1)
player.EquipItem ItemBody 0 1
set EquipDetection to 0
endif
endif

if (GMArmoryArmorDisplayFactionRefNCR.GetDisabled == 0)
if (GetItemCount ArmorNVNCRTrooper >= 1)
GMArmoryArmorDisplayRefNCRTrooperArmor.enable 0
elseif (GetItemCount ArmorNVNCRTrooper <= 0)
GMArmoryArmorDisplayRefNCRTrooperArmor.disable
endif

....... more display scripting etc.

End

Link to comment
Share on other sites

What you just need is to store your equipped items in a container before removing all the rest of the inventory.

 

So how about ...

 

~~~~~~~~~~~~

SCN SortScript

 

Ref rArm

Ref rWeap

Int DoOnce

 

Begin OnActivate Player

 

Set rArm to PlayerRef.GetEquippedObject 2

Set rWeap to PlayerRef.GetEquippedobject 5

 

PlayerRef.RemoveItemTarget MyContainer rArm 1 0

Player.Ref.RemoveItemTarget MyContainer rWeap 1 0

 

Set DoOnce to 1

 

End

 

Begin GameMode

 

If DoOnce == 1

 

; etc .....

 

Set DoOnce to 0

 

endif

End

Edited by Mktavish
Link to comment
Share on other sites

That worked, feel stupid about it now too having never thought about doing it before the item removal. I'll have to add some extra scripting to rebind any hotkeys that people may assign to their gear but it works. With that I think that auto-sort system is good to go, however I'm still trying to find a function to utilize an array variable for the master system.

Link to comment
Share on other sites

Update:

 

So I've been refining the specific auto sort system and I've ran into a new issue with the reequipping part, whenever I wear headgear during the script it always gives me an extra "ghost" headgear. This item will CTD the game if it's touched in any way. I remember having a similar issue months ago using the EquipItem function, but here that function is solid I think, I even tried using the function with a GetItemCount lock on it to no avail. Suggestions?

 

 

 

scn GMArmoryArmorContFactionsScript

short EquipDetection

ref StoredHotkeyItem1
ref StoredHotkeyItem2
ref StoredHotkeyItem3
ref StoredHotkeyItem4
ref StoredHotkeyItem5
ref StoredHotkeyItem6
ref StoredHotkeyItem7
ref StoredHotkeyItem8

ref ItemBody
ref ItemHead

Begin onActivate
if (player.IsSneaking == 0)
activate
elseif (player.IsSneaking == 1)
set StoredHotkeyItem1 to GetHotKeyItem 1
set StoredHotkeyItem2 to GetHotKeyItem 2
set StoredHotkeyItem3 to GetHotKeyItem 3
set StoredHotkeyItem4 to GetHotKeyItem 4
set StoredHotkeyItem5 to GetHotKeyItem 5
set StoredHotkeyItem6 to GetHotKeyItem 6
set StoredHotkeyItem7 to GetHotKeyItem 7
set StoredHotkeyItem8 to GetHotKeyItem 8

set ItemBody to player. GetEquippedObject 2
set ItemHead to player. GetEquippedObject 10
set EquipDetection to 1
endif
End

Begin Gamemode
if (EquipDetection == 1)
player.RemoveItemTarget ItemBody GMMansionValueContRef 1
player.RemoveItemTarget ItemHead GMMansionValueContRef 1
set EquipDetection to 2
endif

if (EquipDetection == 2)
player.removeItemTarget OutfitKings GMArmoryArmorContFactionsRef
player.removeItemTarget ArmorWhiteGloveSociety GMArmoryArmorContFactionsRef
player.removeItemTarget VMS18WhiteGloveMask GMArmoryArmorContFactionsRef
player.removeItemTarget OutfitRepconCult GMArmoryArmorContFactionsRef

...........more item removal scripting...
set EquipDetection to 3
endif

if (EquipDetection == 3)
GMMansionValueContRef.RemoveItemTarget ItemBody player 1
GMMansionValueContRef.RemoveItemTarget ItemHead player 1
set EquipDetection to 4
endif

if (EquipDetection == 4)
setHotkeyItem 1 StoredHotkeyItem1
setHotkeyItem 2 StoredHotkeyItem2
setHotkeyItem 3 StoredHotkeyItem3
setHotkeyItem 4 StoredHotkeyItem4
setHotkeyItem 5 StoredHotkeyItem5
setHotkeyItem 6 StoredHotkeyItem6
setHotkeyItem 7 StoredHotkeyItem7
setHotkeyItem 8 StoredHotkeyItem8
player.EquipItem ItemBody 0 1
player.EquipItem ItemHead 0 1
set EquipDetection to 0
endif

Edited by General Gred
Link to comment
Share on other sites

It fixed the ghost items as far as I can tell but now it wont detect certain hats like the Ranger Hat since it doesn't use the hair slot, and no matter what else I try, hat slot, headband slot, even the mask slot it returns a ghost copy with it, I haven't the slightest clue where these things are coming from. Now I need to do the clothing slot which is gonna be hard if I can't figure out the ghost issue and I'm still hung up on finding a way to use an array for the master auto sorting sysytem.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...