[Tutorial] Papyrus for Beginners

Post » Tue Jun 19, 2012 9:50 pm

Hey everyone! I've just published a new Papyrus tutorial on cipscis.com, aimed at beginners who want an introduction to Papyrus.

It doesn't cover everything, but it covers all you're likely to need to know to write simpler scripts, and should hopefully be enough to get you started.

I plan on writing a follow-up tutorial at some point, hopefully in the near future, covering more advanced aspects of Papyrus that I don't talk about in this tutorial, as well as going into more technical detail.

I'd really appreciate any feedback on this. It's not set in stone by any means, and if you think it's unclear or wrong (please tell me if it's wrong, that's the most important thing) or anything, I'd really like to know.

In case you're wondering, I'm hoping to take the feedback and the knowledge I gain from the experience of writing this tutorial and its follow-up to help improve the Creation Kit Wiki's information on Papyrus. While the information is pretty much all there, it can be hard to find and I'd like to help with that. I also like to be able to point to my own explanations of stuff, though, which is why I also like writing tutorials over which I can maintain ownership.

Anyway, here's what I'm sure you're looking for: http://www.cipscis.com/skyrim/tutorials/beginners.aspx

P.S. Thanks a lot to those of you who agreed to proof read this for me prior to its publishing, even if in your particular case life got in the way (as it often does).

Cipscis
User avatar
Rhysa Hughes
 
Posts: 3438
Joined: Thu Nov 23, 2006 3:00 pm

Post » Tue Jun 19, 2012 2:06 pm

Thanks for your efforts :smile: . This kind of things could help everyone, as neither of us read a manual before starting scripting papyrus and there can always be something basic we ignore.

I think you should add at least a little introducion on type casting, as that's something that could potentially ruin the day of any begginer.

EDIT: oops! you have already included casing . I talk too early after taking a quick look at your tutorial :blush: .

Keep the good work :smile:
User avatar
Matthew Warren
 
Posts: 3463
Joined: Fri Oct 19, 2007 11:37 pm

Post » Tue Jun 19, 2012 10:56 pm

It's a good point to raise, though. I intentionally avoided including too much about casting, because I was trying to avoid talking about how scripts are actually new object types and exactly what that means, and I don't think I could go into proper detail on object casting and why it's required without covering that first. I agree with you, I think it's the problem I anticipate readers of this tutorial are most likely to run into and not understand. It's also one of the topics I have noted for the follow-up, though.

In the meantime, I've discussed it a bit in one of my other tutorials - http://www.cipscis.com/skyrim/tutorials/externalaccess.aspx

Cipscis
User avatar
Natalie Taylor
 
Posts: 3301
Joined: Mon Sep 11, 2006 7:54 pm

Post » Tue Jun 19, 2012 3:31 pm

It's a good point to raise, though. I intentionally avoided including too much about casting, because I was trying to avoid talking about how scripts are actually new object types and exactly what that means, and I don't think I could go into proper detail on object casting and why it's required without covering that first. I agree with you, I think it's the problem I anticipate readers of this tutorial are most likely to run into and not understand. It's also one of the topics I have noted for the follow-up, though.

In the meantime, I've discussed it a bit in one of my other tutorials - http://www.cipscis.com/skyrim/tutorials/externalaccess.aspx

Cipscis
Some good examples there. You are fulfilling your autoimposed teacher task flawlessly. No doubt you are helping a lot the modding comunity :)
User avatar
Isabella X
 
Posts: 3373
Joined: Sat Dec 02, 2006 3:44 am

Post » Tue Jun 19, 2012 10:56 pm

Looks great, I appreciate you doing these :)

The part at the end might be a bit confusing, but only because Location is already a script object.
Location.Name(Parameters) --> ScriptFileName.FunctionName(Parameters) ?
(I amost suggested using ScriptName lol)

A lot of new scripters may find that their first bit of papyrus they have to write will probably be a fragment.
Behind the scenes they're the same thing, but the UI hides the magic and then gives not very helpful error messages when they paste in full script code.
It may be worth mentioning that fragments are the 4th type of Function?

BTW, dunno if I ever said thanks for the FNV page and the apple bug. So thanks (again).
User avatar
Lauren Denman
 
Posts: 3382
Joined: Fri Jun 16, 2006 10:29 am

Post » Tue Jun 19, 2012 9:56 pm

Ooh, I'd forgotten about location being an actual place. I'll change it to FunctionLocation, as it's only a script's name if the function is a global one.

Fragments aren't a 4th type of function so much as they're a section of a script that has a generated wrapper. I've kind of intentionally not gone there as I haven't worked with them myself, but I'd originally intended to also explicitly mention that in the introduction and I seem to have forgotten to do that. I'll do a little bit of editing now.

Cipscis

EDIT:

