Jump to content

[LE] How to let form[] do work?


pxd2050

Recommended Posts

I edit a Outfit Manage MOdï¼I set a form[] Equipment, but it doesn't work. in game Equipment.length away return 0. what is wrong?can you help me?

 

function start(int IsAlias)
	RegisterForMenu("ContainerMenu")
	ActorRef = self.GetActorRef()
	if IsAlias == 1
		return
	endif
	ActorBase aActorBase = ActorRef.GetActorBase()
	OldOutfit = aActorBase.GetOutfit()
	form ItemRef
	int i = OldOutfit.GetNumParts()
	while i
		i -= 1
		ItemRef = OldOutfit.GetNthPart(i+1)
		Equipment[i] = ItemRef
	endwhile
	Debug.notification("BaseItem0 "+Equipment.Length)
endfunction
Scriptname outfit__MainScript extends ReferenceAlias  

import debug
import UI
import utility

LeveledItem Property TempItem auto 
Outfit Property NewOutfit Auto 
Outfit Property OldOutfit Auto 
Outfit Property EmptyOutfit Auto 
MiscObject Property Gold001 Auto
bool IsFollower
Actor ActorRef
form[] Equipment

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	if (akBaseItem as Armor) 
		ActorRef.EquipItem(akBaseItem)
		ActorRef.AddItem(Gold001,1)
	elseif (akBaseItem as Weapon)
		ActorRef.EquipItem(akBaseItem)
		ActorRef.AddItem(Gold001,1)
	endif
endEvent

Event OnMenuOpen(String MenuName)
	if ActorRef.IsPlayerTeammate()
		IsFollower = true
		ActorRef.SetPlayerTeammate(false)
	endif
	ActorRef.setoutfit(EmptyOutfit)
	int i = Equipment.Length
	while i
		i -= 1
		ActorRef.EquipItem(Equipment[i])
	endwhile
	ActorRef.AddItem(Gold001,1)		
	Debug.notification("BaseItem3 "+Equipment.Length)
endEvent

Event OnMenuClose(String MenuName)
	TempItem.Revert()
	form ItemRef
	int i = 31
	while i >=0
		ItemRef = ActorRef.GetEquippedArmorInSlot(i+30)
		if ItemRef
			TempItem.addform(ItemRef,1,1)
			Equipment[i] = ItemRef
		endif
		i -= 1
	endwhile
	ActorRef.setoutfit(NewOutfit)
	ActorRef.AddItem(Gold001,1)
	Debug.notification("BaseItem4 "+Equipment.Length)
	if IsFollower
		ActorRef.SetPlayerTeammate(true)
		IsFollower = false		
	endif
	UnregisterForMenu("ContainerMenu")
endEvent

function start(int IsAlias)
	RegisterForMenu("ContainerMenu")
	ActorRef = self.GetActorRef()
	if IsAlias == 1
		return
	endif
	ActorBase aActorBase = ActorRef.GetActorBase()
	OldOutfit = aActorBase.GetOutfit()
	form ItemRef
	int i = OldOutfit.GetNumParts()
	while i
		i -= 1
		ItemRef = OldOutfit.GetNthPart(i+1)
		Equipment[i] = ItemRef
	endwhile
	Debug.notification("BaseItem0 "+Equipment.Length)
endfunction

function back()
	ActorRef.setoutfit(EmptyOutfit)
	ActorRef.setoutfit(OldOutfit)
	ActorRef.AddItem(Gold001,1)
	form ItemRef
	int i = OldOutfit.GetNumParts()
	while i
		i -= 1
		ItemRef = OldOutfit.GetNthPart(i+1)
		Equipment[i] = ItemRef
	endwhile
	Debug.notification("BaseItem1 "+Equipment.Length)
endfunction

