Jump to content

Formlist functions not working :(


xcafe

Recommended Posts

So this isn't working again, and I don't know why!

 

Basically, I have it set up like this:

 

 

State Learning
Event OnBeginState()
;If spell has reached 100% learned, add spell to player
if (percentageLearned >= 100)
CentralQuest.GSL.AddForm(SpellLearned)
Debug.Notification("You have transcribed " + LearnSpell + ".")
else
Debug.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 Studying

Event 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 complete
Debug.SendAnimationEvent(PlayerRef, "IdleForceDefaultState")
Game.EnablePlayerControls()

AddSpells()


GoToState("Studied") ; leave studying state so OnRead can trigger again

EndEvent
EndState






Function AddSpells()
Debug.Notification("addspells called")
Int ListSize = CentralQuest.GSL.GetSize()
Int Index = 0
While Index < ListSize
Form Entry = CentralQuest.GSL.GetAt(Index)
If (Entry as Spell)
PlayerRef.AddSpell(Entry as Spell)


EndIf
Index += 1
EndWhile

Debug.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 Studied

Event OnBeginState()
NotStudied = false
Debug.Notification("State 'Studied' Entered")
RegisterForSingleUpdateGameTime(24.0)
Debug.Notification("Registered for update(24)")
EndEvent


Event OnUpdateGameTime()
Debug.Notification(GametimeUpdated)
Int ListSize = CentralQuest.GSL.GetSize()
Int Index = 0
While Index < ListSize
Form Entry = CentralQuest.GSL.GetAt(Index)
If (Entry as Spell)
PlayerRef.RemoveSpell(Entry as Spell)
EndIf
Index += 1
EndWhile

GoToState("")
EndEvent

EndState

 

 

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 ObjectReference
CentralListScript Property CentralQuest Auto
Actor Property PlayerRef Auto
Message Property GMSG Auto
Bool Property NotStudied = True Auto


Event OnRead()
{Begins the studying if conditions are right.}
If (NotStudied)
If (PlayerRef.GetSitState() < 3)
Debug.Notification("You must be seated to study your grimoire!")
Else

Int iButton = GMSG.Show()
If (iButton == 0) ;yes
CloseTheBook()
GoToState("Studying")
ElseIf (iButton == 1) ;no
Debug.Notification("You decide not to study your spells right now.")
EndIf
EndIf
EndIf
EndEvent

State Studying

Event 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 complete
Debug.SendAnimationEvent(PlayerRef, "IdleForceDefaultState")
Game.EnablePlayerControls()

AddSpells()


GoToState("Studied") ; leave studying state so OnRead can trigger again

EndEvent
EndState

State Studied

Event OnBeginState()
NotStudied = false
Debug.Notification("State 'Studied' Entered")
RegisterForSingleUpdateGameTime(24.0)
Debug.Notification("Registered for update(24)")
EndEvent


Event OnUpdateGameTime()
Debug.Notification(GametimeUpdated)
Int ListSize = CentralQuest.GSL.GetSize()
Int Index = 0
While Index < ListSize
Form Entry = CentralQuest.GSL.GetAt(Index)
If (Entry as Spell)
PlayerRef.RemoveSpell(Entry as Spell)
EndIf
Index += 1
EndWhile

GoToState("")
EndEvent

EndState

Function 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)
EndFunction

Function AddSpells()
Debug.Notification("addspells called")
Int ListSize = CentralQuest.GSL.GetSize()
Int Index = 0
While Index < ListSize
Form Entry = CentralQuest.GSL.GetAt(Index)
If (Entry as Spell)
PlayerRef.AddSpell(Entry as Spell)


EndIf
Index += 1
EndWhile

Debug.Notification("spells added")
EndFunction

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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