Difference between revisions of "Scripting Tutorial: Updating your leveled items"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>ZuTheSkunk
(New page: You probably know about level scalling used in entire game. And you probably know about common problem which comes with leveled rewards from quests - once you receive one particular versio...)
 
imported>ZuTheSkunk
m
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
You probably know about level scalling used in entire game. And you probably know about common problem which comes with leveled rewards from quests - once you receive one particular version of the item, including low-leveled ones, then it remains the same forever, what can be quite annoying when your character reaches 30-th level or higher and you still possess that stupid 10-th level version of the sword. If you wish to make level scalling less annoying - no matter for what purpose you might need it, for your own pleasure, or maybe also for other users of your mod - then you should consider creating a script which updates specific leveled items every time your character reaches enough high level. And this is what I am going to show in this tutorial.
You probably know about the level scaling used in the entire game. And you probably know about the common problem regarding the leveled rewards from quests - once you receive one particular version of the item, including low-leveled ones, then it remains the same forever. That can be quite annoying when your character reaches 30-th level or higher and you still have that stupid 10-th level version of the sword.
 
If you wish to make the level scaling less annoying - regardless of whether it's just for your own use or for a mod that others can download - then you should consider creating a script that updates specific leveled items every time your character reaches high enough level. And this is what I am going to show you in this tutorial.


{{Tools|req0=[[The Elder Scrolls Construction Set|Construction Set]]}}
{{Tools|req0=[[The Elder Scrolls Construction Set|Construction Set]]}}
Line 21: Line 23:
== Tutorial ==
== Tutorial ==


The idea of the script itself is simple - it runs all the time, checking if you are possessing a specified item with too high level, and if yes, then replaces it with better version. For example, if you type to check does you are possessing a steel longsword while having level 16 or higher, the script will notify if those two conditions are true and will perform the desired result. For the purpose of this tutorial, I have created a custom script of updating the Blackwater Blade from quest "Unexpected Voyage". You can take a look on him at the bottom of this article and see for your own.
The idea of the script itself is simple - it runs all the time, checking if you are in possession of a specified item while your level is too high, and if you do, then it will replace it with a better version.
 
For example, let's say that your script checks two conditions: whether a steel longsword lies in your inventory, and whether your level is 16 or higher. If both of these conditions are true, then it will perform the desired result.
 
For the purpose of this tutorial, I have created a custom script that updates the Blackwater Blade from the quest "Unexpected Voyage". You can take a look at the finished script at the bottom of this article.


* Start Construction Set as usual. Checking Oblivion.esm as master file is required.
Okay, let's get started!


* Open [[Edit Scripts|Script Window]] and use the File Menu (those buttons at the top) to create a new one.
Start the Construction Set as usual. Open the [[Edit Scripts|Script Window]] and use the File Menu (those buttons at the top) to create a new script.


* First of all, you need to type name of the script:
First of all, you need to type the name of your new script:
<pre> scn <Name of your script> </pre>
<pre> scn <Name of your script> </pre>


* Okay, we have the most basic part of the script. For the purpose of what we are going to achieve, we need to check the player's level. We need to type this:
Also, since we want to make the script run all the time, we need to type this:
<pre> Begin GameMode </pre>
 
Okay, so we have the most basic part of the script. For the purposes of what we are going to achieve, we need to check the player's level. We need to type this:
<pre>
<pre>
if ( LVL != player.getlevel )
if ( LVL != player.getlevel )
Line 37: Line 46:
</pre>
</pre>


This part will run whenever the "LVL" variable is not equal to the player's level, what means you have reached another level. It is not essential for your script and I am using it to simplify the progress, so you will not need to type every time "player.getlevel", but just "LVL". With this part, our script will look this way so far:
This part will run whenever the "LVL" [[variable]] is not equal to the player's level, which means that you have reached another level. This part is not essential to your script and I am only using it to simplify the progress, so that you don't have to type "player.getlevel" every single time, but instead just "LVL".
 
If we are going to include this, then we have to include also this:
<pre>
short LVL
</pre>
 
The above creates a variable named "LVL" for this specific script.
 
With all these parts included, this is how our script should look so far:
<pre>
<pre>
scn <Name of your script>
scn <Name of your script>
Line 50: Line 68:
</pre>
</pre>


