antstubell Posted June 27, 2021 Share Posted June 27, 2021 So I have a quest and I've made a script in that quest called SMTaddLightSourceâWhat is the papyrus fragment I have to use in a quest stage in order for the script to run?Do I need a property?Thanks. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted June 27, 2021 Share Posted June 27, 2021 Typically, the begin fragment will be used as most often it is desired that stuff happen as soon as the stage is started. No idea if you need a property or not. That depends upon what code you want in the script fragment itself. Link to comment Share on other sites More sharing options...
antstubell Posted June 28, 2021 Author Share Posted June 28, 2021 Ok, I'll detail what I want. When player picks up a light source, in my case either a torch, a lantern or a candle I want a message to appear that says "It is always advisable to keep a source of with you." Appear once only. I thought that having a quest run as start game enabled and adding a script to the quest would manage this. The bare bones of the script... Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)if !akSourceContainerDebug.Notification("I picked up something")EndIfEndEvent I put this script in the scripts of the quest. My original question was how do I make the quest address this script? Is the script already running because the quest is running? I don't see the message. Do I need a papyrus fragment to run the script? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted June 28, 2021 Share Posted June 28, 2021 Technically the script is already available to run because the quest is running. However, quests do not receive the OnItemAdded event. ObjectReferences receive the OnItemAdded event. You can create an alias on the quest that points to the player and apply the script there instead. I would create a custom formlist that contains all the equip able light sources that you want to provide this warning with. Then create a player alias on a quest and add a script that would be similar to the following. Of course I might use different names and such as this is only an example: Scriptname PlayerAliasLightWarningScript Extends ReferenceAlias Formlist Property myListOfLights Auto String Property myWarning Auto Bool doOnce = false Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If myListOfLights.HasForm(akBaseItem) && doOnce == false doOnce = true Debug.MessageBox(myWarning) EndIf EndEventStates could alternatively be used instead of a bool and may be preferable in the long run depending upon how many mods might add the OnItemAdded event. Even though it does nothing after the initial run, it will contribute to potential stack dumps since each item passed in to the player will trigger the event. Scriptname PlayerAliasLightWarningScript Extends ReferenceAlias Formlist Property myListOfLights Auto String Property myWarning Auto Auto State Waiting Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If myListOfLights.HasForm(akBaseItem) Debug.MessageBox(myWarning) GoToState("Completed") EndIf EndEvent EndState State Completed Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) EndEvent EndState In both examples, if the item picked up is on the list of lights the message is displayed and then the script is told to no longer display that message even if other valid lights are picked up. Link to comment Share on other sites More sharing options...
antstubell Posted June 29, 2021 Author Share Posted June 29, 2021 :thumbsup: Link to comment Share on other sites More sharing options...
Recommended Posts