Jump to content
Mattiewagg

[Student Thread] Paulibobo - Matthiaswagg

Recommended Posts

Alright. Let's get this started. I believe you have but if you haven't please install the Creation Kit (found under Library>Tools in Steam).
We'll be covering scripting first, as it'll make creation of small and large scriots for use in quests easier, and has a variety of applications not just for quests but also dungeons, NPCs, bosses (unique boss fights), etc.
Now, please read thesetwo tutorials on scripting I linked, if you haven't already. It should help you understand the basics, so what I say should be a little bit comprehensible.   :P
Part 1
Part 2
For scripting, I don't recommend using the built in Creation Kit script editor. It's not all that fun to work with. Especially because if the CK crashes during your writing of a 500 line script, you'll lose all that. If the CK built in editor even lets you write that much. Often it won't. The majority of scripting is done in an exterior program from the CK, except for hooking up your scripts to the game.
Also, syntax highlighting (pretty colors for your code) and auto complete (as you start to write a function or something it'll allow you to autocomplete it, including parameters) and quick compiling will save your life.
So I'm going to highly recommend you install a good text editor for this. Notepad++ and SublimeText 2 are the most well supported editors for Papyrus (Skyrim's scripting language). They're both absolutely free. Sublime Text will ask for you to verify and pay after a free trial, every month or so, but it's not needed to actually pay ever. It's not at all annoying and just a quick Ok every month. I'll briefly outline the pros and cons for you. I'm currently using ST2 though I used NP++ in the past:
Notepad++:
Pros:
- Good support for Skyrim scripting, as well as SKSE functions and SkyUI
- Easy to use
- Nice interface, clean look and good syntax highlighting
- Auto complete is great. Also includes definitions of functions - so it will autocomplete, tell you which mod/script the function is from, what it does (not all definitions are complete but many), and possibly how it's used. This feature is mainly what I miss for NP.
Cons:
- Sort of a pain to set up the quick compiler, which allows you to compile directly from NP++ rather than writing there and then pasting in CK and then compiling there. Note it may just be because I suck really really bad at using the command line/stuff you need to set it up. Some people find it very was, I didnt.
- Can't change color scheme - a few syntax colors to choose from but none radically different
- No extra plugins
Set it up for the CK here: Linky
SublimeText 2:
Pros:
- Super easy to set up
- Support for SKSE, SkyUI, and almost all other SKSE plugins (syntax and autocomplete)
- Changeable color themes
- Autocomplete
- Syntax
- Plugins and more color themes are downloadable with the (free) Package Control. Plugins can be helpful for greater editing of scripts, and color themes are fun to play around with.
Cons:
- Autocomplete doesn't support definitions.
Setup for Sublime Text 2: Linky

I also highly recommend SSE (Skyrim Script Editor). It's newer than the others, but it's got way more features and is easier to set up. It's got all the same features as ST except plugins, and many more:

- Edit existing script
- Create new script from within the editor
- Quick compile with Ctrl+S
- Compilation error/success window
- Filter for opening script with options of "Starts with" and "Contains"
- Auto complete (SKSE support as well)
- Syntax highlighting
- Customization of highlighting colors from within the editor
- Clean, professional look
- Extreme customization of all features
- Easy to use
- Resizable/minimizable code and compilation result windows
- Highlighting of words that are the same as selected
- FileDiff tool to show differences between two scripts
- Bookmarking line feature
- Mark line as green/yellow/red
- Multilanguage support (currently English/French)
- Comment out current line feature
- Line cloning
- Column selecting
- Custom autocompletes
- "Draft" save (save without compiling)
- Code folding
- Macro recording
- Line numbers (toggleable)
- Export to "rtf" or "html"
- Various hotkeys for functions, like Go To Line, Replace, and many more
- Auto update feature or update from within editor (Help>About)
- Online help and support
- Tab functionality, including tab all selected lines
- Copy and paste functionality
- Spellcheck on commented out areas and strings in progress

Whenever you've got that set up, tell me (along with which text editor you've decided to use). Be sure to associate .psc files, which can be found in Data/Scripts/Source with your text editor of choice and when we do begin be sure to create your scripts and then edit by right clicking and selecting Open in External Editor.
Then tell me anything you were confused about on the tutorials and we'll begin from there. I'll explain what was confusing and we'll begin on a task of sorts - your first script. If you have any preference on what you want the script to do (unrelated to quests for now), please tell me. I'll take it into account as a first or later script to do, depending on complexity. Examples are a series of messageboxes w/ choices, a script on an activator to spawn a creature, a trigger box that when entered will disable a wall (or move the wall if we use a hidden door, but it has to contain the animations for this). There are many more, just tell me what comes to mind.