function Vanilla(outfit cloths)
	ActorRef.setoutfit(EmptyOutfit)
	ActorRef.setoutfit(cloths)
	ActorRef.AddItem(Gold001,1)
	form ItemRef
	int i = cloths.GetNumParts()
	while i
		i -= 1
		ItemRef = cloths.GetNthPart(i+1)
		Equipment[i] = ItemRef
	endwhile
	Debug.notification("BaseItem2 "+Equipment.Length)
endfunction

 

Link to comment
Share on other sites

I refer to SexLab sslActorAlias,why It can work but I can't work.

function Strip()
	if !ActorRef || ActorRef == none || IsCreature
		return
	endIf
	; Start stripping animation
	;if DoUndress
	;	Debug.SendAnimationEvent(ActorRef, "Arrok_Undress_G"+BaseSex)
	;	NoUndress = true
	;endIf
	; Select stripping array
	bool[] Strip
	if StripOverride.Length == 33
		Strip = StripOverride
	else
		Strip = Config.GetStrip(IsFemale, Thread.UseLimitedStrip(), IsType[0], IsVictim)
	endIf
	; Log("Strip: "+Strip)
	; Stripped storage
	Form ItemRef
	Form[] Stripped = new Form[34]
	; Right hand
	ItemRef = ActorRef.GetEquippedObject(1)
	if ContinueStrip(ItemRef, Strip[32])
		Stripped[33] = ItemRef
		ActorRef.UnequipItemEX(ItemRef, 1, false)
		StorageUtil.SetIntValue(ItemRef, "Hand", 1)
	endIf
	; Left hand
	ItemRef = ActorRef.GetEquippedObject(0)
	if ContinueStrip(ItemRef, Strip[32])
		Stripped[32] = ItemRef
		ActorRef.UnequipItemEX(ItemRef, 2, false)
		StorageUtil.SetIntValue(ItemRef, "Hand", 2) 
	endIf
	; Strip armor slots
	Form BodyRef = ActorRef.GetWornForm(Armor.GetMaskForSlot(32))
	int i = 31
	while i >= 0
		; Grab item in slot
		ItemRef = ActorRef.GetWornForm(Armor.GetMaskForSlot(i + 30))
		if ContinueStrip(ItemRef, Strip[i])
			; Start stripping animation
			if DoUndress && ItemRef == BodyRef ;Body
				Debug.SendAnimationEvent(ActorRef, "Arrok_Undress_G"+BaseSex)
				Utility.Wait(1.0)
				NoUndress = true
			endIf
			ActorRef.UnequipItemEX(ItemRef, 0, false)
			Stripped[i] = ItemRef
		endIf
		; Move to next slot
		i -= 1
	endWhile
	; Equip the nudesuit
	if Strip[2] && ((Gender == 0 && Config.UseMaleNudeSuit) || (Gender == 1 && Config.UseFemaleNudeSuit))
		ActorRef.EquipItem(Config.NudeSuit, true, true)
	endIf
	; Store stripped items
	Equipment = PapyrusUtil.MergeFormArray(Equipment, PapyrusUtil.ClearNone(Stripped), true)
	Log("Equipment: "+Equipment)
endFunction
Edited by pxd2050
Link to comment
Share on other sites

Unless pre-filled in the Creation Kit, arrays have to have their length defined. The sexlab script does this with the line:

Form[] Stripped = new Form[34]

You have nothing like this so the array length will always be 0.

 

Note that while the declaration of the array can be done in the empty state, the length definition can only be done inside a function or event.

Link to comment
Share on other sites

Unless pre-filled in the Creation Kit, arrays have to have their length defined. The sexlab script does this with the line:

Form[] Stripped = new Form[34]

You have nothing like this so the array length will always be 0.

 

Note that while the declaration of the array can be done in the empty state, the length definition can only be done inside a function or event.

It's so exciting to get up and see your reply,It's a perfect solution to the problem form[], and a lot of similar problems about “Unless pre-filled in the Creation Kit.”.

thank you very much.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...