Getting a crash with my script and can't figure out why.. pl

Post » Tue Nov 20, 2012 6:20 am

Trying (succeeded actually with another version), to create an auto - remove all from player script.

I have a saved set - where a player puts items into a container, what goes in gets added to a saved set form, if removed, the item gets removed. Player chooses to sort, and it compares whats in the saved set to the inventory, moves from player to saved container, moves all from player to the storage container, then moves the saved set back to the player.

I can get it to work fine if i just want to add or remove from the conainer, but i want to create a sort of 'button system' where if you open the container it showes what's being saved. if i remove the item, it would remove the 'button' and as well as remove the item in the saved form. Most of the time i can get it to all work fine, but then on occasion i'll get a crash when either adding to the container, or sorting the player. I've been working on all forms of this thing for the last 4 days and I can't get it to work consistently.
Then i have the issue where it'll work okay if transferring one item at a time, but then if i hit remove all, it does odd things and sometimes the items don't get removed from the formlist.

Again, i can get it to work 100 percent if i just go with having items being checked to see if the container is full or not, but then when viewing or adding to the save set, the player won't be able to see what's in the container or the items already saved.

Anyhow, here's the current rendition of the scripts: This one is on a spell that i cast:
Spoiler
Scriptname CSTeleportHomeScript extends ActiveMagicEffect  {Teleport from the home to the last place teleported from and back}ObjectReference Property rHomeMarker  Auto  {Marker used at the Home - Does NOT move}ObjectReference Property rStoredMarker  Auto  {Marker used to mark a teleport destination - moves to players location when casting mark}ObjectReference Property rMarkSpellMarker  Auto  {Map Marker used to show the location on the world map}ObjectReference PlayerObjectReference Property CSTempSaveChestRef AutoObjectReference Property CSSaveChestRef AutoObjectReference Property CSSummonChestRef AutoObjectReference Property AutoHide AutoObjectReference Property AutoAnimal AutoObjectReference Property AutoArrow AutoObjectReference Property AutoArmor AutoObjectReference Property AutoShield AutoObjectReference Property AutoBook AutoObjectReference Property AutoCloth Auto;ObjectReference Property AutoDaedric AutoObjectReference Property AutoFoodRaw AutoObjectReference Property AutoFood AutoObjectReference Property AutoIngot AutoObjectReference Property AutoIngredient AutoObjectReference Property AutoJewel AutoObjectReference Property AutoKey AutoObjectReference Property AutoMisc AutoObjectReference Property AutoPotion AutoObjectReference Property AutoPoison AutoObjectReference Property AutoScroll AutoObjectReference Property AutoSoulGem AutoObjectReference Property AutoWeapon AutoObjectReference Property AutoEnch AutoObjectReference Property AutoMainCont  Auto  Message Property CSSaveSetOptionsMsg AutoMessage Property CSSpellMainMenuMsg  Auto  ;Open Container - Transfer to Container & Open - Auto-Sort ContainerInt Property iState = 1 Auto  Int Property iSubState = 0 Auto  {State used to determin which part of the script to use: Properties are localized to a specific spell: 1 - Home Spell, 2 - Mark Spell, 3 - Recall Spell, 4 - Summon Chest}Event OnEffectStart(Actor Target, Actor Caster)	Player = Game.Getplayer()	if iState == 1								;Teleport Home Spell		if iSubstate == 0			Player.moveto (rHomeMarker)			iSubState = 1			endif	elseif iState == 2							;Mark Spell		if iSubstate == 0			rMarkSpellMarker.Disable ()			rStoredMarker.MoveTo (Player)	   ;This WORKS			rMarkSpellMarker.MoveTo (Player)				rMarkSpellMarker.Enable ()			rMarkSpellmarker.Addtomap ()			iSubstate = 1		endif	elseif iState == 3							;Recall Spell		if iSubState == 0			Player.MoveTo (rStoredMarker)			iSubState = 1		endif;=================================================Relevant Code Below ===================	elseif iState == 4							;Summon Chest		if iSubState == 0		int ichoice = CSSpellMainMenuMsg.show()			if ichoice == 0			;Open Container				CSSummonChestRef.Activate (Player)				iSubState = 1			elseif ichoice == 1		;Tranfer to Container & Open				AutoWeapon.RemoveAllItems (CSSummonChestRef)				AutoSoulGem.RemoveAllItems (CSSummonChestRef)				AutoScroll.RemoveAllItems (CSSummonChestRef)				AutoPoison.RemoveAllItems (CSSummonChestRef)				AutoPotion.RemoveAllItems (CSSummonChestRef)				AutoMisc.RemoveAllItems (CSSummonChestRef)				AutoJewel.RemoveAllItems (CSSummonChestRef)				AutoIngredient.RemoveAllItems (CSSummonChestRef)				AutoIngot.RemoveAllItems (CSSummonChestRef)				AutoFood.RemoveAllItems (CSSummonChestRef)				AutoCloth.RemoveAllItems (CSSummonChestRef)				AutoArmor.RemoveAllItems (CSSummonChestRef)				AutoHide.RemoveAllItems (CSSummonChestRef)				AutoEnch.RemoveAllItems (CSSummonChestRef)				WeapOnRef.Disable()				IngotOnRef.Disable()				SoulGemOnRef.Disable()				BookOnRef.Disable()				ArmorOnRef.Disable()				PotionOnRef.Disable()				PoisonOnRef.Disable()				IngredOnRef.Disable()				MiscOnRef.Disable()				JewelOnRef.Disable()				HideOnRef.Disable()				ClothOnRef.Disable()				FoodOnRef.Disable()				EnchOnRef.Disable()				utility.wait(0.2)				CSSummonChestRef.Activate (Player)				iSubState = 1			elseif ichoice == 2		;Auto-Sort Container				CSSummonChestRef.RemoveAllitems (AutoMainCont)				iSubState = 1			elseif ichoice == 3		;Save Set Options				int iSubchoice = CSSaveSetOptionsMsg.show()					if iSubchoice == 0			;Save Set;						CSAddSaveToChest()						CSSaveChestRef.Activate (Player)						iSubState = 1					elseif iSubchoice == 1		   ;Clear Set & Form						CSSaveSetForm.Revert()						CSSaveChestRef.RemoveAllItems()						debug.notification("Cleared Set")						iSubState = 1					elseif iSubchoice == 2		 ;Exit					endif			elseif ichoice == 4		;Sort Player				CheckSaveSet()			elseif ichoice == 5		;Exit			endif		endif	endif	EndEventFunction CSAddSaveToChest()			CSSaveChestRef.RemoveAllItems()			Int iFormIndex = CSSaveSetForm.GetSize()			While iFormIndex > 0				iFormIndex -= 1				Form kForm = CSSaveSetForm.GetAt(iFormIndex)				CSSaveChestRef.AddItem(kForm, 1)			EndWhile			utility.wait(0.1)EndFunctionFunction CheckSaveSet()	Int iFormIndex = Game.GetPlayer().GetNumItems()	game.DisablePlayerControls()	debug.notification("Please wait..")	While iFormIndex > 0		iFormIndex -= 1		Form kForm = Game.GetPlayer().GetNthForm(iFormIndex)		If CSSaveSetForm.HasForm(kForm)			Int aiCount = Game.GetPlayer().GetItemCount(kForm)			game.GetPlayer().RemoveItem(kForm, aiCount, True, CSTempSaveChestRef )		EndIf	EndWhile	utility.wait(0.2)	game.getplayer().RemoveAllItems(AutoMainCont)	utility.wait(0.2)	CSTempSaveChestRef.RemoveAllItems(Game.GetPlayer())	debug.notification("Sorting Complete")	game.EnablePlayerControls()EndFunctionEvent OnEffectEnd(Actor Target, Actor Caster)		iSubState = 0		debug.notification("Chest is ready.")EndEventObjectReference Property WeapOnRef AutoObjectReference Property SoulGemOnRef AutoObjectReference Property ScrollOnRef AutoObjectReference Property BookOnRef AutoObjectReference Property ArmorOnRef AutoObjectReference Property PotionOnRef AutoObjectReference Property PoisonOnRef AutoObjectReference Property IngredOnRef AutoObjectReference Property MiscOnRef AutoObjectReference Property JewelOnRef AutoObjectReference Property IngotOnRef AutoObjectReference Property HideOnRef AutoObjectReference Property ClothOnRef AutoObjectReference Property FoodOnRef AutoObjectReference Property EnchOnRef  Auto  FormList Property CSSaveSetForm AutoMiscObject Property Gold001 Auto