Edited by Mattiewagg
  • reaction_title_1 1

Share this post


Link to post
Share on other sites

Ok, I read the tuturials carefully, but now I encountered a problem. I decided to use SSE, because it seemed to be the one you recomended the most, but after I download it with no problems, I can't launch it. When I try to, it deletes the SkyrimScriptCompilerPro.exe. I've tried repairing it and delting everything and downloaing again, but nothing seems to work. What do I do?

Share this post


Link to post
Share on other sites

Ok, I read the tuturials carefully, but now I encountered a problem. I decided to use SSE, because it seemed to be the one you recomended the most, but after I download it with no problems, I can't launch it. When I try to, it deletes the SkyrimScriptCompilerPro.exe. I've tried repairing it and delting everything and downloaing again, but nothing seems to work. What do I do?

When you run it (the exe) an installer should pop up allowing you to install the program somewhere. Is that not what happens for you?

Share this post


Link to post
Share on other sites

Yea

Ok, I read the tuturials carefully, but now I encountered a problem. I decided to use SSE, because it seemed to be the one you recomended the most, but after I download it with no problems, I can't launch it. When I try to, it deletes the SkyrimScriptCompilerPro.exe. I've tried repairing it and delting everything and downloaing again, but nothing seems to work. What do I do?


When you run it (the exe) an installer should pop up allowing you to install the program somewhere. Is that not what happens for you?

Yeah that happens. But then I install it where it says, and try to open it throught the shortcut that appears on the desktop, (or through the actuall program) and It just does nothing... I'll delte all the files and try again... for the Fifth time...

Share this post


Link to post
Share on other sites

Yea

Ok, I read the tuturials carefully, but now I encountered a problem. I decided to use SSE, because it seemed to be the one you recomended the most, but after I download it with no problems, I can't launch it. When I try to, it deletes the SkyrimScriptCompilerPro.exe. I've tried repairing it and delting everything and downloaing again, but nothing seems to work. What do I do?

When you run it (the exe) an installer should pop up allowing you to install the program somewhere. Is that not what happens for you?

Yeah that happens. But then I install it where it says, and try to open it throught the shortcut that appears on the desktop, (or through the actuall program) and It just does nothing... I'll delte all the files and try again... for the Fifth time...

I'll speak with the author. Just use NP++. It's very strange because it was working for me. I'll test out your issue.

Share this post


Link to post
Share on other sites

After you run SublimeText2 again, go to your Documents folder and open up SublimePapyrus.ini. Make sure all the file paths are correct. If they are, you're all done.

SOmetimes, ST2 may not recognize a Papyrus file. If that is the case, just go to View>Syntax and set it to the proper language (will be called Papyrus or Skyrim).

Share this post


Link to post
Share on other sites

annnnd I apparently did this wrong. I'm sorry. I had installed ST2 before but the latest update had to be installed in a different manner and the instructions in the thread of SublimePapyrus were not updated yet.

They are now. Please delete the Skyrim folder from the Packages folder, and then follow the instructions for loose files here:

http://forums.bethsoft.com/topic/1501719-rel-sublimepapyrus-a-papyrus-package-for-sublime-text-2/

Sorry for the inconvenience. ;)

Share this post


Link to post
Share on other sites

Riddle activator tutorial

Apologies for length, tried to explain thoroughly for this first one at least. Tell me if it's too much or two little so I can adjust the following lessons. When I'm sure you've got a good grasp of scripting,  near the end, I'll have you make this a whole lot more complex so you can see the progress you've made. ;)