Updated both of those things. The end of the introduction feels a bit like a disclaimer now, but hopefully it'll feel like a useful disclaimer.

Cipscis
User avatar
Phillip Hamilton
 
Posts: 3457
Joined: Wed Oct 10, 2007 3:07 pm

Post » Tue Jun 19, 2012 2:56 pm

Do you write coding help books for a living?! (I used to, sort of, read them for a living and you are better than most I have read).

I think the problem, for non-coders, with tutorials like this is that they struggle to get their head around a concept without seeing it in action.

I don't know if you ever looked at the old wiki ffor the Construction Set? It had a fairly involved Quest and associated things which it stepped through in micro-detail, demonstrating the techniques (and alternate options) to make it all work

Like Dear Old Benbo, but in much better detail, with tech-explanations like yours included.

This is what is desperately needed - and what I hoped Beth would release back on Day-1 - We need a Benbo on Steriods Quest Tutorial that includes a lot of the most common things people want to do (make merchant, add a funky new sword, make a new follower, make some side quests, and so on ...)

That way people understand it AND get something useful at the end of it.

No criticism of your tutorial, that's excellent technical writing - But, at some point, someone (or some ones) need to take the plunge and get a proper detailed tutorial published

(Sadly, like me, I think most everyone is busy with their own stuff ... Which is why I hoped Beth would do a better job than they have)

But again, great work, Cipscis :smile:


(I should note, the CS Tutorial was never finished!) :wink:
User avatar
Stephani Silva
 
Posts: 3372
Joined: Wed Jan 17, 2007 10:11 pm

Post » Tue Jun 19, 2012 10:45 am

I'm at work and don't have the time to look through it right now but I just wanted to give you a big THANKS, because I have been really struggling with trying to understand even the basic concepts of scripting so the more tutorials and documented examples the better for me. I really appreciate it!!!
User avatar
Rebekah Rebekah Nicole
 
Posts: 3477
Joined: Fri Oct 13, 2006 8:47 pm

Post » Tue Jun 19, 2012 11:20 pm

why thanx the more info help on this the better for all of us .. be nice if a library was set up somewhere of code examples to do x (have all the default ones from game but still perusing them). Again thanx.
User avatar
sunny lovett
 
Posts: 3388
Joined: Thu Dec 07, 2006 4:59 am

Post » Tue Jun 19, 2012 10:14 pm

Thanks for writing another tutorial, Cipscis. Critique #1 ...

It would really be helpful to someone who is new to programming/scripting, and in particular new to the object oriented paradigm, to take a sentence or two to define the relationship between objects and their respective functions and how by using the "extends" keyword you are inheriting all of the base functions of that class (type) and then adding (extending) additional functionality.
This may seem painfully obvious to anyone with programming experience, but it's a huge "leap of faith" for someone starting out and if they don't understand the basic concepts they are going to be at a real loss when it comes to more advanced scripting. I do understand that you cannot write a tutorial that encompasses all aspects of programming/scripting, but there are a few concepts that I think need to be fleshed out in programming language tutorials in order to set the reader up for understanding the overall concepts and objerctives.

1) Please take this the way it's meant. Not a bashing of your excellent tutorial, but as an honest critique of what I feel needs to be added to esure the readers understand the basic concepts.
2) I've been coding for about 30 years. I would be happy to run anything you have through the "new player test" to help make things clearer for your readers.
3) Thanks for all the info you have posted on these forums ... the information you have provided on a variety of topics has been instrumental in getting the game to do what I want.

Happy coding,
Dean <<--- my real name ... I hate ^#$% forum handles. lol
User avatar
Alexander Horton
 
Posts: 3318
Joined: Thu Oct 11, 2007 9:19 pm

Post » Tue Jun 19, 2012 8:00 pm

Do you write coding help books for a living?! (I used to, sort of, read them for a living and you are better than most I have read).
No, not even close, but I'm really flattered that you could ask that :blush:

I think the problem, for non-coders, with tutorials like this is that they struggle to get their head around a concept without seeing it in action.
Another project I have planned for after this tutorial's follow-up is to either take one of my own scripts or a script that's already part of Skyrim and go through it line by line, explaining what it's doing and how. When I go through with this, I'll probably do it for a number of full scripts, and it will probably be hosted on the Creation Kit Wiki.

why thanx the more info help on this the better for all of us .. be nice if a library was set up somewhere of code examples to do x (have all the default ones from game but still perusing them). Again thanx.
I agree, and the Creation Kit Wiki would be an excellent place for that.

Thanks for writing another tutorial, Cipscis. Critique #1 ...

