Jump to content

SKSE's setname doesn't save?


Spinner385

Recommended Posts

Edit: previous post deleted.

 

Hmm. Possibly the new set name isn't saved with the savegame, or maybe the potion is being reset after loading a savegame? Might also have to do with the way objects are stored in the inventory.

 

The only solution that I can think of atm would be to change the way that you rename the potions. Instead of putting a script on the player, put a script on the potion that renames it from an OnInit() block. That way every time the potion is initialized (by loading a savegame, resetting it, whatever) the name will get set again.

Edited by steve40
Link to comment
Share on other sites

Thnx again

 

I read this line on some docs under save games, so it doesn't look like its going to happen:

 

Changing Masterfile Value

If you have an existing property and change its value in the masterfile, the script will only receive the new value if it doesn't exist in the save. In other words - changing the value will not overwrite the value it has in the save game.

 

I wanted to add it to potions but I couldn't find any objects for potions that I could attach scripts to. The magic effects that activate will allow scripts but not the potions their selves. I may be looking in the wrong place.

 

Im currently looking for a way to evaluate my inventory OnLoad (OnInit would be better with an onitemadded active). Checking out some looting scripts as I know they evaluate inventory. One guy said he made an imaginary chest and transferred everything to it to be evaluated. Trying to figure out how that transfer took place, but then I could use the onitemadd events from there. Problem is he has .pex files and their gibberish.

 

Edit: Think I got it (roughly):

 

Event OnInit()
Game.GetPlayer().RemoveAllItems(ObjectReference akTransferTo = SomeChest, bool abKeepOwnership = true??)

SomeChest.RemoveAllItems(ObjectReference akTransferTo = Game.GetPlayer(), bool abKeepOwnership = false??)

...

Endevent

 

 

Might work.

Edited by Spinner385
Link to comment
Share on other sites

Hmm. Maybe put that in an OnPlayerLoadGame() block instead of OnInit. This would get called on the player every time a savegame is loaded. Oninit() will not necessarily fire every time the game loads, I think. You could add the new block to your previous RenamePotion script.
Link to comment
Share on other sites

Yeah your right I got it to work and had to use OnPlayerLoadGame(). DIdn't quite understand OnInit. Now I just have to write some script to reequip everything so your not naked every time you load the game. Getting real close to an uploadable product. This was a good script to learn with, always hard to break through that first part of new languages. Good to have help =].

 

BTW maybe you have a more elegant way to do this (particularly having to place the barrel):

 

Event OnPlayerLoadGame()

ObjectReference akTransferTo = Game.GetPlayer().PlaceAtMe(Game.GetForm(0x0008771D))

Game.GetPlayer().RemoveAllItems(akTransferTo,false,false)

akTransferTo.RemoveAllItems(Game.GetPlayer(),false,false)

akTransferTo.Delete()

Endevent

Link to comment
Share on other sites

The way I would handle the barrel is I would create a new empty interior cell for holding all my misc stuff, and drag a barrel into that cell via the Render window. Then in my script I would assign a Property for the barrel, then fill the property with the barrel's reference. Then I could transfer all the items into and out of the barrel (which is in the "hidden" cell that I made) without needing to create a new barrel every time, and not needing to place the barrel at the player, and no need to destroy the barrel afterwards).

 

Event OnPlayerLoadGame()
Actor player = Game.GetPlayer() ; this way we only call GetPlayer once, it's more efficient than calling it twice or more
Player.RemoveAllItems(myBarrelRef,false,false) 
myBarrelRef.RemoveAllItems(Player,false,false) 
Endevent

ObjectReference Property myBarrelRef auto
{The barrel that I have placed in my empty cell in the CK}

 

The following script is from FG109's profile on the CK wiki. It's a set of scripts for getting the actors worn items. Requires SKSE.

 

 

;A function returning a 32 element array containing an actor's equipped (base) items. Requires SKSE. 

Form[] Function SaveOutfit(Actor akActor)
Form[] SavedOutfit = new Form[32]
int slot = 1
int i
int j
while (i < 32)
	Form TempForm = akActor.GetWornForm(slot)
	if (TempForm)
		SavedOutfit[j] = TempForm
		j += 1
	endif
	slot *= 2
	i += 1
endwhile
Return SavedOutfit
EndFunction

;There will probably be empty elements, since the actor probably is not wearing an item in every single slot. Automatically sorted so that empty elements are at the end of the array. 

;Also some functions to remove duplicate entries if needed. 

Form[] Function RemoveDuplicates(Form[] InputArray, Int Size)
Form[] OutputArray = new Form[32]
int i = 0
int j = 0
while (i < Size)
	if (ArrayHasForm(OutputArray, InputArray[i]) < 0)
		OutputArray[j] = InputArray[i]
		j += 1
	endif
	i += 1
endwhile
Return OutputArray
EndFunction

Int Function ArrayhasForm(Form[] MyArray, Form MyForm)
int i = 0
while (i < MyArray.Length)
	if (MyArray[i] == MyForm)
		Return i
	endif
	i += 1
endwhile
Return -1
EndFunction

 

Edited by steve40
Link to comment
Share on other sites

Thnx so much again.

 

The barrel idea actually explained a lot I didn't quite put together before. Much smoother.

 

Funny I had almost exactly the same script as the outfit script. His looks much cleaner of course. Wish I had found it before I did all that math and figuring =P.

 

I was looking for a way to make it less laggy, as your naked and jumpy for a bit. I wanted to use the OnObjectUnequipped and OnItemAdded events to see how that worked. So I need a list I can carry across events. As of right now I'm fighting to get either formlists or property arrays to work right. It may not help but I see it as a learning experience (an aggrevating one at that).

 

I can't express enough the gratitude for taking your time to help.

 

Edit: Im doubting how I can make the inventory evaluation part any smoother. What I'm worried about is loading in a harry situation and not having my armor on. I think I will make the full evaluation a spell and have onitemadded always running. Besides you only loose the names when you reload the client not your game. After that its figuring out how to upload as a mod.

Edited by Spinner385
Link to comment
Share on other sites

  • Recently Browsing   0 members

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