EDIT: This one ran incredibly long. Sorry. Still tell me if it was too long or if you prefer this intense level of detail. Again, oops and sorry for the various walls of text. They are important though.

  1. First, we need to create our riddler. This will just be an activator of some sort. I suggest we begin with WETempActivator (open the CK, search in the filter in the category All for WETempActivator). Once you've found it, open up a cell in the Cell View (overview on cell view and other windows). Any cell, just remember the editorID as this is the COC location. Drag the record WETempActivator in after double clicking the cell to open it
  2. Now, we'll create a script. Double click on the WETempActivator IN YOUR CELL VIEW, and DO NOT click the View/Edit Base Object. Instead, keep pressing the right arrow on the little window in the Cell View until you get to Scripts. Press Add, and in the window that pops up, Select [New Script]. Give it a scriptname, and it should extend ObjectReference. Ignore the other parts now, we'll go over those in a later lesson or they may have been covered in the tut you read. If you're curious about the other options, though we will go over most later, feel free to ask.
  3. After you've added your new script, right click it and press Open in External Editor. This should open it in ST2. Paste in the following script (please read it and try to understand, there is an explanation below!):
  4. Scriptname PutTheScriptNameYouChoseHere Extends ObjectReference 
    Message Property RiddleMessage Auto
    MiscObject Property Gold001 Auto
    Spell Property ParalyzeSpell Auto
    Actor Property PlayerREF Auto; if you are going to reference the player more than once, do NOT use Game.GetPlayer but instead use an actor property. It's 1000x faster and best for a variety of reasons to be explained later
    Event OnActivate(ObjectReference akActionRef)       
        Int Choice = RiddleMessage.Show()
        
        If Choice == 0 || Choice == 1; choice first or second choice in list, will be incorrect
        
            ParalyzeSpell.Cast(Self, PlayerREF)
            
        Else;isn't first or second, thus third as we only will define 3 buttons
        
            PlayerREF.AddItem(Gold001, 5000000)
            
        EndIf
        
    EndEvent
    
  5. Pretend this is 4, stupid forum Now I'll explain the script. I'm also going to stop numbering because the forum formatting is stupid.

First off, you've got your scriptname. This is like an editor ID, etc. It's just how your script is identified. The scriptname must be identical to the file name of the script .pex, so make sure you switch out the scriptname in the above script with the one you chose when doing [New Script].

Then we define our properties. You should know what properties are from the tutorials you read earlier - we've got one for our messagebox (type Message); one for our gold (type MiscObject, which is of Book/Armor/Weapon/etc. and is basically an item that doesn't fit into other categories - stuff like little dolls from HF fit into this category); one for our Paralyze spell (type Spell) and one for our player (type Actor, see comment behind colon for explanation why we used that and not Game.GetPlayer - we could have used GetPlayer but wanted to mention this early on).

We will fill these properties after we create the actual things to fill them with.

Then we have our Event. OnActivate is an event sent anytime an activator (container, door, something like WETempActivator, etc.) is activated by ANYTHING. The parameter is a variable that you can access from your script - it's basically info sent along with the event. You don't have to use it but it can often be useful (say doing one thing if the actionRef/thing to activate is the player VS a dog). Everything within our event will be code called when our event is sent. So first, we define a variable of type int (integer = whole number of any type). Because it is defined WITHIN our event, it will ONLY be accessible within that particular event. If I had another event in that script, say OnInit() (called when the object the script is on initializes/loads for the first time), and I tried to access the var Choice, there would be errors. You can declare a variable outside of an event and have it accessible within all events, but if it's declared in one event then it is only accessible in that one event

Now, Message.Show (in this case we replace Message with our Message property) is a function that will show the messagebox or notification that a message property points to. However, it also has a return value. A return value is what value that function gives back when you call it - so you can say THIS VARIABLE = Message.Show, which means that not only will it show the notification, it will ALSO make THIS VARIABLE = to the return value of Show. Show's return value is the choice that the player chose, in the value of an integer. It's a little tricky to get your head around, but once the player chooses a button on the messagebox, the return value will equal the index (explained later when we create our Message) of the button they chose. Using this value, we can do different stuff depending on what the PC chooses. So, we've defined Choice.

We then use conditional phrases (If/ElseIf/Else) to check what the player choice. Firstly, we have If. This means that IF the condition declared after the If evaluates to True, then the code within that If block should be executed. (An If block is from the first If to EndIf. If you have an If/ElseIf thing, then If Conditonal1 is true the first If will be done. Even if ElseIf was also true, only the first If will be chosen. ElseIfs are for multiple choices doing different things. If you want something to happen for everything true, create a set of If blocks.) Our first If condition also uses a LOGICAL OR. A logical or is basically saying If Conditional1 OR Conditional2. So this changes the If - now, if either Conditional1 or Conditional2 is true, then the If will execute. In ours, we check if Choice is 1 or 2. I'll be having the first two buttons be incorrect for you, so this is right. 

Inside that If, we cast the Paralyze spell on the player. Cast is a function to be called on a spell. Calling says that whatever is before the period (.) when you have a function afterwards is what the function is being called on. It's the accusative - if I'm calling Kill ON PlayerREF, that kills the Player. If I'm calling AddItem ON the Donkey, that will add an item to the donkey. The calling reference is not always the same, like with Cast. Cast doesn't have the calling reference as what it should be cast on, but rather what the spell is. So be sure to check (see CreationKit.com). Cast will cast the calling reference (spell) on the person in the second part of the parantheses. These parentheses are parameters that you pass in as direct values or variables. 

