Tes3Mod:Morrowind Script Library

Created by the community, compiled and edited by Nedius. Version 0.3. The original document was created on 09.10.2007 (or earlier).

Foreword
This resource has been created by a whole host of modders working hard and then offering their work freely to the modding community. Below is the list of modders who have contributed to this resource. Thanks to them all.
Credit goes to: Darknut, Chia, Zer010, Nikki, Melian, Enmesharra, cyran0, morrowind-mod.com, Fliggerty, Midgetalien, Trey Leavens, Pokeapoke, Qarl, Lurlock, Princess_stomper, Baratheon79, ixidorsbane, Aridale, Rocket, Boblen 1982, Kir, Thamior Amakiir, Stuporstar, Regaez, The Pixie, Symon69, Abot.

If you recognise an un-named (or, heaven forbid, wrongly named) script that you are the author of, please let me know so I can put it in place!

(Please note that morrowind-mod.com is defunct and the links that are present there lead to suspicious sites - MWM wiki.)
Activators
Bed script
by Bethesda

 
Buttons
by Nikki

"Activate script"; which would be placed on a button of some sort. You need to make a global variable first, I'll call it "var01", you should name it something with your initials.

 

NOTE: For the mover, use activator wall move script

Button activator 2 (a-la Ghostgate)
Submitted by Zer010, made by Bethesda

Here's the classic button/lever leads to wall/gate/whatever moving script: the MW ghostgate script.
This part is put on the activator:
 Begin GG_OpenGate1

;opens first gate as Ghostgate (say that 5 times)
;put on button

float timer
short state

if ( MenuMode == 1 )
	return
endif

if ( OnActivate == 1 )
	
	if ( GG_Gate1_State == 0 ) 
		PlaySound "Open Lock"
		"ex_gg_portcullis_01"->Playsound3DVP "Dwemer Door Open" 1.0 1.0
		set GG_Gate1_State to 10
		set state to 10
	endif
endif

