xcafe Posted December 10, 2016 Share Posted December 10, 2016 So this isn't working again, and I don't know why! Basically, I have it set up like this: State LearningEvent OnBeginState();If spell has reached 100% learned, add spell to playerif (percentageLearned >= 100)CentralQuest.GSL.AddForm(SpellLearned)Debug.Notification("You have transcribed " + LearnSpell + ".")elseDebug.Notification("You have learned " + percentageLearned as int + "% of " + LearnSpell + ".")endIf This here is part of a larger script attached to spelltomes, but this part is the part that adds the spells in the tomes to the formlist. Then my script, here, calls the formlist and uses the function from this post to add the spells to the player. State StudyingEvent OnBeginState();This will run as studying begins.;;; Include anything that needs to happen at study start here.Int WaitTime = CentralQuest.GSL.GetSize()Game.DisablePlayerControls(True, True, True, False, True, True, True, True)Game.ForceThirdPerson()Debug.SendAnimationEvent(PlayerRef, "ChairReadingStart")Utility.Wait(WaitTime * 5.0) ; sets when studying will be completeDebug.SendAnimationEvent(PlayerRef, "IdleForceDefaultState")Game.EnablePlayerControls()AddSpells()GoToState("Studied") ; leave studying state so OnRead can trigger againEndEventEndStateFunction AddSpells()Debug.Notification("addspells called")Int ListSize = CentralQuest.GSL.GetSize()Int Index = 0While Index < ListSizeForm Entry = CentralQuest.GSL.GetAt(Index)If (Entry as Spell)PlayerRef.AddSpell(Entry as Spell)EndIfIndex += 1EndWhileDebug.Notification("spells added")EndFunction Except that it's not doing that. It adds the spell that I have manually added into the formlist through the CK, but none of the ones it should be adding from the tomes. To clarify, it is being called, as all the debugs are going off, it just isn't working. In addition, the function to remove the spells also isn't working. Here's the script for that: State StudiedEvent OnBeginState()NotStudied = falseDebug.Notification("State 'Studied' Entered")RegisterForSingleUpdateGameTime(24.0)Debug.Notification("Registered for update(24)")EndEventEvent OnUpdateGameTime()Debug.Notification(GametimeUpdated)Int ListSize = CentralQuest.GSL.GetSize()Int Index = 0While Index < ListSizeForm Entry = CentralQuest.GSL.GetAt(Index)If (Entry as Spell)PlayerRef.RemoveSpell(Entry as Spell)EndIfIndex += 1EndWhileGoToState("")EndEventEndState It's not even removing the spell that's manually added in the formlist, I don't know what the deal is. Here's the full script, for reference: Scriptname grimoirescript3 extends ObjectReferenceCentralListScript Property CentralQuest AutoActor Property PlayerRef AutoMessage Property GMSG AutoBool Property NotStudied = True AutoEvent OnRead(){Begins the studying if conditions are right.}If (NotStudied)If (PlayerRef.GetSitState() < 3)Debug.Notification("You must be seated to study your grimoire!")ElseInt iButton = GMSG.Show()If (iButton == 0) ;yesCloseTheBook()GoToState("Studying")ElseIf (iButton == 1) ;noDebug.Notification("You decide not to study your spells right now.")EndIfEndIfEndIfEndEventState StudyingEvent OnBeginState();This will run as studying begins.;;; Include anything that needs to happen at study start here.Int WaitTime = CentralQuest.GSL.GetSize()Game.DisablePlayerControls(True, True, True, False, True, True, True, True)Game.ForceThirdPerson()Debug.SendAnimationEvent(PlayerRef, "ChairReadingStart")Utility.Wait(WaitTime * 5.0) ; sets when studying will be completeDebug.SendAnimationEvent(PlayerRef, "IdleForceDefaultState")Game.EnablePlayerControls()AddSpells()GoToState("Studied") ; leave studying state so OnRead can trigger againEndEventEndStateState StudiedEvent OnBeginState()NotStudied = falseDebug.Notification("State 'Studied' Entered")RegisterForSingleUpdateGameTime(24.0)Debug.Notification("Registered for update(24)")EndEventEvent OnUpdateGameTime()Debug.Notification(GametimeUpdated)Int ListSize = CentralQuest.GSL.GetSize()Int Index = 0While Index < ListSizeForm Entry = CentralQuest.GSL.GetAt(Index)If (Entry as Spell)PlayerRef.RemoveSpell(Entry as Spell)EndIfIndex += 1EndWhileGoToState("")EndEventEndStateFunction CloseTheBook(){Close the book and inventory menu too.}Game.DisablePlayerControls(false, false, false, false, false, true, false, false)Utility.Wait(0.01)Game.EnablePlayerControls(false, false, false, false, false, true, false, False)EndFunctionFunction AddSpells()Debug.Notification("addspells called")Int ListSize = CentralQuest.GSL.GetSize()Int Index = 0While Index < ListSizeForm Entry = CentralQuest.GSL.GetAt(Index)If (Entry as Spell)PlayerRef.AddSpell(Entry as Spell)EndIfIndex += 1EndWhileDebug.Notification("spells added")EndFunction Link to comment Share on other sites More sharing options...
Recommended Posts