It would really be helpful to someone who is new to programming/scripting, and in particular new to the object oriented paradigm, to take a sentence or two to define the relationship between objects and their respective functions and how by using the "extends" keyword you are inheriting all of the base functions of that class (type) and then adding (extending) additional functionality.
I couldn't agree more with you, Dean. This is my #1 priority for the next tutorial. I'd intentionally avoided talking about this here because it's not necessary to understand that for many basic concepts, and a lot of users will not need to know this to write the kinds of scripts they need. I also want it to be fresh in the reader's mind when I'm talking about many of the things I want to talk about in the follow-up tutorial I have planned, like extending your own scripts, global functions and (like my other tutorial) going more in-depth to object casting and accessing functions and properties form other objects.

I certainly see it as very important information, even to a beginner. That's why I wrote one of my other tutorials, "http://www.cipscis.com/skyrim/tutorials/externalaccess.aspx". I expect "function not defined" errors will be the most common source of confusion for readers of this tutorial, and that tutorial was written to deal with that error.

Cipscis
User avatar
Penny Wills
 
Posts: 3474
Joined: Wed Sep 27, 2006 6:16 pm

Post » Tue Jun 19, 2012 8:23 am

Another project I have planned for after this tutorial's follow-up is to either take one of my own scripts or a script that's already part of Skyrim and go through it line by line, explaining what it's doing and how. When I go through with this, I'll probably do it for a number of full scripts, and it will probably be hosted on the Creation Kit Wiki.

If you are willing to put in the time, then this is a great idea. It is exactly what will give those newest to coding (nevermind coding in the CK) the most help. It is always easier for people to follow something being taken apart than to try and teach them to write something from the ground up

Consider taking apart one of the Quests - Step by Step (not MQ!). There are a number of good targets that are simple enough not to make the deconstruction a ridiculous task, but complex enough that they demonstrate much of the stuff many people want to do.

'Grats on your work so far :smile:
User avatar
Marta Wolko
 
Posts: 3383
Joined: Mon Aug 28, 2006 6:51 am

Post » Tue Jun 19, 2012 12:26 pm

Nice idea on this .. another thing that might help is a few more details on the 'default' scripts that are in the game. I've extracted them to look at and seems based on name to have a lot of basic stuff already set up (if I understand them .. no fer sure there), now if could just figure out how ro put a couple of them together. Another one I'd luv an explanation like talking about is the 'critterspwan' scripts ... seem interesting if could only figure them out and how to change (seem to work on the 'c' points setup in the cells to spawn all the wildlife so how can they maybe be used to spawn actor/creatures). Whatever do i'll read as always find yer stuff helpful in knox=cking down some of the ossification in the head.
User avatar
Rachael
 
Posts: 3412
Joined: Sat Feb 17, 2007 2:10 pm

Post » Tue Jun 19, 2012 6:44 pm

Hi Cipscis,
your articles are helping me a lot, thanks.
User avatar
krystal sowten
 
Posts: 3367
Joined: Fri Mar 09, 2007 6:25 pm

Post » Tue Jun 19, 2012 7:07 pm

Cipscis,

I'm learning to mod, and will eventually get to the point where I have to learn how to script. I've made efforts before with NWN and NWN2, but failed due to lack of comprehension.

This guide is excellent for people like me who have a hard time grasping the Greek. 10/10.
User avatar
Harry-James Payne
 
Posts: 3464
Joined: Wed May 09, 2007 6:58 am

Post » Tue Jun 19, 2012 6:05 pm


I couldn't agree more with you, Dean. This is my #1 priority for the next tutorial. I'd intentionally avoided talking about this here because it's not necessary to understand that for many basic concepts, and a lot of users will not need to know this to write the kinds of scripts they need. I also want it to be fresh in the reader's mind when I'm talking about many of the things I want to talk about in the follow-up tutorial I have planned, like extending your own scripts, global functions and (like my other tutorial) going more in-depth to object casting and accessing functions and properties form other objects.

I certainly see it as very important information, even to a beginner. That's why I wrote one of my other tutorials, "http://www.cipscis.com/skyrim/tutorials/externalaccess.aspx". I expect "function not defined" errors will be the most common source of confusion for readers of this tutorial, and that tutorial was written to deal with that error.

Cipscis

Man am I glad to hear this. I believe this would really help me (completely new to scripting). When reading your tutorial the first part that I had issues with was grasping the concept of extending objects. What you wrote was very plain and easy to read but for some reason (learning disorder on my part most likely) my brain had a difficult time putting the pieces together to where I could clearly envision the process. My thought process was something along these lines:

Well extend means to add to (or change) the functionality of a game object and I am able to do that to the five objects listed. When I followed the links for those objects to the wiki, I felt the descriptions of what they are did not provide a clear enough explanation so things started to get hazy or confusing. I felt the information about events and variables made more sense to me. That just seems like a math formula to figure out sort of, but how to identify and determine which object (and exactly what that object is) so I can attach a script I create to change the objects functionality still is sort of confusing to me.