* Now it is a time to create first part of script which checks does the player is possessing a specified item with too high level. Since it has been reported that riding a horse when such script runs might create problems, we will add the condition which blocks the script while player is on the horse. Also, to prevent situations when player is currently holding the item in his hand or wearing it and the script suddenly unequips the item from him, we will add the condition which checks does the player is currently using the specified item. So, we need to type this:
Now it's time to create our first check. Remember these two conditions I mentioned earlier? That's what this part is going to be about.
 
Since it has been reported that riding a horse when such script runs might create problems, we will add a condition that blocks the script while player is riding a horse. Also, to prevent situations when the player is currently wearing the item and the script suddenly unequips it, we will add a condition that checks whether the player currently uses the specified item.
 
Here's how it looks:
<pre>
<pre>
if ( player.IsRidingHorse == 0 )
if ( player.IsRidingHorse == 0 )
if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= NumberOfLevelWhenPlayerShouldn'tHaveThisItem )
if ( player.getitemcount ID_Of_The_Item > 0 && LVL >= LevelValue )
if ( player.getequipped IDofLowLevelItem == 1 )
if ( player.getequipped ID_Of_The_Item == 1 )
</pre>
</pre>


Obviously, in "IDofLowLevelItem" we need to type the ID name of item that should be replaced with better version, and in "NumberOfLevelWhenPlayerShouldn'tHaveThisItem" we need to type the number of minimum level, when this item becomes too low-level for player and must be replaced with better one.
Obviously, in "ID_Of_The_Item" we need to type in the ID name of the item that should be replaced with a better version. In "LevelValue" we need to type in the minimum level when this item becomes too low-level for the player and must be replaced with a better version.


* Okay, so we have our first conditions in our script. Now we need to type the lines which takes the low-level item away from player and gives the better version instead. The most simple version may look this way:
Okay, so we have our first conditions in our script. Now we need to make sure that the low-level item will be taken away from the player and replaced with a better version. It's highly recommended to make a leveled list and have it contain all of the item's versions; the following script is written with this in mind.
 
The simplest version should look like this:
<pre>
<pre>
if ( player.IsRidingHorse == 0 )
if ( player.IsRidingHorse == 0 )
if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= NumberOfLevelWhenPlayerShouldn'tHaveThisItem )
if ( player.getitemcount ID_Of_The_Item > 0 && LVL >= LevelValue )
if ( player.getequipped IDofLowLevelItem == 1 )
if ( player.getequipped ID_Of_The_Item == 1 )
player.unequipitem IDofLowLevelItem
player.unequipitem ID_Of_The_Item
player.removeitem IDofLowLevelItem 1
player.removeitem ID_Of_The_Item 1
player.additem IDofBetterItemOrLeveledList 1
player.additem ID_Of_The_Leveled_List 1
player.equipitem IDofBetterItem
player.equipitem ID_Of_The_Better_Item
else
else
player.removeitem IDofLowLevelItem 1
player.removeitem ID_Of_The_Item 1
player.additem IDofBetterItemOrLeveledList 1
player.additem ID_Of_The_Leveled_List 1
endif
endif
</pre>
</pre>
This part of the script does the following: if the player is wearing the item, then it will first unequip it and only then take it away, followed by the new item from the leveled list being added and subsequently equipped. If the player doesn't have it equipped, then it will merely remove the old version and add the better one from the leveled list.


As you may guess, "IDofBetterItemOrLeveledList" means ID name of specific better item if there is only one such item, or of the leveled list if there are many of those better versions. "IDofBetterItem" means ONLY a specific better item.
Remember that if you have a leveled list with many different versions of the item, then you need to type in every single one of them for the part where the script must equip it on the player - it will not guess which one should be equipped, and if the player is not currently in possession of the version affected by the "equipitem" function, then the player will end up with an unequipped item.


This part of script does following: first, it unequips the item and takes him away, then it adds the better item or the leveled list to the player, and finally it equips this better item on the player (assuming that he is actually using it, otherwise it will just remove the low-level version and add the better one). You must remember that if there are many of those better versions, then you need to type every single one for the part when script must equip it on the player - it will not guess which one should be equipped, and if player is not currently possessing the version typed for "equipitem" function, then player will just remain with not held/worn item.
There is another thing you must know: in its current state, the script will notify the player about the replacements with "XXX removed" and "XXX added" messages. There are two ways to remove them; you can learn about them from the [[Message Spam]] article.


