This tutorial will go over how you can make a triggerbox turn into an activator like a lever. It will be invisible, and allows you to, say - place an invisible trigger over the well static in Whiterun square. Then, you could make the well "activatable" without making the well itself an activator.
Base Scripts
To begin with, here is the base script that you will place on your trigger:
Scriptname ActivatorScript extends ObjectReference
Event OnActivate(ObjectReference akActionRef)
;code here
EndEvent
And the base scripts with a time frame:
Scriptname ActivatorScript Extends ObjectReference
Auto State Ready
Event OnActivate(ObjectReference akActionRef)
GoToState("Waiting")
;code here
EndEvent
EndState
State Waiting
Event OnBeginState()
RegisterForSingleUpdateGameTime(floatTimeHere);replace floatTimeHere with the value for the amount of time before the activator is reset
EndEvent
Event OnUpdateGameTime()
GoToState("Ready")
EndEvent
EndState
Setting Up Your Trigger
Now, in order to have the trigger activate properly, you need to do some set up for it.
First, you'll need to create your trigger volume. Once you've done that, resize it so it is scaled the way you want it to and is placed where you want the player to activate it.
Then, double click your trigger volume. You should see this window:
First, you'll need to create your trigger volume. Once you've done that, resize it so it is scaled the way you want it to and is placed where you want the player to activate it.
Then, double click your trigger volume. You should see this window:
For your triggerbox activator to work, you MUST make sure that the rotation of any OR all of the axes is larger than 0. One of them could be 0.0000000001 but it must be larger than 0 or it won't work.
Click Edit Base, right next to the "Base Objec t" bar. This will open up a new window. Only concern yourself with three things:
Name: This is the name of your activator, NOT the ID of your form. You should, most likely, name this what you want your activator to say. When the player's cursor hovers over your trigger, they will see "Activate Name", so make sure it fits.
Activate Text Override: If you'd prefer it not to say "Activate Name", you should use Activate Text Override. Whatever you type into this box (nothing defaults to Activate) will replace that Activate text. Putting in "Urglestahfs" wouild mean that, when hovering over your trigger in-game, it would say "Urglestahfs Name".
Is Marker: This is a checkbox underneath "Add Destruction Data". This must be unchecked. If this is checked, the activator will not work. It tells the engine there is no model to render, when checked. Even if there is no model, you cannot have this checked or you will be unable to activate your trigger. I do not know exactly why this is, but a marker probably would not be activatable, which is probably why.
Once you've ensured these are all correct, go back to the "Reference" window seen in the previous step. (Press OK to save the info in the Activator window. If the Reference window is gone, just double click your trigger in the cell view to open it again.) There is one essential step here. Go to the Primitive tab, and check the Player Activation box.
Click Edit Base, right next to the "Base Objec t" bar. This will open up a new window. Only concern yourself with three things:
Name: This is the name of your activator, NOT the ID of your form. You should, most likely, name this what you want your activator to say. When the player's cursor hovers over your trigger, they will see "Activate Name", so make sure it fits.
Activate Text Override: If you'd prefer it not to say "Activate Name", you should use Activate Text Override. Whatever you type into this box (nothing defaults to Activate) will replace that Activate text. Putting in "Urglestahfs" wouild mean that, when hovering over your trigger in-game, it would say "Urglestahfs Name".
Is Marker: This is a checkbox underneath "Add Destruction Data". This must be unchecked. If this is checked, the activator will not work. It tells the engine there is no model to render, when checked. Even if there is no model, you cannot have this checked or you will be unable to activate your trigger. I do not know exactly why this is, but a marker probably would not be activatable, which is probably why.
Once you've ensured these are all correct, go back to the "Reference" window seen in the previous step. (Press OK to save the info in the Activator window. If the Reference window is gone, just double click your trigger in the cell view to open it again.) There is one essential step here. Go to the Primitive tab, and check the Player Activation box.
This allows the player to actually activate your trigger. If you went in game now, you should be able to activate your trigger. However, nothing will actually happen, as we've not set up a script for your trigger.
Creating Your Activate Script
So, we'll do that now. Make sure your mod is saved - you wouldn't want to go back and do all of that again, would you?
Now, you can add the script in one of two places. You can go back to the Activator window (which you get to by pressing Edit Base), or you can add a script directly in the Reference window (by pressing the right arrow button in the Reference window until you see the Scripts tab, and clicking there).
If you add it on the Base Object, every single reference of your trigger will have this script. Adding it on the Reference means only that specific activator/trigger will have that script. So, you could have the same trigger doing different things on every object. Or, you could have a single activator with one script that you could continually reuse without needing to edit the script each time. Which method to use really depends on how you'll be using the trigger.
Whichever way you choose, find the button "Add" in the respective tab/window.
Now, you can add the script in one of two places. You can go back to the Activator window (which you get to by pressing Edit Base), or you can add a script directly in the Reference window (by pressing the right arrow button in the Reference window until you see the Scripts tab, and clicking there).
If you add it on the Base Object, every single reference of your trigger will have this script. Adding it on the Reference means only that specific activator/trigger will have that script. So, you could have the same trigger doing different things on every object. Or, you could have a single activator with one script that you could continually reuse without needing to edit the script each time. Which method to use really depends on how you'll be using the trigger.
Whichever way you choose, find the button "Add" in the respective tab/window.
In the window that pops up, select NEW to create your new script. Give it a script name and keep the type as ObjectReference. Press OK to generate the script. Once you've made your script, edit it by right clicking the script entry and selecting Open in External Editor or just Edit Source if you have no script editor.
We'll be using this base script:
We'll be using this base script:
Scriptname akWellActivatorScript extends ObjectReference
Event OnActivate(ObjectReference akActionRef)
;code here
EndEvent
As you can see, it is very, very simple. We've turned the trigger box into a full activator. Usually, trigger boxes are activated by someone entering them. However, because we've allowed for Player Activation, they no longer work that way. They have become invisible, manual activators - like an altar, or a door. Therefore, we will be using OnActivate rather than OnTriggerEnter. So we have our event set up, and then we have a little area for code.
Any sort of code can be put into that ";code here" area. You could add some water to the activator's inventory (wells, anyone?), kill some random people, spawn a dragon, activate an animation, open a door, or just set a variable. Just choose the proper function.
Whatever you want. Once you've placed that activator script there, fill the properties on your script. It should now work if you go in-game.
If you want an activator that will only do your action of code depending on when you last activated it, check out the script at the top of this tutorial. Just use that instead of the simpler base script.
Please tell me if this tutorial was useful for you. Thanks. ;)
Any sort of code can be put into that ";code here" area. You could add some water to the activator's inventory (wells, anyone?), kill some random people, spawn a dragon, activate an animation, open a door, or just set a variable. Just choose the proper function.
Whatever you want. Once you've placed that activator script there, fill the properties on your script. It should now work if you go in-game.
If you want an activator that will only do your action of code depending on when you last activated it, check out the script at the top of this tutorial. Just use that instead of the simpler base script.
Please tell me if this tutorial was useful for you. Thanks. ;)