Thanks a bunch for doing these tutorials!
User avatar
W E I R D
 
Posts: 3496
Joined: Tue Mar 20, 2007 10:08 am

Post » Tue Jun 19, 2012 8:55 am

Thank you for this! Can't wait to see the next one.
User avatar
N3T4
 
Posts: 3428
Joined: Wed Aug 08, 2007 8:36 pm

Post » Tue Jun 19, 2012 1:49 pm

Thanks for the praise, everyone! In the 24 hours after I published this tutorial, cipscis.com had about a month's worth of traffic, so this has already been a much greater success than I'd anticipated.

I've started a little bit of work on the first draft of the next tutorial, and thought I'd post my (very brief) notes on what it means to say the Papyrus is "Object Oriented", just because this information is so important.

  • When you create a new script, you are also creating a new type of object with the same name as your script
  • When you attach a script to an object, you are adding the type defined by the script to the object's list of types
  • You can only attach a script to an object if that script extends one of the object's types
  • Native types, like "Form" and "ObjectReference", already exist and are attached to the appropriate objects by the engine. This is what allows you to attach scripts to an object by extending the object's native type.
Inheritance - that extending a script means you inherit its functions and properties - follows from this.

Cipscis
User avatar
Jennifer Munroe
 
Posts: 3411
Joined: Sun Aug 26, 2007 12:57 am

Post » Tue Jun 19, 2012 8:14 pm

That's a really good tutorial. Very helpful as well, explains a lot of stuff that confused me.
User avatar
Loane
 
Posts: 3411
Joined: Wed Apr 04, 2007 6:35 am

Post » Tue Jun 19, 2012 6:05 pm


I think the problem, for non-coders, with tutorials like this is that they struggle to get their head around a concept without seeing it in action.

and

Another project I have planned for after this tutorial's follow-up is to either take one of my own scripts or a script that's already part of Skyrim and go through it line by line, explaining what it's doing and how. When I go through with this, I'll probably do it for a number of full scripts, and it will probably be hosted on the Creation Kit Wiki.

First, let me say thank you Cipscis for everything you've done throughout the years for the community. It's folks like you that inspire relative newcomers such as myself to keep trying to learn and improve our skills (or in my case lack thereof) and to become better modders. You've personally helped me a number of times, and while I know sometimes these things are very difficult for me to grasp, you and many others have helped me with quite a lot of patience. For that I am truly grateful!

I definitely read your tutorials whenever you post something new, and would also like to echo h4events comment in that sometimes I generally understand what you're doing with your script in theory, but don't necessarily know when or how exactly you would use it in the game. What would be helpful to me, and I believe others as well would be to take the scripts that you are explaining, and tell us the scenarios in the game where they would be used.

Thanks again!
User avatar
Alkira rose Nankivell
 
Posts: 3417
Joined: Tue Feb 27, 2007 10:56 pm

Post » Tue Jun 19, 2012 10:35 pm

I have added this to the non-video section of the tutorial list stickied at the top of the forum.
User avatar
Sheila Esmailka
 
Posts: 3404
Joined: Wed Aug 22, 2007 2:31 am

Post » Tue Jun 19, 2012 9:35 am

Thanks G. B. Jackson! I didn't realise there was such a section in that thread. I have another couple of tutorials currently published as well, and I'd be grateful if you'd add them. They can be found listed http://www.cipscis.com/skyrim/tutorials.

@Balok:
I definitely hear you and everyone else asking for more examples. Like I said, the tutorial isn't set in stone. When I next edit it, I'll be sure to add some illustrative examples to each section.

Cipscis
User avatar
Vivien
 
Posts: 3530
Joined: Fri Apr 13, 2007 2:47 pm

Post » Tue Jun 19, 2012 5:56 pm

Thank you for your hard work Cipscis! Your tutorials make the lightbulb go on! :)
User avatar
Vickey Martinez
 
Posts: 3455
Joined: Thu Apr 19, 2007 5:58 am

Post » Tue Jun 19, 2012 10:07 am

Thanks G. B. Jackson! I didn't realise there was such a section in that thread. I have another couple of tutorials currently published as well, and I'd be grateful if you'd add them. They can be found listed http://www.creationkit.com/skyrim/tutorials.

That link points to an empty page on the Wiki.
User avatar
Fiori Pra
 
Posts: 3446
Joined: Thu Mar 15, 2007 12:30 pm

Post » Tue Jun 19, 2012 8:28 pm

What can i say Cip you're the man. I use your sight all the time and I thank you for the assistance you've given me here on the forums. Keep up the great work. I'm sure to link your wisdom and knowledge to others.
User avatar
Margarita Diaz
 
Posts: 3511
Joined: Sun Aug 12, 2007 2:01 pm

Next

Return to V - Skyrim