That was the most simple version. For this one, it will just do what it should and you will be notified with this by "XXX removed" and "XXX added" messages. If you would like to remove them, there are two ways to perform that, and you can learn about both of them by checking [[Message Spam]] article.
Okay, let's take a look at what we got so far:
 
* Okay, it is time to check what we have made so far:
<pre>
<pre>
scn <Name of your script>
scn <Name of your script>
Line 93: Line 116:


if ( player.IsRidingHorse == 0 )
if ( player.IsRidingHorse == 0 )
if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= NumberOfLevelWhenPlayerShouldn'tHaveThisItem )
if ( player.getitemcount ID_Of_The_Item > 0 && LVL >= LevelValue )
if ( player.getequipped IDofLowLevelItem == 1 )
if ( player.getequipped ID_Of_The_Item == 1 )
player.unequipitem IDofLowLevelItem
player.unequipitem ID_Of_The_Item
player.removeitem IDofLowLevelItem 1
player.removeitem ID_Of_The_Item 1
player.additem IDofBetterItemOrLeveledList 1
player.additem ID_Of_The_Leveled_List 1
player.equipitem IDofBetterItem
player.equipitem ID_Of_The_Better_Item
else
else
player.removeitem IDofLowLevelItem 1
player.removeitem ID_Of_The_Item 1
player.additem IDofBetterItemOrLeveledList 1
player.additem ID_Of_The_Leveled_List 1
endif
endif
endif
endif
</pre>
</pre>


* Now if you wish to add more versions to replace, then just copy/paste the part after "if ( player.IsRidingHorse == 0 )", and do not forget about replacing "if" with "elseif".
Now, if you want to include more old versions to be replaced with better ones, then just copy/paste the part after "if ( player.IsRidingHorse == 0 )" and change the values and IDs appropriately. Don't forget to replace the first "if" with "elseif".


* To complete the script, finish it with enough "endif" and one "END":
To complete the script, finish it by typing "endif" enough times and then just one "END":
<pre>
<pre>
scn <Name of your script>
scn <Name of your script>
Line 121: Line 144:


