Jump to content

Scripting Problems | When did this stop being simple?


LtMattmoo

Recommended Posts

I consider myself to be a low-level "veteran" modder, having worked with the construction sets since Morrowind, but this new "Papyrus" language seems to have completely thrown me and I'd very much like a hand getting back into this.

 

I'll start with something that should have been simple: How do I get the AddItem function to run within a script? An example and explanation as to why...

Scriptname additemtest extends ObjectReference  

Event OnActivate(ObjectReference akActionRef)
Game.GetPlayer().AddItem(SoulGemGrand, 2, true)
EndEvent

...doesn't work would be brilliant (by doesn't work I mean fails to compile for various reasons depending on which of various different syntaxes I'm trying).

 

If you want to be really helpful, if I can't even get AddItem working I can predict a considerable sum of hurdles to follow and would love someone to walk me through "extensions". I don't understand what they are, what they do or how to work with/around them and the Creation Kit site hasn't helped.

 

Sorry if I seem arrogant. Hours of repetitive programming failure puts me in a bad mood. I do understand that the problem is me and not the new direction that the Creation Kit has taken.

 

Thankyou for your time.

And Thankyou in advance for your help.

 

..Please help me.

Link to comment
Share on other sites

I consider myself to be a low-level "veteran" modder, having worked with the construction sets since Morrowind, but this new "Papyrus" language seems to have completely thrown me and I'd very much like a hand getting back into this.

 

I'll start with something that should have been simple: How do I get the AddItem function to run within a script? An example and explanation as to why...

Scriptname additemtest extends ObjectReference  

Event OnActivate(ObjectReference akActionRef)
Game.GetPlayer().AddItem(SoulGemGrand, 2, true)
EndEvent

...doesn't work would be brilliant (by doesn't work I mean fails to compile for various reasons depending on which of various different syntaxes I'm trying).

 

If you want to be really helpful, if I can't even get AddItem working I can predict a considerable sum of hurdles to follow and would love someone to walk me through "extensions". I don't understand what they are, what they do or how to work with/around them and the Creation Kit site hasn't helped.

 

Sorry if I seem arrogant. Hours of repetitive programming failure puts me in a bad mood. I do understand that the problem is me and not the new direction that the Creation Kit has taken.

 

Thankyou for your time.

And Thankyou in advance for your help.

 

..Please help me.

 

Scriptname _Soul_Gem_test extends ObjectReference  
{Testing Soul gem give.}

SoulGem Property SoulGemGrand auto

Function OnActivate(ObjectReference akActionRef)
       Game.GetPlayer().AddItem(SoulGemGrand, 2, false)
endfunction

 

The thing is, the argument where it asks for what object you want is not asking for an object in game, it's asking for a variable that is connected to the in game object. So this means you need a property that defines that object.

The property can be named anything but as long as you use the same name when calling for it, you should have no problem. The other thing to note is that after you name your property and your script saves, you need to go to the "Properties" tab and name the item you want. Please notice note 1.

http://i39.tinypic.com/fjgpix.png

And what I labeled 2 in the picture can be put in front of your property for the desired item you want. For example:

Weapon Property blahblahblah auto

This will make your property a weapon and therefore can select a weapon in your "Properties" Tab.

more examples:

key Property blahblahblah auto

book Property blahblahblah auto

Now once you are in the properties tab, select your desired property, and edit the value column by pulling the pick "object" tab down. Form there you can select the object you want.

http://i43.tinypic.com/2jc9anl.png

 

Hoped that help,

Joe

Link to comment
Share on other sites

Thanks so much, Joe, that helped a lot. My script's only problem now is that the 'OnSit' Event doesn't occur before opening the craft menu when "sitting" at an Enchantment Table. I believe that's a function limitation, though, which I can probably get around by sticking an 'OnActivate' Event on the Enchantment Table Bases.

 

Now only to work out what the script extensions are for...

 

Thanks again.

Link to comment
Share on other sites

Extensions, from what little I understand, allows you to use events and functions based from the script you've extended.

 

There's more to it than that, but essentially, extending the ObjectReference script for example lets you use Event OnActivate.

 

Most scripts also extend to others, but there's some benefits of using the child script extending a parent script (In most cases, your script extends a major script like ObjectReference or Quest) such as local definitions of functions and events.

 

If I recall the logic right, it is that you change what happens a certain function or event does but only for that script only. That is why when using OnActivate, for example, you can extend ObjectReference in your script or any other script that has Event OnActivate (but ObjectReference seems to be the most common, I think because it encapsulates any object).

 

Fr example Event OnActivate would do something in Script A (say, create an explosion at the object that gets activated), Event OnActivate in Script B would do something different (Creates sheep at the object). Both of them refer to a parent script instead of changing the parent script itself (which may lead to serious consequences). Hope this explains Extensions a bit more.

Link to comment
Share on other sites

  • 6 months later...
Thanks, this has been very helpful so far. How would it look like if I wanted to have a spell that adds an item? In Oblivion all you had to do is add a script effect to a spell and run the additem/ equipitem script in it. Is it all that different in Skyrim? From what I have learned not all that much is different but I get freaked out on the things that are...
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...