This one is on the container (Full 'un- edited') Tried several things, highly commented things out - Ignore the commented parts, some are just things i was trying that i never took out so if read it wouldn't make much sense. I do that so if i need a particular code again it's right in front of me.) I'll post the 'cleaned' up non-commented script after this one.

Spoiler
Scriptname CSSavedSetContScript extends ObjectReference  MiscObject Property Gold001 AutoFormList Property CSSaveSetForm AutoFormList Property CSRemoveSetForm AutoInt Property iState AutoObjectReference Property CSTempSaveChestRef AutoEvent OnActivate(ObjectReference akActionRef)CSTempSaveChestRef.RemoveAllItems();			self.RemoveAllItems();			utility.wait(0.1);			Int iFormIndex = CSSaveSetForm.GetSize();			While iFormIndex > 0;				iFormIndex -= 1;				ObjectReference kForm = CSSaveSetForm.GetAt(iFormIndex ) As ObjectReference;				Form kForm = Self.GetNthForm(iFormIndex);					self.AddItem(kForm, 1);			EndWhileEndEventEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)	if akSourceContainer == Game.Getplayer()	;	if !CSSaveSetForm.hasform(akbaseItem)		CSSaveSetForm.AddForm(akBaseItem);		debug.notification("Form Added");		aiItemCount = self.GetItemCount(akBaseItem)		self.removeitem(akbaseItem, AiItemCount, True, CSTempSaveChestRef);		CSTempSaveChestRef.RemoveAllItems(game.getplayer())		self.additem(akBaseItem,1)		Int aiItemCountTwo = self.GetItemCount(akBaseItem);		utility.wait(0.1)		if AiItemCountTwo > 1			AiItemCountTwo += AiItemCountTwo			self.removeitem(akbaseItem, AiItemCountTwo)			self.additem(akbaseItem, 1);			utility.wait(0.1)		endif			RegisterforSingleUpdate(2);	else;		debug.message("Only one item each");		UnregisterForUpdate();		aiItemCount = self.GetItemCount(akBaseItem);		aiItemCount -= 1;		self.removeitem(akbaseItem, AiItemCount, True, CSTempSaveChestRef);		debug.notification("Nothing Added");		RegisterforSingleUpdate(2);	endif	endifEndEvent;State TooManyItems;	Event OnBeginState();		game.disableplayercontrols();		game.enableplayercontrols();		debug.messagebox("Only one Item at a time.");	EndEvent;EndStateEvent OnUpdate()		game.DisablePlayerControls()		debug.notification("Please wait...");			Int iFormIndex = CSRemoveSetForm.GetSize();			While iFormIndex > 0;				iFormIndex -= 1;				Form kForm = CSRemoveSetForm.GetAt(iFormIndex);				Game.GetPlayer().RemoveItem(kForm, 1, False);			EndWhile;			CSRemoveSetForm.Revert();		iFormIndex = Self.GetNumItems();		if iFormIndex < 1;			CSSaveSetForm.Revert();		endif;		else;			CSSaveSetForm.Revert();			While iFormIndex > 0;				iFormIndex -= 1;				Form kForm = Self.GetNthForm(iFormIndex);				Int aiItemCount = GetItemCount(kForm);				;if AiItemCount > 1				;	AiItemCount += AiItemCount				;	self.removeItem(kForm, AiItemCount)				;	utility.wait(0.1)				;	self.AddItem(kForm, 1)				;endif;				CSSaveSetForm.AddForm(kForm);			EndWhile		;		endif;	utility.wait(0.2)	CSTempSaveChestRef.RemoveAllItems(Game.GetPlayer());	self.RemoveAllItems()	debug.notification("Saved Set = Saved")	game.EnablePlayerControls()EndEvent	Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)	if akSourceContainer == Game.GetPlayer();		if CSSaveSetForm.HasForm(akBaseItem)			CSSaveSetForm.RemoveAddedForm(akBaseItem);			CSRemoveSetForm.AddForm(akBaseItem)			debug.notification("Form Removed")			Game.GetPlayer().removeItem(AkBaseItem, AiItemCount, True);		endif;		int iFormIndex = Self.GetNumItems();		if iFormIndex < 1;			CSSaveSetForm.Revert();			Game.GetPlayer().removeItem(AkBaseItem, 1, True);			CSTempSaveChestRef.RemoveAllItems(Game.GetPlayer());			Unregisterforupdate();		else;			Game.GetPlayer().removeItem(AkBaseItem, 1, True);			CSTempSaveChestRef.RemoveAllItems(Game.GetPlayer());			registerforsingleupdate(2);		endif		registerforsingleupdate(2)	endifEndEvent