if ( player.IsRidingHorse == 0 )
if ( player.IsRidingHorse == 0 )
if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= NumberOfLevelWhenPlayerShouldn'tHaveThisItem )
if ( player.getitemcount ID_Of_The_Item > 0 && LVL >= LevelValue )
if ( player.getequipped IDofLowLevelItem == 1 )
if ( player.getequipped ID_Of_The_Item == 1 )
player.unequipitem IDofLowLevelItem
player.unequipitem ID_Of_The_Item
player.removeitem IDofLowLevelItem 1
player.removeitem ID_Of_The_Item 1
player.additem IDofBetterItemOrLeveledList 1
player.additem ID_Of_The_Leveled_List 1
player.equipitem IDofBetterItem
player.equipitem ID_Of_The_Better_Item
else
else
player.removeitem IDofLowLevelItem 1
player.removeitem ID_Of_The_Item 1
player.additem IDofBetterItemOrLeveledList 1
player.additem ID_Of_The_Leveled_List 1
endif
endif
endif
elseif ( player.getitemcount ID_Of_Another_Item > 0 && LVL >= LevelValue )
elseif ( player.getitemcount IDofAnotherLowLevelItem > 0 && LVL >= NumberOfLevelWhenPlayerShouldn'tHaveThisItem )
(...)
(...)
endif
endif
Line 140: Line 162:
</pre>
</pre>


And at this point, your script should be correct.
And at this point, your script should be correct (don't forget to save!). There is only one thing to do - you must add it to a quest in order to make it work. This "quest" will not appear in the player's journal and will simply work silently in the background.


* There is only one thing to do - you must add it to the quest in order to make it working. Set type of your script as "Quest" at the File Menu.
* Set the type of your script as "Quest" in the File Menu.


* Open the [[Quest|Quest Menu]] by button with "Q".
* Open the [[Quest|Quest Menu]] by clicking the "Q" button at the top.


* Add new quest by clicking RMB on the list and checking "New".
* Add a new quest by right-clicking on the list and choosing "New".


* Click this quest and in "Script" part choose your script from the list.
* Select the new quest, and under "Script" choose your script from the list.


* You did it! Now save your mod and you are free to go.  
* You did it! Now save your mod and you are free to go.  


There is one more feature to add, if you wish. Such updating script can be a bit problematic for the game and can make it working slower if there are many such scripts working in the background. To avoid such problem, you should do following:
There is one more feature that can be added, if you want. Your script can be a bit problematic for the game and can make it run slower if there are many such scripts working in the background. To avoid such a problem, you should do the following:
 
* Add "short NotPerform" below "short LVL"
 
* Add "set NotPerform to 0" below "set LVL to player.getlevel"


* Add also "short NotPerform" below "short LVL", add "set NotPerform to 0" below "set LVL to player.getlevel", add "&& NotPerform == 0" next to "if ( player.IsRidingHorse" and at the end of the script, after last replaced item, add instead of next one:
* Add "&& NotPerform == 0" after "if ( player.IsRidingHorse"
 
* At the end of the script, after the last replaced item, add instead of another "elseif":
<pre>
<pre>
else
else
Line 160: Line 188:
</pre>
</pre>


In this case, your script will look this way:
In this case, your script should look like this:
<pre>
<pre>
scn <Name of your script>
scn <Name of your script>
Line 175: Line 203:


if ( player.IsRidingHorse == 0 && NotPerform == 0 )
if ( player.IsRidingHorse == 0 && NotPerform == 0 )
if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= NumberOfLevelWhenPlayerShouldn'tHaveThisItem )
if ( player.getitemcount ID_Of_The_Item > 0 && LVL >= LevelValue )
if ( player.getequipped IDofLowLevelItem == 1 )
if ( player.getequipped ID_Of_The_Item == 1 )
player.unequipitem IDofLowLevelItem
player.unequipitem ID_Of_The_Item
player.removeitem IDofLowLevelItem 1
player.removeitem ID_Of_The_Item 1
player.additem IDofBetterItemOrLeveledList 1
player.additem ID_Of_The_Leveled_List 1
player.equipitem IDofBetterItem
player.equipitem ID_Of_The_Better_Item
else
else
player.removeitem IDofLowLevelItem 1
player.removeitem ID_Of_The_Item 1
player.additem IDofBetterItemOrLeveledList 1
player.additem ID_Of_The_Leveled_List 1
endif
endif
endif
elseif ( player.getitemcount ID_Of_Another_Item > 0 && LVL >= LevelValue )
elseif ( player.getitemcount IDofAnotherLowLevelItem > 0 && LVL >= NumberOfLevelWhenPlayerShouldn'tHaveThisItem )
(...)
(...)
else
else
Line 196: Line 223:
</pre>
</pre>


Remember that in this version, this script will replace your item ONLY if you are currently possessing it while gaining a new level, because we have forced the script to block itself after completing his task and to not run again unless you have reached another level.
Remember that in this case, this script will replace your item ONLY if it's in your possession while you're gaining a new level - this is because we have forced the script to block itself after completing its task and to not run again until you reach another level.


* To avoid this, you should also add this script to the '''item''':
To avoid this, you should also add this script to the '''item itself''':
<pre>
<pre>
scn <Name of your another script>
scn <Name of the script>


Begin OnAdd Player
Begin OnAdd Player


set IDofTheQuest.NotPerform to 0
set ID_Of_The_Quest.NotPerform to 0
End
End
</pre>
</pre>


"IDofTheQuest" is a ID name of the quest you have just created. This script will cause game to make quest script running whenever you add the item to your inventory.
"ID_Of_The_Quest" is the ID name of the quest you have just created. This item script will force the quest script to run whenever you add the item to your inventory.
 
If the item already has a script, then you will have to simply add the contents of the above script to the existing one. (Do not copy "scn <Name of the script>", since the original script already has it.) Note that this is not always a viable option, since only one mod can modify an item's script.
 
And this is all. Below you will find my example of a complete script, to be absolutely sure that you understood everything correctly.
== Example of a completed script ==


And this is all. Below you will find my example of complete script, to be absolutely sure that you have understood everything correctly.
<pre>
<pre>
scn aaaTestScriptUpdater
scn aaaTestScriptUpdater
Line 364: Line 395:
  Items
  Items
  Level
  Level
  Scalling
  Scaling
  Tutorial
  Tutorial
End Search Terms -->
End Search Terms -->

Latest revision as of 12:59, 21 November 2014

You probably know about the level scaling used in the entire game. And you probably know about the common problem regarding the leveled rewards from quests - once you receive one particular version of the item, including low-leveled ones, then it remains the same forever. That can be quite annoying when your character reaches 30-th level or higher and you still have that stupid 10-th level version of the sword.

If you wish to make the level scaling less annoying - regardless of whether it's just for your own use or for a mod that others can download - then you should consider creating a script that updates specific leveled items every time your character reaches high enough level. And this is what I am going to show you in this tutorial.


Tools used in this tutorial

Required


Requirements[edit | edit source]

Basic knowledge of:

Commands and Functions used[edit | edit source]

Tutorial[edit | edit source]

The idea of the script itself is simple - it runs all the time, checking if you are in possession of a specified item while your level is too high, and if you do, then it will replace it with a better version.

For example, let's say that your script checks two conditions: whether a steel longsword lies in your inventory, and whether your level is 16 or higher. If both of these conditions are true, then it will perform the desired result.

For the purpose of this tutorial, I have created a custom script that updates the Blackwater Blade from the quest "Unexpected Voyage". You can take a look at the finished script at the bottom of this article.

Okay, let's get started!

Start the Construction Set as usual. Open the Script Window and use the File Menu (those buttons at the top) to create a new script.

First of all, you need to type the name of your new script:

 scn <Name of your script> 

Also, since we want to make the script run all the time, we need to type this:

 Begin GameMode 

Okay, so we have the most basic part of the script. For the purposes of what we are going to achieve, we need to check the player's level. We need to type this:

	if ( LVL != player.getlevel )
		set LVL to player.getlevel
	endif

This part will run whenever the "LVL" variable is not equal to the player's level, which means that you have reached another level. This part is not essential to your script and I am only using it to simplify the progress, so that you don't have to type "player.getlevel" every single time, but instead just "LVL".

If we are going to include this, then we have to include also this:

short LVL

The above creates a variable named "LVL" for this specific script.

With all these parts included, this is how our script should look so far:

scn <Name of your script>

short LVL

Begin GameMode

	if ( LVL != player.getlevel )
		set LVL to player.getlevel
	endif

Now it's time to create our first check. Remember these two conditions I mentioned earlier? That's what this part is going to be about.

Since it has been reported that riding a horse when such script runs might create problems, we will add a condition that blocks the script while player is riding a horse. Also, to prevent situations when the player is currently wearing the item and the script suddenly unequips it, we will add a condition that checks whether the player currently uses the specified item.

Here's how it looks:

	if ( player.IsRidingHorse == 0 )
		if ( player.getitemcount ID_Of_The_Item > 0 && LVL >= LevelValue )
			if ( player.getequipped ID_Of_The_Item == 1 )

Obviously, in "ID_Of_The_Item" we need to type in the ID name of the item that should be replaced with a better version. In "LevelValue" we need to type in the minimum level when this item becomes too low-level for the player and must be replaced with a better version.

Okay, so we have our first conditions in our script. Now we need to make sure that the low-level item will be taken away from the player and replaced with a better version. It's highly recommended to make a leveled list and have it contain all of the item's versions; the following script is written with this in mind.

The simplest version should look like this:

	if ( player.IsRidingHorse == 0 )
		if ( player.getitemcount ID_Of_The_Item > 0 && LVL >= LevelValue )
			if ( player.getequipped ID_Of_The_Item == 1 )
				player.unequipitem ID_Of_The_Item
				player.removeitem ID_Of_The_Item 1
				player.additem ID_Of_The_Leveled_List 1
				player.equipitem ID_Of_The_Better_Item
			else
				player.removeitem ID_Of_The_Item 1
				player.additem ID_Of_The_Leveled_List 1
			endif

This part of the script does the following: if the player is wearing the item, then it will first unequip it and only then take it away, followed by the new item from the leveled list being added and subsequently equipped. If the player doesn't have it equipped, then it will merely remove the old version and add the better one from the leveled list.

Remember that if you have a leveled list with many different versions of the item, then you need to type in every single one of them for the part where the script must equip it on the player - it will not guess which one should be equipped, and if the player is not currently in possession of the version affected by the "equipitem" function, then the player will end up with an unequipped item.

There is another thing you must know: in its current state, the script will notify the player about the replacements with "XXX removed" and "XXX added" messages. There are two ways to remove them; you can learn about them from the Message Spam article.

Okay, let's take a look at what we got so far:

scn <Name of your script>

short LVL

Begin GameMode

	if ( LVL != player.getlevel )
		set LVL to player.getlevel
	endif

	if ( player.IsRidingHorse == 0 )
		if ( player.getitemcount ID_Of_The_Item > 0 && LVL >= LevelValue )
			if ( player.getequipped ID_Of_The_Item == 1 )
				player.unequipitem ID_Of_The_Item
				player.removeitem ID_Of_The_Item 1
				player.additem ID_Of_The_Leveled_List 1
				player.equipitem ID_Of_The_Better_Item
			else
				player.removeitem ID_Of_The_Item 1
				player.additem ID_Of_The_Leveled_List 1
			endif
		endif

Now, if you want to include more old versions to be replaced with better ones, then just copy/paste the part after "if ( player.IsRidingHorse == 0 )" and change the values and IDs appropriately. Don't forget to replace the first "if" with "elseif".

To complete the script, finish it by typing "endif" enough times and then just one "END":

scn <Name of your script>

short LVL

Begin GameMode

	if ( LVL != player.getlevel )
		set LVL to player.getlevel
	endif

	if ( player.IsRidingHorse == 0 )
		if ( player.getitemcount ID_Of_The_Item > 0 && LVL >= LevelValue )
			if ( player.getequipped ID_Of_The_Item == 1 )
				player.unequipitem ID_Of_The_Item
				player.removeitem ID_Of_The_Item 1
				player.additem ID_Of_The_Leveled_List 1
				player.equipitem ID_Of_The_Better_Item
			else
				player.removeitem ID_Of_The_Item 1
				player.additem ID_Of_The_Leveled_List 1
			endif
		elseif ( player.getitemcount ID_Of_Another_Item > 0 && LVL >= LevelValue )
		(...)
		endif
	endif

End

And at this point, your script should be correct (don't forget to save!). There is only one thing to do - you must add it to a quest in order to make it work. This "quest" will not appear in the player's journal and will simply work silently in the background.

  • Set the type of your script as "Quest" in the File Menu.
  • Open the Quest Menu by clicking the "Q" button at the top.
  • Add a new quest by right-clicking on the list and choosing "New".
  • Select the new quest, and under "Script" choose your script from the list.
  • You did it! Now save your mod and you are free to go.

There is one more feature that can be added, if you want. Your script can be a bit problematic for the game and can make it run slower if there are many such scripts working in the background. To avoid such a problem, you should do the following:

  • Add "short NotPerform" below "short LVL"
  • Add "set NotPerform to 0" below "set LVL to player.getlevel"
  • Add "&& NotPerform == 0" after "if ( player.IsRidingHorse"
  • At the end of the script, after the last replaced item, add instead of another "elseif":
	else
		set NotPerform to 1

In this case, your script should look like this:

scn <Name of your script>

short LVL
short NotPerform

Begin GameMode

	if ( LVL != player.getlevel )
		set LVL to player.getlevel
		set NotPerform to 0
	endif

	if ( player.IsRidingHorse == 0 && NotPerform == 0 )
		if ( player.getitemcount ID_Of_The_Item > 0 && LVL >= LevelValue )
			if ( player.getequipped ID_Of_The_Item == 1 )
				player.unequipitem ID_Of_The_Item
				player.removeitem ID_Of_The_Item 1
				player.additem ID_Of_The_Leveled_List 1
				player.equipitem ID_Of_The_Better_Item
			else
				player.removeitem ID_Of_The_Item 1
				player.additem ID_Of_The_Leveled_List 1
			endif
		elseif ( player.getitemcount ID_Of_Another_Item > 0 && LVL >= LevelValue )
		(...)
		else
			set NotPerform to 1
		endif
	endif

End

Remember that in this case, this script will replace your item ONLY if it's in your possession while you're gaining a new level - this is because we have forced the script to block itself after completing its task and to not run again until you reach another level.

To avoid this, you should also add this script to the item itself:

scn <Name of the script>

Begin OnAdd Player

	set ID_Of_The_Quest.NotPerform to 0
	
End

"ID_Of_The_Quest" is the ID name of the quest you have just created. This item script will force the quest script to run whenever you add the item to your inventory.

If the item already has a script, then you will have to simply add the contents of the above script to the existing one. (Do not copy "scn <Name of the script>", since the original script already has it.) Note that this is not always a viable option, since only one mod can modify an item's script.

And this is all. Below you will find my example of a complete script, to be absolutely sure that you understood everything correctly.

Example of a completed script[edit | edit source]

scn aaaTestScriptUpdater

short LVL
short NotPerform

Begin GameMode

	if ( LVL != player.getlevel )
		set LVL to player.getlevel
		set NotPerform to 0
	endif

	if ( player.IsRidingHorse == 0 && NotPerform == 0 )
		if ( player.getitemcount MS31BlackwaterBlade01 > 0 && LVL >= 5 )
			if ( player.getequipped MS31BlackwaterBlade01 == 1 )
				message " "
				message " "
				player.unequipitem MS31BlackwaterBlade01
				message " "
				message " "
				player.removeitem MS31BlackwaterBlade01 1
				message " "
				message " "
				player.additem MS31RewardBlackwaterBladeLeveled 1
				message " "
				message " "
				player.equipitem MS31BlackwaterBlade05
				player.equipitem MS31BlackwaterBlade10
				player.equipitem MS31BlackwaterBlade15
				player.equipitem MS31BlackwaterBlade20
				player.equipitem MS31BlackwaterBlade25
			else
				message " "
				message " "
				player.removeitem MS31BlackwaterBlade01 1
				message " "
				message " "
				player.additem MS31RewardBlackwaterBladeLeveled 1
			endif
		elseif ( player.getitemcount MS31BlackwaterBlade05 > 0 && LVL >= 10 )
			if ( player.getequipped MS31BlackwaterBlade05 == 1 )
				message " "
				message " "
				player.unequipitem MS31BlackwaterBlade05
				message " "
				message " "
				player.removeitem MS31BlackwaterBlade05 1
				message " "
				message " "
				player.additem MS31RewardBlackwaterBladeLeveled 1
				message " "
				message " "
				player.equipitem MS31BlackwaterBlade10
				player.equipitem MS31BlackwaterBlade15
				player.equipitem MS31BlackwaterBlade20
				player.equipitem MS31BlackwaterBlade25
			else
				message " "
				message " "
				player.removeitem MS31BlackwaterBlade05 1
				message " "
				message " "
				player.additem MS31RewardBlackwaterBladeLeveled 1
			endif
		elseif ( player.getitemcount MS31BlackwaterBlade10 > 0 && LVL >= 15 )
			if ( player.getequipped MS31BlackwaterBlade10 == 1 )
				message " "
				message " "
				player.unequipitem MS31BlackwaterBlade10
				message " "
				message " "
				player.removeitem MS31BlackwaterBlade10 1
				message " "
				message " "
				player.additem MS31RewardBlackwaterBladeLeveled 1
				message " "
				message " "
				player.equipitem MS31BlackwaterBlade15
				player.equipitem MS31BlackwaterBlade20
				player.equipitem MS31BlackwaterBlade25
			else
				message " "
				message " "
				player.removeitem MS31BlackwaterBlade10 1
				message " "
				message " "
				player.additem MS31RewardBlackwaterBladeLeveled 1
			endif
		elseif ( player.getitemcount MS31BlackwaterBlade15 > 0 && LVL >= 20 )
			if ( player.getequipped MS31BlackwaterBlade15 == 1 )
				message " "
				message " "
				player.unequipitem MS31BlackwaterBlade15
				message " "
				message " "
				player.removeitem MS31BlackwaterBlade15 1
				message " "
				message " "
				player.additem MS31RewardBlackwaterBladeLeveled 1
				message " "
				message " "
				player.equipitem MS31BlackwaterBlade20
				player.equipitem MS31BlackwaterBlade25
			else
				message " "
				message " "
				player.removeitem MS31BlackwaterBlade15 1
				message " "
				message " "
				player.additem MS31RewardBlackwaterBladeLeveled 1
			endif
		elseif ( player.getitemcount MS31BlackwaterBlade20 > 0 && LVL >= 25 )
			if ( player.getequipped MS31BlackwaterBlade20 == 1 )
				message " "
				message " "
				player.unequipitem MS31BlackwaterBlade20
				message " "
				message " "
				player.removeitem MS31BlackwaterBlade20 1
				message " "
				message " "
				player.additem MS31BlackwaterBlade25 1
				message " "
				message " "
				player.equipitem MS31BlackwaterBlade25
			else
				message " "
				message " "
				player.removeitem MS31BlackwaterBlade20 1
				message " "
				message " "
				player.additem MS31BlackwaterBlade25 1
			endif
		else
			set NotPerform to 1
		endif
	endif
	
End