Difference between revisions of "Scripting Tutorial: Updating your leveled items"
Scripting Tutorial: Updating your leveled items (edit)
Revision as of 10:27, 19 November 2010
, 10:27, 19 November 2010Few additional corrections
imported>ZuTheSkunk m (Additional minor fixes.) |
imported>ZuTheSkunk m (Few additional corrections) |
||
Line 29: | Line 29: | ||
* First of all, you need to type name of the script: | * First of all, you need to type name of the script: | ||
<pre> scn <Name of your script> </pre> | <pre> scn <Name of your script> </pre> | ||
* Also, since we want to make the script running all the time, we need to type this: | |||
<pre> Begin GameMode </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: | * 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: | ||
Line 37: | Line 40: | ||
</pre> | </pre> | ||
This part will run whenever the "LVL" [[variable]] is not equal to the player's level, | This part will run whenever the "LVL" [[variable]] is not equal to the player's level, meaning that 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 "player.getlevel" every time, but just "LVL" instead. With this part, our script will look this way so far: | ||
<pre> | <pre> | ||
scn <Name of your script> | scn <Name of your script> | ||
Line 53: | Line 56: | ||
<pre> | <pre> | ||
if ( player.IsRidingHorse == 0 ) | if ( player.IsRidingHorse == 0 ) | ||
if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= | if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= MinLevelForReplacing ) | ||
if ( player.getequipped IDofLowLevelItem == 1 ) | if ( player.getequipped IDofLowLevelItem == 1 ) | ||
</pre> | </pre> | ||
Obviously, in "IDofLowLevelItem" we need to type the ID name of item that should be replaced with better version, and in " | Obviously, in "IDofLowLevelItem" we need to type the ID name of item that should be replaced with better version, and in "MinLevelForReplacing" 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. | ||
* 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 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: | ||
<pre> | <pre> | ||
if ( player.IsRidingHorse == 0 ) | if ( player.IsRidingHorse == 0 ) | ||
if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= | if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= MinLevelForReplacing ) | ||
if ( player.getequipped IDofLowLevelItem == 1 ) | if ( player.getequipped IDofLowLevelItem == 1 ) | ||
player.unequipitem IDofLowLevelItem | player.unequipitem IDofLowLevelItem | ||
Line 93: | Line 96: | ||
if ( player.IsRidingHorse == 0 ) | if ( player.IsRidingHorse == 0 ) | ||
if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= | if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= MinLevelForReplacing ) | ||
if ( player.getequipped IDofLowLevelItem == 1 ) | if ( player.getequipped IDofLowLevelItem == 1 ) | ||
player.unequipitem IDofLowLevelItem | player.unequipitem IDofLowLevelItem | ||
Line 121: | Line 124: | ||
if ( player.IsRidingHorse == 0 ) | if ( player.IsRidingHorse == 0 ) | ||
if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= | if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= MinLevelForReplacing ) | ||
if ( player.getequipped IDofLowLevelItem == 1 ) | if ( player.getequipped IDofLowLevelItem == 1 ) | ||
player.unequipitem IDofLowLevelItem | player.unequipitem IDofLowLevelItem | ||
Line 131: | Line 134: | ||
player.additem IDofBetterItemOrLeveledList 1 | player.additem IDofBetterItemOrLeveledList 1 | ||
endif | endif | ||
elseif ( player.getitemcount IDofAnotherLowLevelItem > 0 && LVL >= | elseif ( player.getitemcount IDofAnotherLowLevelItem > 0 && LVL >= MinLevelForReplacing ) | ||
(...) | (...) | ||
endif | endif | ||
Line 174: | Line 177: | ||
if ( player.IsRidingHorse == 0 && NotPerform == 0 ) | if ( player.IsRidingHorse == 0 && NotPerform == 0 ) | ||
if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= | if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= MinLevelForReplacing ) | ||
if ( player.getequipped IDofLowLevelItem == 1 ) | if ( player.getequipped IDofLowLevelItem == 1 ) | ||
player.unequipitem IDofLowLevelItem | player.unequipitem IDofLowLevelItem | ||
Line 184: | Line 187: | ||
player.additem IDofBetterItemOrLeveledList 1 | player.additem IDofBetterItemOrLeveledList 1 | ||
endif | endif | ||
elseif ( player.getitemcount IDofAnotherLowLevelItem > 0 && LVL >= | elseif ( player.getitemcount IDofAnotherLowLevelItem > 0 && LVL >= MinLevelForReplacing ) | ||
(...) | (...) | ||
else | else |