Total fail to launch with first script

Post » Thu Aug 08, 2013 1:44 am

Hi all...

So I am here with my tail between my legs as I can't even get the most basic of papyrus scripts to work even though I claim to be an excellent code writer. I find this so rudimentary, that i must apologize in advance for even having to ask this.

1) My first issue is that I cannot find a list of variable properties anywhere. The way I am learning them is by looking at random sample scripts, and that is very slow going. Is there a list anywhere? Although, it seems that the list may just be the object names from the object list in the CK. Is that it?

2) In the GECK days, I could use the menu bar in the CK to Edit -> Find Text -> and search existing scripts for pertinent examples of the functions I wanted to use. The scripts in Skyrim don't seem to be subject to the Find Text menu option. Is there another way to search through papyrus scripts?

3) Now to the nitty gritty...

I am trying to do something so simple; I have created a quest and quest script whose sole function is to check whether the player has a specific book that I created in his inventory. If he doesn't have it, I want to add it, but I can't even get past the inventory check. That's it. So I am trying to use the GetItemCount function like this where the name of the book form is MyBook:

Scriptname TestScript extends Quest  ;Book Property fBook AutoEvent OnInit() ; This event will run once, when the script is initialized;    fBook = MyBook;    If (Game.GetPlayer().GetItemCount(MyBook)==0);    EndifEndEvent

(Note: the semi colons were placed by me to indicate the lines that fail compiling. They are commented out for demonstration purposes only.)

I have added the book and the player as aliases to the quest, yet the lines with semi colons in front of them will not compile. I have tried explicit and implicit referencing for the GetItemCount parameter, both have failed compiling.

Bloody Heck, I say!

User avatar
Star Dunkels Macmillan
 
Posts: 3421
Joined: Thu Aug 31, 2006 4:00 pm

Post » Wed Aug 07, 2013 8:07 pm

The semi colons are terminators. They are used to prevent unwanted code to be run, or to add notes and stuff to codes, without worry of messing the script up. You can terminate a whole block of code(or an entire script) by putting a ; in front of a / and ending the code inside that with a / in front of a ; .

If you want those lines to run, remove the semi colons.

In fact, the first line behind the OnInit() event you placed is an example of the usefulness of the semi colons.

User avatar
Nathan Hunter
 
Posts: 3464
Joined: Sun Apr 29, 2007 9:58 am

Post » Thu Aug 08, 2013 1:28 am

Oh, man... I told you I was a good programmer... I put those semi colons in myself because I could not compile the code without them. They are place holders showing where my code fails. Taking out each one in turn (except for the If and endif, which get removed as a pair), causes the script to fail without explanation. The one caveat being that the line:

Book Propery fBook Auto

will compile, but I had tried to define it explicitly originally by using this instead:

Book property fBook = MyBook Auto

and that line would make the script fail.

User avatar
Jarrett Willis
 
Posts: 3409
Joined: Thu Jul 19, 2007 6:01 pm

Post » Thu Aug 08, 2013 4:05 am

Edit: Nevermind, the guy below me said everything I said better.

I'm gonna stay out of this forum lol.

User avatar
gandalf
 
Posts: 3400
Joined: Wed Feb 21, 2007 6:57 pm

Post » Thu Aug 08, 2013 2:17 am

Spoiler

1) http://skyrim.nexusmods.com/mods/13430/? is outdated, but it is still useful for quickly finding out basic information about Papyrus. You should be able to find most of what you need by using it (most of the entries are hyperlinks to articles on the Creation Kit wiki).

2) I've never heard of such a thing existing in CK, but someone else might have.

3) The lines containing MyBook aren't compiling because MyBook hasn't been defined. What you'll want to do is use the fBook property that you defined, but you need to point the property at the book (or form) you created. You need to open your script's Properties Window and set the value of fBook to be the book you created.

Scriptname TestScript extends Quest  Book Property fBook Auto ;Assign the book you created as the value of this propertyEvent OnInit()    If(Game.GetPlayer().GetItemCount(fBook) == 0)      ;Do your stuff here    EndifEndEvent

If you write scripts that require you to refer to the player a lot, then you should either create an ObjectReference (or Actor, depending on the situation) property called PlayerRef or use Game.GetPlayer() once to assign a value to an ObjectReference (or Actor) variable and use that variable in the rest of the script. That will get you a script with better performance.

If you name a property after the EditorID or ReferenceID, then you can auto-fill the property in the Properties Window of a script.

User avatar
Joe Bonney
 
Posts: 3466
Joined: Tue Jul 17, 2007 12:00 pm

Post » Wed Aug 07, 2013 7:09 pm

Bingo! Thanks a bunch Mr.jack. You've got me on my way. I see now that game objects cannot be be assigned explicitly within scripts, but rather get passed as parameters to the scripts.

User avatar
M!KkI
 
Posts: 3401
Joined: Sun Jul 16, 2006 7:50 am


Return to V - Skyrim