if ( State >= 10 )
	
	set timer to ( timer + GetSecondsPassed )

	;move gate up (210 units)
	if ( timer  
It uses a global variable, GG_Gate1_State. Also, the moved bit needs to have this "script":
  
- which adds a variable to track, although actually I've never seen it being used.

Flushing toilet
by Pokeapoke

 begin flush_script

short state
float timer

if ( MenuMode == 1 )
return
;don't run time in Menu Mode. Very bad.
endif
if ( state == 0 ); flush is off
if ( onActivate == 1 )
 PlaySound3D "Dwemer Door Open"
set state to 1
set timer to 1; will rotate for 1 second while opening
endif
elseif ( state == 1 ); flush is turning
 Rotate X -60; rotates 60 deg/sec
 set timer to ( timer - GetSecondsPassed )
if ( timer  

Hurt actor on contact 1
 

Hurt actor on contact 2
by Regaez

The most basic of all scripts!
 

Invisible activator

Here is a different version of the abovementioned script which will make the wall rise when you get near an invisible marker, the "trigger script". I recommend using the activator mesh with the sound effect scripts on them. You can use the same global variable as the above script but you should not use them both in the same cell.

Create your own “var01” using the gameplay > Globals menu and selecting new and giving your global a unique id. Replace var01 with this ID.

 begin trigger01_script

short doonce 


if ( MenuMode == 1 ) 
return 
endif 

If ( GetDistance, Player  
Note: for the mover, use activator wall move script.

Light switch
by Regaez

The lightswitch script – attach this to your switch object. Rz_light is a global variable (Short).
 
This next script is what you place on the individual lights. This is for the “normal” lighting. Copy this and place it on your other colored lights – you will just need to change the enable/disable to their corresponding variable value. I'll list it for you:

Norm, enable if( Rz_light == 1)

Green, enable if( Rz_light == 2)

Blue, enable if( Rz_light == 3)

Red, enable if( Rz_light == 4)

All lights, disable if ( Rz_light == 5)

 
Reset activator
by Nikki

Now here is a script you should place on another invisible activator in the room to reset the global variable when you leave the cell so you can use the script over and over.
 
Teleporting the player
by Zer010

Here's a script that makes an object teleport the player somewhere upon activation.
It's supposed to look better in game than a more simple teleportation because it uses fades.
I haven't actually used it myself yet.
You need to create 3 new global float variables for it: My_PC_X, My_PC_Y, My_PC_Z (replace "my" with something unique).
 
Weather controller (static)
by Regaez

Here is a script I just recently wrote – and it works! It randomly changes the weather when you activate it. It is static, so you can’t pick it up. I attached it to the dwemer puzzle box – it seemed to fit the script nicely!
 
Creatures

Appearing skeleton trapped chest
by BILL of Bethesda

Script 1 (on chest)
 
Script 2 (on all skeletons)
 
Making creatures appear by invisible activator
by Nikki

This one however makes monsters or NPCs warp into existance when you get near a certain invisible marker. 

First make a global variable. Call it something like "warp var01". Now attach this script to the enemy you want to do the warping:
 
And of course the good ol' trigger script to cause the warp to take effect when you get near the invisible marker. I recommend using the activator mesh with the sound effect scripts on them. You can use the same global variable as the above script but you should not use them both in the same cell.
 begin WarpTrig01_script

short doonce 


if ( MenuMode == 1 ) 
return 
endif 

If ( GetDistance, Player  
Just place the scripted enemy in the cell wherever you want them to appear. You can use as many of them as you want, so you could have ten of them appear to surround the player when they get near an important item. They dont just appear out of thin air either, they appear with a flash of light and pause for a split second before attacking which makes the effect seem more interesting. Oh, make sure to set their fight AI to 0 otherwise the pause will be negated.

Again, like the scripts in the above post, you must reset the variable when you leave the cell; see the reset script. That way the script can be used again and again.
Summon a creature on activating an item
by BILL of Bethesda
 
Visual effect on death
Submitted by Midgetalien

Here's one which places a special effect when a creature dies. It also disables the creature i.e making look like it diseapered in the magical vortex. If you want the creature's corpse to still be there, then just remove the disabled part.
 
Display cases
from morrowind-mod.com
Lady E's, which have the glass lids go down when activated
 ; Activates the display case lid (_SA_dispcaselid) to slide up/down. 
; Creator of this script is Viking_ Lord from Anastasio The Great's Hideout
begin SA_displaycaselid
float Timer
short State
if ( MenuMode == 1 )
return
endif
if ( OnActivate ==1 ) 
if ( State == 0 )
PlaySound "Door Stone Open"
set State to 245
endif
endif
if ( State >= 245 )
set timer to ( timer + GetSecondsPassed )
;slide lid down
if ( Timer  
Indigo Rage's display cases with the red fabric interior
 ;This script is from IndigoRage it operates the cases that have the red fabric on the bottom.
begin SA_Ind_displaycase
short state
short first
short open
short close
float timer
If (MenuMode == 1)
Return
endif
If (OnActivate == 1)
Set state to 1
endif
If (state == 1)
If (first == 0)
playgroup, idle2, 0
set open to 1
endif
endif
if (open == 1) 
set timer to ( timer + GetSecondsPassed )
if ( timer  
Dongle's Green glass display cabinet
 ;This script is from Dongle for use with the Green Glass Display Cases. 
Begin, SA_GlassDisplayScript
Short State
Short First
Short Open
Short Close
Float Timer
If ( MenuMode == 1 )
Return
EndIf
If ( OnActivate == 1 )
Set State to 1
EndIf
If ( State == 1 )
If ( First == 0 )
PlayGroup, Idle2, 0
PlaySound3D, "Door Creaky Open"
Set Open to 1
EndIf
EndIf
If ( Open == 1 )
Set Timer to ( Timer + GetSecondsPassed )
If ( Timer  

Fixed versions of Dongle's and Indigo Rage's display cases scripts
These were not included in the original compilation - MWMWiki

The following modifications of the abovementioned scripts were submitted by Cantorsdust. They described the problem with the original scripts as follows: "The fundamental problem, as far as I could tell, was this: The containers had 4 animations. Idling closed, opening, idling open, and closing. For whatever reason, the closing animation refused to allow the idling animation to take over after the appropriate time. So I changed the animation function to interrrupt, rather than wait for the previous animation to finish, then adjusted the timers so that the animation interrupted at just the right time."

 Begin GlassDisplayScript
;used in Dongle's display case

short State
short First
short Open
short Close
float Timer

If ( MenuMode == 1 )
Return
endif

If ( OnActivate == 1 )
Set State to 1
endif

If ( State == 1 )
If ( First == 0 )
If ( Open == 0 )
PlayGroup, Idle2, 0
PlaySound3D, "Door Creaky Open"
Set Open to 1
Set State to 0
Set First to 0
Set Close to 0
Endif
EndIf
EndIf

If ( Open == 1 )
Set Timer to ( Timer + GetSecondsPassed )
If ( Timer  

 begin Ind_displaycase
;attached to Indary's display case

short state
short first
short open
short close
float timer

If ( MenuMode == 1 )
Return
endif

If ( OnActivate == 1 )
Set state to 1
endif

If ( state == 1 )
If ( first == 0 )
if ( open == 0 )
playgroup, idle2, 1
set open to 1
set state to 0
set first to 1
set close to 0
endif
endif
endif

if ( open == 1 )
set timer to ( timer + GetSecondsPassed )
if ( timer  

Doors
Air lock script
by Regaez

This is the airlock script. Place this on the desired switch. Waterlev and waterstate are global variables (short).
 
Place this script on the door that you exit from – to the flooded area (you usually enter from this door).
 
Place this script on the door which leads to the rest of the cell – the area which is not flooded. You may need to play around with values depending on what the original waterlevel was – I think I set mine to 15000.
 Begin Rz_airlock_flooddoor

if( MenuMode == 1)
    return
endif

if( OnActivate == 1)
    if( GetWaterLevel > 14750)
        MessageBox "You need to drain the room of water first, before opening this door."
    elseif (GetWaterLevel  
Automatically closing doors
by Enmesharra

I hate having doors opened all over the place about as much as I hate having to always stop and close the door. So I created this simple but useful script for my house mod. Put this on a door and the door will close by itself 5 seconds after being opened.
 
Door lock script
by Pokeapoke
 
Alternate door lock script
by Qarl
 Begin Door_lock

If ( OnActivate )
 If ( Player->GetItemCount "Door_key"  
Auto-lock doors
by Baratheon79
 begin auto-relock_door_script

short activate_count
float relock_timer

DontSaveObject

if ( menumode == 1 )
   return
endif

;This part allows the player to open the door if they pick the lock or have
;the key in their inventory.
if ( GetLocked == 0 )
   if ( OnActivate == 1 )
        if ( activate_count  GetItemCount, "door_key" >= 1 )
             Activate
             set activate_count to ( activate_count + 1 )
        else
             Activate
        endif
   endif
endif

;This section relocks the door once it's closed
if ( activate_count == 2 )
   if ( relock_timer  
Trapped rug
by Rocket

Use a different spell for this one, you might have to create one.
 
Create a door using a rug model like f\Furn_rug_01.nif. Give it a name like "Handwoven Rug" and attach this script. Set the reference data to locked, level 0, with any trap spell.
Trapped rug 2
by BILL of Bethesda

 begin BILL_common_trapped_rug
; hits the player with a glyph of weakness when he walks on the rug.
; trap resets 15 seconds later.
;
; script location: should be called from ac_furn_rug_big_04_dren

; variables
short onMe		; is the Player on me?
short wait
float timer

if ( MenuMode == 1 )
	return
endif

if ( wait == 1 )
	set timer to ( timer + GetSecondsPassed )
	if ( timer  
Tribunal’s dark hole script – a door with an option to pass through
 
Inventory
Making items arrive post-death
 Begin XX_Death_Script

If ( GetHealth  
Items
Making a miscellaneous object unliftable
by Vorwoda_the_Black, from morrowind-mod.com

I had to change the trees in Abu Manor dining room from Static to Miscellaneous Objects so they wouldn't have collision walls, but I didn't want people to be able to pick them up like Miscellaneous Objects. Just replace the SA_MiscTreeScript with the id of the object in question.
 
Teleport amulet
Make sure you alter the LOCATION, and insert here x/y/z values.
 
Teleport ring
from morrowind-mod.com
 
Teleport ring 2
by Thamior Amakiir

Change locations to where you want it to take you.
 
Teleport ring 3
by Regaez

This is the teleporting ring script. Attach it to a ring (duh). It is currently set to teleport you to Balmora Square. It requires you to make a mark ability and a recall ability. And if you don't want to teleport to Balmora Square you'll just have to change the position cell info.
 
‘Throbbing’ items
by Fliggerty

It makes an object grow and shrink a little bit to simulate a "throbbing" effect.
 begin throb_script

  float timer
  short state
  float temp
  short delay

  if ( MenuMode )
      return
  endif

  set timer to ( timer + getsecondspassed )
  if ( timer >= 3 );change this for delay between grow n shrink
      if ( state == 0 )
          set state to 1
      else
          set state to 0
      endif
      set timer to 0
  endif

  set delay to ( delay + 1 )
  if ( delay  
Making objects appear only if the player has an item in their inventory
by Trey Leavens

This one makes the object it's attached to only appear if the player has a certain item in inventory.
It would be pretty cool if you checked for a spell instead of an item, say one which you only got from a faction, since that's not obvious the object appearing would appear to be connected with belonging to said faction.
 
Sword in the stone
by Regaez

Ah, well here's a little "Sword in the Stone" sort of script. Basically you could put it on a sword stuck in the ground. It's pretty basic, but hey!
Note (comment from author): “Oh, I'm writing it from memory, as I am not actually on my Morrowind-playing computer at the moment, so it may not be 100% the correct (I sometimes get muddled up with the greater than/less than signs).”
 Begin R_strength_test

if( MenuMode == 1)
     Return
endif

if( OnActivate == 1)

     if( player-> GetStrength   GetStrength > 49)
            if( player-> GetStrength   GetStrength > 59)
            if( player-> GetStrength   GetStrength > 69)
            if( player-> GetStrength   GetStrength > 79)
            if( player-> GetStrength   GetStrength > 89)
            if( player-> GetStrength  

Another note from author: “I would just like to make a last minute defense in case this script has some fatal flaws and say that I am not the best at scripting and... oh what the heck, you get the idea! If it's wrong then it's wrong and I'm sure you super dooper scripters out there can fix it in the blink of an eye!”

Sword in the stone 2
by Regaez

Another "Sword in the Stone" themed script. Attach this to a Daedric Longsword or a weapon of your choice!
 
Sword in the stone 3
by Symon69
 Begin R_strength_test

local pstr

if ( MenuMode == 1)
     Return
endif

set pstr to player -> GetStrength

if ( OnActivate )
     if ( pstr  
Weather controller (carriable)
by Regaez

To use this object just drag it onto your person in the inventory menu.
 
Journal
Adding journal entries
by Cyran0

Well, here is a script that I frequently use in designing quests. It updates the player’s journal upon reading a book or note. It works whether the player reads the note by activating it in the world or equipping the note from inventory.
 
Using the journal to make items ‘appear’
This script can be placed on an item, activator or NPC to make it appear only after a certain journal entry has been reached. Remember to replace ‘MY_JOUNRAL_INDEX’ with the journal name of the required entry.
 Begin Journal_enable_script

if ( GetDisabled == 0 )
	if ( GetJournalIndex MY_JOUNRAL_INDEX  
Locks
Briefcase lock
by Kir
 begin CodeLock_Briefcase

short status
; 0 - initialization
; -1 - locked and standby
; 2 - locked and activated
; 3 - processing buttons
; -4 - unlocked and standby
; 5 - unlocked and activated
; 6 - processing lockpicking
; 7 - blocking from reaction to OpenLockFail sound more than once

short codesum
short code1
short code2
short code3
short code4
short lock1
short lock2
short lock3
short lock4
short locksum
short button
short pickable
float chance
short i
short j

if ( OnActivate == 1 )
if ( status == -4 )
set status to 5
else
set status to 2
endif
endif

if ( GetSoundPlaying "Open Lock Fail" == 1 )
if ( status == -1 )
set status to 6
return
endif
endif

if ( status   0 )
Lock 10000; It *must* be insanely high regardless of the intended difficulty - do not change
endif
set status to -1
endif

if ( status == 5 )
Activate
set status to -4
endif

if ( status == 2 )
; MessageBox "Enter the code number:| %.0f    %.0f    %.0f    %.0f", lock1, lock2, lock3, lock4, "  ", "  ", "  ", "  ", "Exit"
MessageBox "  %.0f    %.0f    %.0f    %.0f             ", lock1, lock2, lock3, lock4, "  ", "  ", "  ", "  ", "Exit"
set status to 3
endif

if ( status == 3 )
set button to GetButtonPressed
if ( button == -1 )
return
elseif ( button == 0 )
set lock1 to lock1 + 1
if ( lock1 == 10 )
 set lock1 to 0
endif
elseif ( button == 1 )
set lock2 to lock2 + 1
if ( lock2 == 10 )
 set lock2 to 0
endif
elseif ( button == 2 )
set lock3 to lock3 + 1
if ( lock3 == 10 )
 set lock3 to 0
endif
elseif ( button == 3 )
set lock4 to lock4 + 1
if ( lock4 == 10 )
 set lock4 to 0
endif
elseif ( button == 4 )
set status to -1
return
endif
set locksum to ( lock1 * 1000 ) +  ( lock2 * 100 ) + ( lock3 * 10 ) + lock4
if ( locksum == codesum )
set status to 5
PlaySound "Open Lock"
if ( pickable > 0 )
 Unlock
endif
else
set status to 2
PlaySound "LockedChest"
endif
endif

if ( status == 6 )
set chance to ( Player->GetSecurity )
set chance to ( chance * chance * chance )
set chance to ( chance / 10000 )
set i to Random, 20
set chance to ( chance + i )
set i to ( Player->GetLuck )
set i to ( i / 10 )
set chance to ( chance + i )
;messagebox "Security + Random + Luck chance %.3f" chance

if ( Player->GetItemCount       "skeleton_key" > 0 ); Morrowind only
; if ( Player->HasItemEquipped "skeleton_key" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 2 )
elseif ( Player->GetItemCount       "pick_secretmaster" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_secretmaster" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 1.2 )
elseif ( Player->GetItemCount       "pick_grandmaster" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_grandmaster" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 1.1 )
elseif ( Player->GetItemCount       "pick_master" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_master" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 1.0 )
elseif ( Player->GetItemCount       "pick_journeyman_01" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_journeyman_01" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 0.8 )
elseif ( Player->GetItemCount       "pick_apprentice_01" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_apprentice_01" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 0.6 )
endif
;messagebox "Total chance %.3f" chance

if ( ( Chance * 2 )  
Keypad lock
by Kir
 begin CodeLock_Numpad1

short status
; 0 - initialization
; -1 - locked and standby
; 2 - locked and activated
; 3 - processing buttons
; -4 - unlocked and standby
; 5 - unlocked and activated
; 6 - processing lockpicking
; 7 - blocking from reaction to OpenLockFail sound more than once

long codesum
long code
short lock_length
short lock_order
short code1
short code2
short code3
short code4
short code5
short code6
short code7
short code8
short code9
short code10
short code11
short code12
short code13
short code14
short code15

short button
short pickable
float chance
short doonce
short correct
short i

if ( OnActivate == 1 )
if ( status == -4 )
set status to 5
else
set status to 2
set lock_order to 1
set codesum to 0
endif
endif

if ( GetSoundPlaying "Open Lock Fail" == 1 )
if ( status == -1 )
set status to 6
endif
endif

if ( status  = 1 )
set code to ( code * 10 ) + code1
endif
if ( lock_length >= 2 )
set code to ( code * 10 ) + code2
endif
if ( lock_length >= 3 )
set code to ( code * 10 ) + code3
endif
if ( lock_length >= 4 )
set code to ( code * 10 ) + code4
endif
if ( lock_length >= 5 )
set code to ( code * 10 ) + code5
endif
if ( lock_length >= 6 )
set code to ( code * 10 ) + code6
endif
if ( lock_length >= 7 )
set code to ( code * 10 ) + code7
endif
if ( lock_length >= 8 )
set code to ( code * 10 ) + code8
endif
if ( lock_length >= 9 )
set code to ( code * 10 ) + code9
endif
if ( pickable > 0 )
Lock 10000; It *must* be insanely high regardless of the intended difficulty - do not change!
endif
set status to -1
endif

if ( status == 5 )
Activate
set status to -4
endif

if ( status == 2 )
MessageBox "       Enter the code sequence: %.0f         ", codesum, "1", "2", "3", "4", "5", "6", "7", "8", "9"
set status to 3
endif

if ( status == 3 )
set button to GetButtonPressed + 1
if ( button == 0 )
return
endif
set codesum to codesum * 10
set codesum to codesum + button
set lock_order to lock_order + 1

if ( lock_order > lock_length )
if ( codesum == code )
;   Activate
 set status to 5
 PlaySound "Open Lock"
 Unlock
else
 set status to 7
 PlaySound "Open Lock Fail"
endif
else
set status to 2
PlaySound "LockedChest"
endif
endif

if ( status == 6 )
set chance to ( Player->GetSecurity )
set chance to ( chance * chance * chance )
set chance to ( chance / 10000 )
set i to Random, 20
set chance to ( chance + i )
set i to ( Player->GetLuck )
set i to ( i / 10 )
set chance to ( chance + i )
;messagebox "Security + Random + Luck chance %.3f" chance

if ( Player->GetItemCount       "skeleton_key" > 0 ); Morrowind only
; if ( Player->HasItemEquipped "skeleton_key" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 2 )
elseif ( Player->GetItemCount       "pick_secretmaster" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_secretmaster" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 1.2 )
elseif ( Player->GetItemCount       "pick_grandmaster" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_grandmaster" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 1.1 )
elseif ( Player->GetItemCount       "pick_master" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_master" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 1.0 )
elseif ( Player->GetItemCount       "pick_journeyman_01" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_journeyman_01" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 0.8 )
elseif ( Player->GetItemCount       "pick_apprentice_01" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_apprentice_01" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 0.6 )
endif
;messagebox "Total chance %.3f" chance

set status to 7
if ( ( Chance * 1.5 )  
Magic
Magic regeneration
by Zer010

This global script makes the PC's (and only the PC's) magicka gradually regenerate.
I find it better than sleeping 26 hours at a stretch.
Note that the formula can be changed, as well as the time.
 begin Global_MagickaRegeneration
     
     float regen
     float timer
     float will
     
     if ( MenuMode == 1 )
         return
     endif
     
     set timer to ( timer + GetSecondsPassed )
     if ( timer  
Misc
Detecting PC’s birthsign
by The Pixie

This script will detect the player's birthsign, setting the global variable Pix_g_Birthsign. Use it as a global script.
 
On anyone or anything that is interested in the birthsign, put this at the start of their script, so the above is called once and only once:
 
I have tested this to my satisfaction, but it has not been beta-tested.
Detecting player’s facing
by Clownbaton

This is a script from my current (and first :] ) mod. Its easy to determine in which direction the Player is facing but if you want plot any sort of projectile motion relative to the way the player is facing then you need to know in which Cartesian quadrant you are in and in which direction you are facing. Basically, this script gives you access to your location and your orientation within each quadrant. Each unique state is defined by a value and these values can later be used to correctly plot an object's path. It is supposed to be attached to an equippable object and once the object has been equipped the user can access the data. a simple modification would mean you could run it as a global script.

So I guess you could put this one under "location determination" or "projectile motion update information" or something. I know it sounds like I'm over-complicating it but imagine plotting the course of a catapult's round? Since "SetPos" sets the world coordinates we need this extra orientation information.
 begin tjk_scr_PC_Faces

;this will define as a number the orientation of the PC and in which quadrant 
;the PC is in. This information will be useful for projectile motion path 
;plotting

short OnPCEquip
short PantsOn
short FrameCount
float PCX
float PCY
float PCZ
float TimePassed
short QState              ;holds quadrant PC is in
short FState              ;holds the local direction PC is facing
short PCAngle           ;holds relative angle of the PC

if ( OnPCEquip == 1 )
	MessageBox "Player orientation object has been equipped!"
	set PantsOn to 1
	set OnPCEquip to 0
endif

if ( PantsOn == 1 )
	if ( FrameCount    GetPos, X )
		set PCY to ( Player-> GetPos, Y )
		set PCZ to ( Player-> GetPos, Z )
		
		;quadrant 1 check
		if ( PCY > 0 )
			if ( PCX > 0 )
				set State to 1
				MessageBox "PC is in Q1"
			endif; PCX
		endif;  PCY

		;quadrant 2 check
		if ( PCY > 0 )
			if ( PCX   0 )
				set State to 4
				MessageBox "PC is in Q4"
			endif; PCX
		endif;  PCY

		;now we can get the rotation of PC
		set PCAngle to ( Player-> GetAngle, Z )
		
		;must first check to see if PC is in line with a local axis
		if ( PCAngle == 0 )
			set FState to 9
			MessageBox "PC is facing North as angle is 0"
			Return
		endif

		if ( PCAngle == -90 )
			set FState to 10
			MessageBox "PC is facing West as angle is -90"
			Return
		endif

		;if ( PCAngle == -180 )
			;set FState to 11
			;MessageBox "PC is facing South as angle is -180"
			;Return
		;endif

		if ( PCAngle == 180 )
			set FState to 11
			MessageBox "PC is facing South as angle is 180"
			Return
		endif

		if ( PCAngle == 90 )
			set FState to 12
			MessageBox "PC is facing East as angle is 90"
			Return
		endif

		;now we can see if it lies in a local quadrant
		;local q1
		if ( PCAngle > 0 )
			if ( PCAngle   -90 )
				set FState to 6
				MessageBox "PC is facing p2"
				Return
			endif
		endif

		;local q3
		if ( PCAngle   -180 )
				set FState to 7
				MessageBox "PC is facing p3"
				Return
			endif
		endif

		;local q4
		if ( PCAngle > 90 )
			if ( PCAngle  
Interors like exteriors
by Abot

 
Keg script
by Lurlock
 
Trash can
Original script by Boblen1982 - rewritten by IxidorsBane
 begin container_reset_scr

short deltimer
;object_reset - glob.variable to start deleting container

if ( object_reset == 0 )
if ( deltimer != 0 )
 set deltimer to 0
endif
return
endif

if ( object_reset == 1 )
if ( deltimer == 0 )
 Disable
endif
if ( deltimer  
part II: to be put on a hidden activator (a ring under the floor, etc.)
 begin object_activator

;original script by Boblen1982 - rewritten by IxidorsBane

short active
short message_state
short buton
short object_timer
short currentDay
;object_reset - glob.variable to start deleting container

if ( currentDay != Day )
set currentDay to Day
set active to 1
endif

if ( active == 0 )
return
endif

if ( active == 1 )
set active to 2
set object_timer to 0
endif

if ( active == 2 )
set object_reset to 1
set active to 3
elseif ( active == 3 )
set object_timer to ( object_timer + 1 )
if ( object_timer  
Movers
Activator wall move
by Nikki

Now here's a script that will cause a wall to rise up when that button is pressed, or you get near that invisible marker. Make an activator from the wall mesh and attach this script to it.
 begin WallMove01_script

float Timer 
short State 

if ( MenuMode == 1 ) 
return 
endif 

if ( var01 == 1 ) 
if ( State == 0 ) 
PlaySound3D "SothaDoorOpen" 
set State to 1
endif 
endif 

if ( State >= 1 ) 

set timer to ( timer + GetSecondsPassed ) 

if ( Timer  
Use with the actor reset script (link needed)
Sliding wall trap 1
by Nedius, modified by Enmesharra

This should be placed on a mesh that the player stands on to activate a wall mover.
 
Sliding wall trap 2
by Nedius, modified by Enmesharra

This should be placed on a mesh that the player stands on to activate a wall mover.
 
Sliding wall trap 3
by Nedius, modified by Enmesharra

This should be placed on a mesh that the player stands on to activate a wall mover.
 Begin GDRN_LostStairTrap

short state
float counter
Short doOnce

if ( MenuMode == 1 )
return
endif

if ( GetStandingPC == 0 )
;its best to do it this way ... otherwise the whole script until you step on the mesh 
return
endif

If ( doOnce == 0)

set state to 10

endif

if ( state == 10 )

Set counter to counter + GetSecondsPassed

if ( counter  
Rotating objects constantly
by Nikki

This script will make an object rotate constantly. You should change the X/Y/Z value to alter the axis, the number to alter the speed.
 
Up and down constant movement
This will make a mover rise and then fall again, constantly.
 begin updwn

float      timer
float    uptime

if ( MenuMode == 0 )

    set uptime to 1    

    set timer to ( timer + GetSecondsPassed )

;move up
    if ( timer  
Music
Overriding battle music
by Nikki

This script causes a certain music file to be played and overrides battle music. I always thought battle music ruined the element of suprise in MW, as levitation magic ruins the fun of exploration.

First make two rats, one called "music rat 01" and another called "music rat 01b", check the references persist tab on rat01b. Give each of them a constant paralyze ability. Place this script on "music rat 01":
 
Then place each of them in the cell somewhere where you cant see them like under a rock or something. They will try to fight one another but wont be able to move due to the paralyse ability. The music file you scripted on the other one will loop over and over as long as you are in the cell and will not be interuppted by battle music.

I got this idea from another poster on this forum but the original had just one rat that attacked the player. The problem with that version is that any NPCs or creatures with startcombat scripted on them caused battle music to play again. This one is foolproof.
NPCs
Changing NPC's clothes daily
by Trey Leavens

Here’s a simple script to make an npc wear different outfits on different days, for each day of the week, and pjs at night. Substitute or add lines for whatever outfits you want. They do not have to be in their inventory, the equip command adds items and equips them to npcs.
 
Disposition
by Melian

This one is VERY simple, but I seem to remember people asking about NPC disposition control a lot in the past. Sets an NPC's in-game (not base) disposition to match a variable NPC_Disp.
 begin NPC_local_script

float temp

;short NPC_Disp
;can be local or global, as needed
;can also be a float if you like but not necessary unless you want to mod disp by a float value


if ( MenuMode == 1 )
    if ( NPC_Disp  
The only way to change the NPC's disposition is to set NPC_Disp, nothing else will have any effect. 
So no "ModDisposition 10", it's "set NPC_Disp to ( NPC_Disp + 10 )".
Enforced clothing for a companion
by Enmesharra

The concept is for a companion to have their own outfit and not wear the stuff you really just want them to carry for you. This is the simple version, the one I'm using in the mod will allow the player to choose from several outfits.

The script is started in the result box of the companion's greetings. When you give the companion things to carry, if they are more valuable or have a better armor rating then the companions personl stuff then they will immediately put them on. Once the dialog ends this script removes all clothes and re-equips the companion's personal outfit.

The items ZZA_strip_01 through ZZA_strip_05 - are a set of clothing and armor that cover all body parts, ensuring the removal of all clothing/armor. The items ZZA_Comp_outfit_1 and ZZA_Comp_outfit_2 are the companion's personal armor and boots.

The potential for abuse exists in that it is easy for the player to create infinite number of the companion's outfit by removing them each time. When I included checks to see if the companion still posessed the outfit it slowed the redressing down too much (at least in the complicated multioutfit version). If someone is going to exploit this, they can just use the console to give themselves a bunch of money much more easily, so I didn't worry about it. (Except to make the companions outfit only worth 1 gold piece).
 Begin ZZA_comp_dress_script

short counter

If ( menumode == 1 )
  return
endif

if ( counter  
Guard script
by Stuporstar

Here's a script to control AIEscorts and make sure they will not follow the player through a door or teleport. It's great for making guards in a particular cell which defend the player but need to stay put. This was contributed to my mod by Arcimaestro Anteres, and consists of two scripts that work together:
 
 
Note from Yacoby: the guards will not defend the player if they teleport into the cell.
Making NPCs fight
submitted by Zer010

This script could be placed on one or the other NPC, or even on a hidden activator in their cell if there is some reason you do not want the script attached to an NPC. I do not know what distance you want them for combat to begin, but you can play with the distance value I am using until you are satisfied.
 
Making NPCs fight 2
This script should be placed on NPC1, and another on NPC2. However, the script for NPC2 should have the locations on NPC1 and NPC2 reversed.
 
Making an NPC fight two others
To make an NPC fight with two NPCs, NPC 1 uses this script, NPCs 2 & 3 use the above script, suitably altered.
 
Making companions warp to you
by Grumpy, submitted by Zer010

This script is used a lot, it's Grumpy's companion script which causes a companion to "warp" back to you if it gets too far away ( meaning that it's stuck in a hedge or something ). You still need to put the companion in follow mode through dialogue/script.
 
Mannequins
Simple mannequin
by Zer010

A simple mannequin script. This freezes an NPC into position so the player can put armor on them. They're fun but disturbingly detailed for mannequins. The simplest one is this:
 
You put it on an NPC with 0 life and "corpses persist" checked, their body stays upright. Problem is you can get rid of them if you hit "dispose of corpse" when activating them.
Wooden Armor Mannequins
by Chris Janosi

These are non-weapon wielding & they are moveable so you need the placeholder script, which is provided here also.
 
Armor mannequin placeholder script, used with the above script for Chris Janosi's mannequins:
 
Pacifying NPCs
by Lurlock
 
Scale
For the scale of your choice, simply edit the ‘setscale X’ number.
Scale scrpit 1
 
Scale script 2
 
Scale script 3
 
Timer
By Zer010

Well, here's a timer. Placed on an activator, it'll make it do something five seconds after activation.
 
Or perhaps it would work with timer=5, and one fewer doonce? Dunno...