And that same script only with the commented parts taken out for easier reading.

Spoiler
Scriptname CSSavedSetContScript extends ObjectReference  MiscObject Property Gold001 AutoFormList Property CSSaveSetForm AutoFormList Property CSRemoveSetForm AutoInt Property iState AutoObjectReference Property CSTempSaveChestRef AutoEvent OnActivate(ObjectReference akActionRef)	 CSTempSaveChestRef.RemoveAllItems()EndEventEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)	if akSourceContainer == Game.Getplayer()		 CSSaveSetForm.AddForm(akBaseItem)		 self.removeitem(akbaseItem, AiItemCount, True, CSTempSaveChestRef)		 self.additem(akBaseItem,1)		 Int aiItemCountTwo = self.GetItemCount(akBaseItem)		 if AiItemCountTwo > 1			AiItemCountTwo += AiItemCountTwo			self.removeitem(akbaseItem, AiItemCountTwo)			self.additem(akbaseItem, 1)		 endif			RegisterforSingleUpdate(2)	  endifEndEventEvent OnUpdate()		game.DisablePlayerControls()		debug.notification("Please wait...")		CSTempSaveChestRef.RemoveAllItems(Game.GetPlayer())		debug.notification("Saved Set = Saved")		game.EnablePlayerControls()EndEvent	Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)	if akSourceContainer == Game.GetPlayer()	   	 CSSaveSetForm.RemoveAddedForm(akBaseItem)	   	 debug.notification("Form Removed")			Game.GetPlayer().removeItem(AkBaseItem, AiItemCount, True)			registerforsingleupdate(2)	endifEndEvent


