How To Get Renaming A Spell To Persist Across Saves?

Post » Sun Nov 18, 2012 11:07 pm

So, I asked about how to use one spell to store a second spell as a property and then have a third spell get the second spell from the property http://www.gamesas.com/topic/1407459-how-to-externally-set-property-on-only-one-instance-of-a-script/. Using a quest script as the receptacle works fabulously, and the properties themselves persist across saves (i.e. when I restart the game, the recall spell still casts the spell it's supposed to).

However, I'm having difficulty renaming the spell and having the new name persist. I'm aware that SetName isn't currently persistent, so what I'm trying to do is just set the name in an OnPlayerLoadGame event block. So, I've attached the following script to a player alias in the quest I'm using as a receptacle for the properties:

Scriptname ishicobattlemagealiasscript extends Actor  ishicobattlemagequestscript Property questScript AutoSpell Property recallSpell1 AutoSpell Property recallSpell2 AutoEvent OnPlayerLoadGame()     Spell storedSpell1 = (questScript.storedSpell1 as Spell)     Spell storedSpell2 = (questScript.storedSpell2 as Spell)     recallSpell1.setName("Battle Magic: " + storedSpell1.getName())     recallSpell2.setName("Battle Magic: " + storedSpell2.getName())EndEvent

However, it doesn't seem to work. I'm not sure where the problem is exactly.

For what it's worth, even before I set up the OnPlayerLoadGame stuff, the new name WOULD persist across saves as long as I didn't shut down the game completely.
User avatar
Justin Hankins
 
Posts: 3348
Joined: Fri Oct 26, 2007 12:36 pm

Post » Mon Nov 19, 2012 7:01 am

(really, this is too advanced for me ... Justin or someone may be better able to help ... when awake ;))

Event OnPlayerLoadGame()


Instead, have you tried OnInit??

(does about same, fires about same time)
User avatar
Setal Vara
 
Posts: 3390
Joined: Thu Nov 16, 2006 1:24 pm

Post » Sun Nov 18, 2012 5:39 pm

Edits via SKSE's http://www.creationkit.com/SetName_-_Form and http://www.creationkit.com/SetWeight_-_Form, among others, get wiped when the game closes. You can maintain them with something like http://www.creationkit.com/Complete_Example_Scripts#Maintenance.2Fupdate_code_which_runs_once_per_save_load_and_shows_a_message_when_a_mod_is_updated_or_first_loaded. http://www.creationkit.com/OnPlayerLoadGame_-_Actor won't fire the first time thus the compartmentalization and calling of the Maintenance function in an http://www.creationkit.com/OnInit event to cover the initial changing.

Also, the player's script should be extending ReferenceAlias rather than Actor.

Spoiler
ScriptName ishicobattlemagealiasscript Extends ReferenceAlias  ishicobattlemagequestscript Property questScript AutoEvent OnPlayerLoadGame()	questScript.Maintenance()EndEvent;*******************ScriptName YourQuestScript Extends QuestSpell Property recallSpell1 AutoSpell Property recallSpell2 AutoEvent OnInit()	Maintenance()EndEventFunction Maintenance()	;Set namesEndFunction
User avatar
Sophie Payne
 
Posts: 3377
Joined: Thu Dec 07, 2006 6:49 am

Post » Mon Nov 19, 2012 7:59 am

Register your Names just after changes with String Properties or String[] :

String Property storedSpellName1 AutoString Property storedSpellName2 AutoString[] Property storedSpellName AutostoredSpellName = new String[3]; somewhere just after changestoredSpellName1 = storedSpell1.GetName()storedSpellName2 = storedSpell2.GetName()storedSpellName[1] = storedSpell1.GetName()storedSpellName[2] = storedSpell2.GetName()Event OnPlayerLoadGame()	 recallSpell1.setName("Battle Magic: " +storedSpellName1)	 recallSpell2.setName("Battle Magic: " +storedSpellName2)	 recallSpell1.setName("Battle Magic: " +storedSpellName[1])	 recallSpell2.setName("Battle Magic: " +storedSpellName[2])EndEvent
User avatar
Emily Rose
 
Posts: 3482
Joined: Sat Feb 17, 2007 5:56 pm

Post » Mon Nov 19, 2012 7:29 am

Register your Names just after changes with String Properties or String[] :

String Property storedSpellName1 AutoString Property storedSpellName2 AutoString[] Property storedSpellName AutostoredSpellName = new String[3]; somewhere just after changestoredSpellName1 = storedSpell1.GetName()storedSpellName2 = storedSpell2.GetName()storedSpellName[1] = storedSpell1.GetName()storedSpellName[2] = storedSpell2.GetName()Event OnPlayerLoadGame()	 recallSpell1.setName("Battle Magic: " +storedSpellName1)	 recallSpell2.setName("Battle Magic: " +storedSpellName2)	 recallSpell1.setName("Battle Magic: " +storedSpellName[1])	 recallSpell2.setName("Battle Magic: " +storedSpellName[2])EndEvent

I think the issue was that OnPlayerLoadGame() doesn't fire the first time or wev... is there any reason I should do this (registering Strings) instead of what I've already got?
User avatar
laila hassan
 
Posts: 3476
Joined: Mon Oct 09, 2006 2:53 pm

Post » Sun Nov 18, 2012 3:44 pm

Ach. Well if the issue was that no there's no reason to register. Sorry for the mistake.
User avatar
Krystal Wilson
 
Posts: 3450
Joined: Wed Jan 17, 2007 9:40 am

Post » Sun Nov 18, 2012 4:39 pm

Ach. Well if the issue was that no there's no reason to register. Sorry for the mistake.

Yeah, I just tested it out and after setting up the initial OnInit (as well as doing a LOT of cleaning-up of my code) it works fine.

I was just wondering if there were any benefits to storing the strings, like being faster or wev :)
User avatar
glot
 
Posts: 3297
Joined: Mon Jul 17, 2006 1:41 pm

Post » Mon Nov 19, 2012 4:57 am

If i may ask that, i know a dumb question, why not simply rename the spell in the creation kit? This would be permanent.

Or did you try something like absorbing a enemy spell and teaching it to the player temporarily?
User avatar
naomi
 
Posts: 3400
Joined: Tue Jul 11, 2006 2:58 pm


Return to V - Skyrim