I know lots of you out there are completely confused about how to start scripting, but want to learn anyway. First, I'll link Morrowind Scripting for Dummies because it is the bible. It can still be a little complicated for the complete novice though, which is why I'm making this thread to help you all out ( and because I was asked nicely to do something like this ). smile.gif

I will also link the Comprehensive Tutorial and Useful Link List. There is lots of good stuff in there.

The CS Basics:

First I'll give a mini tutorial on making and applying a script.

So you have your mod open and an object you want to script it. ( I'll assume that much or you should be reading the "My First House" tutorial wink.gif ) The first thing you do is go into the Gameplay menu and select Edit Scripts. Now you'll want to make a new script, so go ahead and select that from the menu in the scripting window. It'll open up a blank page and you can start typing in your stuff there.

* NOTE: you can also use ctrl-C and ctrl-V to copy and paste stuff. It's actually easier to write your scripts in WordPad or something because you can use the search and replace functions. It's also a good idea to save any script your working on as a text file just in case the CS crashes or you accidentally hit "recompile all".

That's another good bit of advice. Never ever EVER hit the "recompile all" button. EVER. Period. As far as most of us scripters are concerned, that bloody button should have been disabled when the devs handed their nifty tool over to us. It is the "please make the cs crash and ruin all my hard work" button.

After you save your script ( yes I skipped the scripting part for now because the rest of the tutorial/faq is going to be all about that ) you are going to have to reference it somewhere.
- A Local Script is attached to an object. To apply it to the object, just go into the object menu in the cs, click on the script bar and scroll down until you find the name of your script. Local scripts will only run if the object is currently loaded ( in the same cell as you or in your inventory ). So if you have a script on a barrel, that script will start as soon as you enter the room that contains the barrel, and then stop after you leave the room.
- A Global Script has to be started. Once it is started ( by typing "StartScript YourScriptName" into the dialogue results field, or into another script or by making it a startscript ) it will run in the background constantly until it is stopped. Global scripts are usually stopped inside the script itself by adding "StopScript YourScriptName" to the end of the script, or after a certain condition is met inside the script ( a certain variable or function is set to a specific number for example...more on that later).

Ok, now on to the actual scripting:

The first thing you want to do is give it a begin and end tag, as well as a name.

CODE
Begin YourScriptNameHere

End


These lines have to be in every script, and you stuff everything else in between.

If statements:

These are pretty much the same as in most programming languages, php, C, you name it.

CODE
If ( this stuff happens )
     Do This Stuff
Endif


Always check to make sure an If statement is closed by an Endif. Otherwise the CS compiler will barf up your script.

The next level is the Else and Elseif statements that can go in between to allow multiple variable conditions:

CODE
If ( this is true )
     Do this
Elseif ( this other thing is true )
     Do something else
Else; else meaning none of the conditions return true, and btw the semi-colon is a comment which means you can safely type stuff after it that won't be compiled to explain your scripts...as I am doing now.
    Do nothing; or something else
Endif


And that's the basic logic behind coding.

That's part one. I'll get to more later as I find the time.
Hey There! This is an excellent idea. Glad to see you picking up the torch. (and not burning down houses with it....)

May want to link to the Sticky thread in the mods form for the beginning tutorials as well. As far as I know, there is NOT beginning scripting tutorial, so you are filling a rather large void here.

Thank You.
QUOTE(HeyYou @ Oct 14 2007, 03:07 PM) *
As far as I know, there is NOT beginning scripting tutorial, so you are filling a rather large void here.

Other than the one in MWSFD, the one Dragon_Song did (which is slightly outdated in some respects now) etc


Anyway, good work, always good to see more tutorials smile.gif
Ooh, scripting in common language! Thank you. I understand bits and pieces, maybe someday I'll connect the dots and have it all make sense. (I get the language, just not the usage)
I've added the link to the Useful Tutorial sticky. I'll get to explaining variables and functions next. I'm writing stuff in installments whenever I need a break from my modding. I also added a little bit about global and local scripts and how they run.
Stuporstar! I had no idea you were serious about this, you said a few days ago you might release a small guide. Thank you!
QUOTE(hellbreaker @ Oct 15 2007, 02:53 PM) *
Stuporstar! I had no idea you were serious about this, you said a few days ago you might release a small guide. Thank you!


Hey, your welcome! I've done it this way so I can work on it in bits whenever I'm not too busy. I'll make another addition to it sometime today maybe. smile.gif
Thanks from me too, Stup!

You have been most helpful to this noob! This is an excellent start! Keep them coming!

fing05.gif
Hi everyone

can I add a link to the ever famous and ever growing UESP Wiki ... Modding Section

particularly this [clickable Link]=> Tes3Mod:Scripting Basics

and of course this [clickable Link] => Tes3Mod:Scripting Pitfalls

they are both good resources and of course when you get to be great you can update them smile.gif

many thanks on Stuporstar for this initiative and the amazing horizon of modding challenges and solutions smile.gif
Here's a little script I made for items that can't have enchanting
(Tested and works perfectly)

-------------------------------

Begin {script name}

short done
short OnPCEquip

if ( OnPCEquip == 1 )
player-> addspell {ability name}

endif

if ( OnPCEquip == 0 )
player-> removespell {ability name}

endif

end


---------------------------

very simple and easy to remeber!
this adds the ability (spell) so that the player has it when equipped and removes it when it is unequipped.
Just make a spell (ability) and use it instead of an enchantment. It's also useful for surprise stuff.
I made it for a new mod im releasing shortly "Expanded Morrowind - Torch Magic". laugh.gif
Hope this helps some people!!

Nice thread.
I'd like to add my 2 cents to try to justify the poor "recompile all" button existence smile.gif .
It can be useful if you have a lot of global targeted scripts calling each other (you have to recompile all cross-referencing global scripts when you make changes).

The 5 standard buggy scripts not recompiled in the process (DagothUrCreature1, EndGame, Float, LorkhanHeart and SignRotate) can be easily removed, or you can use Wrye's GMST vaccine to avoid the problem.
QUOTE(abot @ Oct 17 2007, 08:37 PM) *
Nice thread.
I'd like to add my 2 cents to try to justify the poor "recompile all" button existence smile.gif .
It can be useful if you have a lot of global targeted scripts calling each other (you have to recompile all cross-referencing global scripts when you make changes).

The 5 standard buggy scripts not recompiled in the process (DagothUrCreature1, EndGame, Float, LorkhanHeart and SignRotate) can be easily removed, or you can use Wrye's GMST vaccine to avoid the problem.


actually thats a goos point smile.gif I forgot that ...
heh. ive never read the "My First House" tutorial, can some'one post a link or something please.

thnx mellow.gif
Check the pinned threads at the top of the forum, many tutorials are linked there.
QUOTE(abot @ Oct 17 2007, 02:37 PM) *
Nice thread.
I'd like to add my 2 cents to try to justify the poor "recompile all" button existence smile.gif .
It can be useful if you have a lot of global targeted scripts calling each other (you have to recompile all cross-referencing global scripts when you make changes).

The 5 standard buggy scripts not recompiled in the process (DagothUrCreature1, EndGame, Float, LorkhanHeart and SignRotate) can be easily removed, or you can use Wrye's GMST vaccine to avoid the problem.


That's true, though I personally still have crashing problems when accidentally hitting that evil little button, even though I use GMST vaccine. I guess it's just my old computer having problems. I still recommend not touching it if you're just starting out scripting.
I'm looking for a companion thread that
if dead, stop following until spoken to again.
(dremoran guardian)

If I can also get help with a pack guar script that can be bought, then spawns, owned by you and can have items put inside its "pack".
Thanks
QUOTE(Oblivio-Relic-Vvardenfell @ Oct 26 2007, 08:12 AM) *
I'm looking for a companion thread that
if dead, stop following until spoken to again.
(dremoran guardian)

If I can also get help with a pack guar script that can be bought, then spawns, owned by you and can have items put inside its "pack".
Thanks


You'd probably want to make your own thread with this question rather than hijacking this one. shrug.gif
sorry, it just looked like this was a script help topic.
Sorry again, wasn't trying to hijack it. smile.gif
Seems I don't have a lot of time for adding to this lately. sad.gif
Submit a Thread