The first parameter (must be declared in order, with a small exception) is ObjectReference akSource. Any ObjectReference or type of ObjectReference like an Actor, can be passed in. akSource should equal what is casting the spell. I put in Self because this will say that the activator casts the spell. Self is the value of the reference the script is on in EVERY SCRIPT and does not require variable or property declarations to use. akTarget is what the spell should be cast on. I put in PlayerREF, since I want it cast on the player. (You could also pass in akActionRef but only the Player can see messageboxes so only the player will have this affect them). 

Then we have our Else. An else has no need for clarification with Conditionals. It's just - If nothing else worked out, here I am! So we use Else for if the player chose the correct option, since it's the less likely one here. We call the function AddItem on PlayerREF, to add the item in parentheses to the player. It's parameters are:

(Form akItemToAdd, Int aiCount = 1, Bool abSilent = false)

The little = signs mean it's a default parameter. These will automatically have the value of what is after the = unless you declare otherwise by passing in values. This means you can just ignore them and just pass in akItemToAdd if you're interested. We pass in the form AND the count. The form is our gold, and the count is a random really high number I put in. Then we make sure to close our EndIf block so as not to confuse the engine, and end our event the same way. Compile with Ctrl + B in ST2 and return to the CK.

=============

Ugh. That was real longwinded, sorry.

So, now we need to hook up the properties. This is setting it up for the game world - making these properties actually mean something, because currently they reference nothing and as such will DO nothing.

Let's start with our Message property. Go to Miscellaneous>Message in the Obj Window Filter. Create a new one (always right click>new) and give it a unique editor ID (see Naming Conventions). Ignore title. All you have to be concerned with is ticking Messagebox (else buttons won't work), and the Message Text. Put in what you want your riddle to be here. Example:

What howls when the moon is out and is the only thing as fast as wind?

You can put in whatever you want. Then, create 3 new entries under Buttons. As you can see, each is given an index. This index is what correlates to our int variable Choice. Make sure 0 and 1 are incorrect and 2 is correct, since that's how we set up our script to percieve the buttons (0-1/first and second are incorrect, 2/third is correct). Press OK to save your Message. Now, return to our script. This time, highlight your script and instead of pressing Add or Open in External Editor, press Properties. Now you can fill your properties. Press Auto Fill All at the bottom. This will automatically associate properties that have the same property name as the objects editorID. This can be useful, but if you're going to use a property a lot, keep the name length down to save you from arthritis. :P

Those that don't auto-fill, click on and select the proper thing from the dropdown (sorted by EditorID, begin typing in the ID to skip to that section of the dropdown). ParalyzeSpell can be whatever you want, actually. Just choose any spell from the drop down as I can't currently remember the ID of the spell.

=================

You're all done! Save, load your .esp with your mod manager or launcher and go find your activator. Test it out and tell me what you think.

We'll be having less tutorial like lessons in a little, much shorter, and you'll get a chance to actually make your own first script. I wrote this when I was tired and went on for longer than i needed to, hence the ridiculous length. If the length bothers you tlel me so I can fix it in future lessons. If I miss anything sorry, just tell me and I'll get it fixed so you can get your first script working.

Edited by Mattiewagg

Share this post


Link to post
Share on other sites

I have a problem. I was pressing Ctr+build and nothing happened, and then I went to tools and build was faded out so i couldn't press it. If I select another build system I can try to do Ctr+B, but it jus says [Decode error - output not utf-8]. What can I do about it? (All the rest worked fine btw XD)

PS:I don't care about the length of what you write as long as it's complete and informative.

Edited by Paulibobo

Share this post


Link to post
Share on other sites

Hmm. Make sure the syntax chosen is Skyrim under View>Syntax and you've opened a precreated .psc from within the CK with Open in External Editor.

If that fails reinstall SublimePapyrus and if that fails reinstall ST. If you just want to get it working then just right click Edit/Open Source in the CK and the CK's built in editor will open. You can use that as well (Ctrl+S to compile).

I believe I had a similar problem with ST once. Can you confirm it doesn't work on vanilla .pscs either?

Share this post


Link to post
Share on other sites

Actually, I think you made a mistake. I'm not blaming you, it happens, but in the ParalyzeSpell.Cast(Self, PlayerREF))  you have two parethesis )) and I think that's the problem. Once I removed one, it worked for me. Could that be it? I filled the porpreties, and all that stuff, and it works. I tested all the three dialogue buttons and everything went fine! So what's next? 

Edited by Paulibobo

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×