What is Tamriel Rebuilt?
Yeti is our new Head of Characters (8. Dec 13 18:57)
Aeven is our new Head of Interiors (7. Dec 13 02:05)
gro-Dhal is the new Head of Literature (9. Sep 13 19:07)
Sacred East version 1.5 released! (8. Aug 13 09:40)
Stryker named new Head of Interiors (5. May 13 18:34)
Stryker named Assistant Head of Characters (3. Feb 13 13:54)
2012 in Review (31. Dec 12 13:51)
Our New Head of Characters is Not! Also Int Reviewing Empty! (13. Dec 12 17:56)
Sacred East updated to Version 1.2 (11. Oct 12 10:30)
New Core Shuffle! (7. Oct 12 23:20)
We've been going at it pretty hard so far, so let's take a break - and set the stage for a very simple script, while we're at it.
You should have TESCS open, and just Morrowind.esm (no ESP selected). Open the cell "Vivec, Guild of Mages". (You can zip right to this particular spot in the game through any number of travel merchants, one such being Masalinie Merian in the Balmora Mages' Guild.)
Find the dining room, as pictured:
You should be acquainted with how to create a custom object, so I'll just give you the basic steps for what we need, here. First, hit the Container tab, and make a new container. Give it a suitable ID, and name it "Audrey". For the Art File (NIF) use "f\Flora_corkbulb_01.nif". Leave everything else at the default value.
Now in one of the corners of the dining room, set up a stool, and a planter pot. (I used furn_com_rm_stool_01 and furn_com_planter.) These are both Statics, of course. Now drag a copy of your container, Audrey, into the planter. You'll need to resize your reference of Audrey to fit - I went down to 0.5 in scale.
Now for some scripting. Open up Audrey, and click the ellipses (the "...") next to Script. With the script editor open, go to the Script menu and choose New.
Before we actually begin writing the script, it's best to have an idea for what you want the script to do. This helps you think in advance of how you should phrase your questions and answers, and once you become more experienced, you'll also be thinking ahead of any caveats or loopholes your conditions might imply (for instance, if you have to acquire a certain key to open a certain lock - what if the player loses the key?).
This is going to be a very simple script that helps demonstrate some basic commands, which "test for equality" - that is, they allow you to ask questions that check for whether one thing (usually a number) is equal to another.
So Audrey, the plant, is going to ask a question. The question, in plain English, would be, "Does the player have 3 large kwama eggs?" If the answer is, "No, the player has less than that." then Audrey will complain to the player. If the answer is, "Yes, the player has exactly 3 large kwama eggs." then Audrey will snatch the eggs from the player's inventory, and consume them whole! Or, if the answer is, "Yes, the player has more than 3 large kwama eggs." then Audrey will take four eggs from the player, and eat them. (Audrey is, after all, just a bit greedy.)
Now that you have an idea for the questions you want to ask, and the answers you want to apply, we're faced with the two requirements I stated earlier: can you ask these particular questions or give these particular answers? (Does Script have a method, for instance, for checking a player's inventory? Or a means to remove things from a player's inventory?); and, how do you ask these questions, or phrase these answers?
Before we go digging too deep into Script, to try and find the specific commands and functions we need (to satisfy the first requirement), let's just focus on the second requirement -- how would you phrase the question, and the answers?
All questions use the command "if", which has a rule (syntax) of enclosing the question being asked inside of parantheses. So, the original question, "Does the player have 3 large kwama eggs?" could be written as something like, "if ( player has 3 large kwama eggs )". You're perfectly welcome to use "pseudo-code" when you're first building your script, so in the editor, go ahead and write down exactly that:
begin DS_hw_audrey_sc if( player has 3 large kwama eggs ) end
We also need to begin and end the script, as you've learned, so I wrote those parts down, too. I've named my script "DS_hw_audrey_sc", but you can name yours however you please. I've also used my own particular "style" for whitespacing - I don't use a space between "if" and the first parantheses, but I do include spaces inside of the parantheses, to buffer the question being asked. I use this particular style because it's what looks nicest to me. The style you personally develop and use is simply a matter of taste.
Now, there's an additional rule about the "if" command, which is that you actually begin supplying the answer, to the question asked, on the very next line. To indicate that you've finished your "question-answer block", you finish with the command "endif". So, in our pseudo-code so far:
begin DS_hw_audrey_sc if( player has 3 large kwama eggs ) ... answer goes here ... endif end
It's useful to get into the habit of entering "endif" on the very next line as soon as you write an "if" question, rather than start to write the answer, and when you're done, add the "endif". This is because you will tend to forget to tack on the endif, if you don't get it out of the way first thing. So in the pseudo-code above, I would have written the line, "if( player ..." first, "endif" second, and "... answer ..." last.
You can also see that I've used a tab to indent the "answer" portion of this "question-answer block". This is for readability. It's much easier to identify all of the answer (since it could last several lines) that belongs to this particular question when it's indented. If this still doesn't quite make sense to you, just keep it in the back of your mind. Indentation will probably come very naturally to you, in fact, once you've looked at more code, and written some yourself.
Now what's this "equality" thing I was talking about? Well, when you need to check for whether two particular numbers are equal, or one is greater than another, then you're performing an "equality check". In the case of the question we have so far, we need to determine if "the player's large kwama egg count" is exactly equal to "3". You express "exactly equal to" with the double-equals command (which some would call an "operator"), "==". And yes, it's two equals signs, and there's a good reason for that, too, but you'll just have to take my word on it, for now.
There are a number of different kinds of equality check you can perform, "==" (exactly equal to) is just one of them. The whole list is as follows:
|The content of this site is © by the Tamriel Rebuilt community. Morrowind, Oblivion, their expansions, and their content is © Bethesda Softworks.|