Jump to content

[LE] Script help for MCM.. half working


Recommended Posts

Okay, so the books are being added each time the menu is being closed. Try this.

 

 

Book[] Property MyBooks Auto
Bool BooksAdded = False
Bool InitialSetup = False

Function AddBooks()
	Actor aPlayer = Game.GetPlayer()
	int i = MyBooks.Length    
	while (i > 0)
		i -= 1
		aPlayer.AddItem(MyBooks[i], 1)
	endWhile
EndFunction

Function RemoveBooks()
	Actor aPlayer = Game.GetPlayer()
	int i = MyBooks.Length    
	while (i > 0)
		i -= 1
		aPlayer.RemoveItem(MyBooks[i], 1)
	endWhile
EndFunction

Event OnOptionSelect(int option)
	If (option == OIDBooks)
		BooksAdded = !BooksAdded
		SetToggleOptionValue(option, BooksAdded)
	EndIf
EndEvent

Event OnConfigClose()
    RegisterForSingleUpdate(0.1)
EndEvent

Event OnUpdate()
	If BooksAdded == True
		If InitialSetup == False
			InitialSetup = True
			AddBooks()
		EndIf
	Else
		RemoveBooks()
		InitialSetup = False
	EndIf
EndEvent

This uses a "master" bool that is toggled when the books are added and thus prevents adding the books again. It is reset when the books are removed so that the books may be added once more when the option is turned on in the MCM.

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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