How to use Papyrus Fragments

Post » Wed Jun 20, 2012 3:27 am

Okay, i've been using the scripting feature a lot, and one thing I don't understand is how to use fragments. They seem to accept functions and syntax inconsistently to me, and I just don't understand their rules. For example, if I have a script like this:

Scriptname BugTrader extends ReferenceAlias ReferenceAlias Property Insect  Auto ReferenceAlias Property TBJBurke  Auto function giveBug()    TBJBurke.GetReference().AddItem(Insect.GetReference())    Game.GetPlayer().addItem(NewProperty, 500)endFunctionMiscObject Property NewProperty  Auto 

(Trades a bug jar for gold)
What would I type in the corresponding dialogue box's Papyrus Script fragment to get it to run when the NPC says it?
User avatar
x a million...
 
Posts: 3464
Joined: Tue Jun 13, 2006 2:59 pm

Post » Wed Jun 20, 2012 3:58 am

Most of the full script will be hidden to you in the fragment window. The full script is autogenerated, and what you see in the window is just an automatically named function body.
The type of script it is extending, and what 'magic variables' available, will depend on what http://www.creationkit.com/Category:Fragments it is.

So your fragment window for your task above, will just be...
;    TBJBurke.GetReference().AddItem(Insect.GetReference());    Game.GetPlayer().addItem(NewProperty, 500)

Save it, and YES: *** Comment the the code out when you first enter it! ***

If you're using properties that are not available in the standard autogenerated template, then they need to be added before you use them in your code.
So click on the Properties button, and then use the Add button to define the new properties.

Once that is done, you can go back and remove the comment markers, and re-save.
User avatar
marie breen
 
Posts: 3388
Joined: Thu Aug 03, 2006 4:50 am

Post » Tue Jun 19, 2012 11:57 pm

Most of the full script will be hidden to you in the fragment window. The full script is autogenerated, and what you see in the window is just an automatically named function body.
The type of script it is extending, and what 'magic variables' available, will depend on what http://www.creationkit.com/Category:Fragments it is.

So your fragment window for your task above, will just be...
;	TBJBurke.GetReference().AddItem(Insect.GetReference());	Game.GetPlayer().addItem(NewProperty, 500)

Save it, and YES: *** Comment the the code out when you first enter it! ***

If you're using properties that are not available in the standard autogenerated template, then they need to be added before you use them in your code.
So click on the Properties button, and then use the Add button to define the new properties.

Once that is done, you can go back and remove the comment markers, and re-save.

Thanks. Never really thought about commenting it out like that. But I still wonder how to use the function that I made as a saved script from dialogue. Is that not something that can be done?
User avatar
rheanna bruining
 
Posts: 3415
Joined: Fri Dec 22, 2006 11:00 am


Return to V - Skyrim