I'm tired and can't wrap my head around how to go about doing this using a 'button' type system. 4 days going between the two scripts, oiy.

Thanks for any help. I appreciate it.

-Mush-
User avatar
Blessed DIVA
 
Posts: 3408
Joined: Thu Jul 13, 2006 12:09 am

Post » Tue Nov 20, 2012 1:31 pm

Things to check:

Could be a dirty save game issue, so USE A NEW GAME to test this (but only AFTER you get out of the tutorial part of the game, that means out of the sewers and on your way to riverwood town.)

Could be a conflict, so unload ALL your mods, then only load your ONE mod that you are testing (again, only after the tutorial*).

Could be an issue with script memory/ram use settings, use the default Skyrim INI to test your mod. This has actually happen to me were I thought I had a corrupted scrip but it turned out it was a INI setting I had made recently to "try out" and forgot about it.


Rule of thumb is that to test for CTD from your scripts you should first test in a STRICTLY VANILLA ENVIRONMENT!
Breaking that rule has taken me on wild goose chase/witch hunt thinking it was some issue in MY mod.


* The tutorial part of the game runs on some slightly "different" game code than the rest of the game. Even back in Oblivion days I ALWAYS had strange issues trying to run perfectly fine scripts during the tutorial part of the game. Now I just always tell my users not to load my mods until after that part of the game.
User avatar
Rob Smith
 
Posts: 3424
Joined: Wed Oct 03, 2007 5:30 pm

Post » Tue Nov 20, 2012 8:17 am

nods, yup. Done all the above. I'm missing something, but i can't find it. maybe a timing issue. i don't know.
User avatar
leigh stewart
 
Posts: 3415
Joined: Mon Oct 23, 2006 8:59 am

Post » Tue Nov 20, 2012 4:02 pm

Could be the apparently bugged formlist functions you are using (Revert()?). See http://www.gamesas.com/topic/1365445-bug-formlist-functions-seem-to-break-under-certain-conditions/ thread for the details.
User avatar
Nany Smith
 
Posts: 3419
Joined: Sat Mar 17, 2007 5:36 pm

Post » Tue Nov 20, 2012 3:26 am

Zartar: Thanks, that all is consistent with what is happening. Now to figure out how to do what I need to do without those functions. I wouldn't even begin to know how arrays work, but from what I understand, they have to be certain lengths to start. With how my function works it could change dynamically without any end length. could be an unlimited amount of items that go in the chest.

I can figure out how to work it successfully, but it would mean the player wouldn't be able to see already what's in the list of saved sets. Could go about adding things to a hidden container and compare the players items with that of the items in the set container. move things as appropriate etc.

-Mush-
User avatar
Sara Lee
 
Posts: 3448
Joined: Mon Sep 25, 2006 1:40 pm


Return to V - Skyrim