Give Player items via Dialogue

Post » Mon Jun 18, 2012 10:40 am

I have tried using

Game.GetPlayer().AddItem(aaaStartKey, 1)

in a dialogue papyrus fragment box, but I always get the error

Starting 1 compile threads for 1 files...
Compiling "QF_aaaStart_010018C7"...
c:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\QF_aaaStart_010018C7.psc(18,25): variable aaaStartKey is undefined
No output generated for QF_aaaStart_010018C7, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on QF_aaaStart_010018C7

EDIT: Typo
User avatar
Inol Wakhid
 
Posts: 3403
Joined: Wed Jun 27, 2007 5:47 am

Post » Mon Jun 18, 2012 2:02 pm

is aaaStartKey an editor ID? If so, it sounds like you don't know about http://www.creationkit.com/Variables_and_Properties in Papyrus yet. You can no longer directly reference editor objects by name.
User avatar
John N
 
Posts: 3458
Joined: Sun Aug 26, 2007 5:11 pm

Post » Mon Jun 18, 2012 12:34 pm

I've just finished writing a short tutorial about this, as it's a very commonly asked question - http://www.cipscis.com/skyrim/tutorials/editorids.aspx

Cipscis
User avatar
K J S
 
Posts: 3326
Joined: Thu Apr 05, 2007 11:50 am

Post » Mon Jun 18, 2012 12:48 am

Yes it is, and oh, okay. Yeah I was used to directly referencing editor objects, like in Oblivion. I'll definitely give that tutorial a read, thank you. :smile:

EDIT: Oh, Cipscis, I didn't see your post there. I'll check it out too. Thanks :)
User avatar
keri seymour
 
Posts: 3361
Joined: Thu Oct 19, 2006 4:09 am

Post » Mon Jun 18, 2012 9:28 am

I read over the tutorials and I'm still confused on what to do, I'm just slow I guess :P Would someone mind breaking it down for me in layman's terms?
User avatar
Nicole Mark
 
Posts: 3384
Joined: Wed Apr 25, 2007 7:33 pm

Post » Mon Jun 18, 2012 9:26 am

exact same problem here... :confused:
i dont understand how to set the things up with the properties / adressing...
i just want to add a key and remove gold from the inventory at the end of a conversation...
User avatar
Natalie Harvey
 
Posts: 3433
Joined: Fri Aug 18, 2006 12:15 pm

Post » Mon Jun 18, 2012 2:15 am

nobody got a clue? :blush:
the wiki was no help for me...
maybe a simple but complete example would be enough...
User avatar
DeeD
 
Posts: 3439
Joined: Sat Jul 14, 2007 6:50 pm

Post » Mon Jun 18, 2012 3:57 am

Scriptname AddKeyTestScript extends ObjectReferenceKey Property keyToGive AutoEvent OnTriggerEnter(ObjectReference akActionRef)    Game.GetPlayer().AddItem(keyToGive, 1)EndEvent

If that was attached to a trigger, then when the player enters the trigger, it would give the key specified.

I don't know anything about dialog though.

And as for choosing what key to give, when you look at the list of scripts on the object, there should be a "properties" button.

Click it, then select the property (In this case, keyToGive) then select what key you want to give the player.
User avatar
Adriana Lenzo
 
Posts: 3446
Joined: Tue Apr 03, 2007 1:32 am

Post » Mon Jun 18, 2012 12:47 am

is aaaStartKey an editor ID? If so, it sounds like you don't know about http://www.creationkit.com/Variables_and_Properties in Papyrus yet. You can no longer directly reference editor objects by name.
I guess that's the price to pay for a more powerful scripting system. Everything takes 10 times as long. :P
User avatar
Andy durkan
 
Posts: 3459
Joined: Fri Aug 03, 2007 3:05 pm

Post » Mon Jun 18, 2012 2:55 pm

Before you write your script, ask yourself "What am I going to need in the script?"

This means ,Actors, objects, anything.

For instance, I'm planning to give my Actor (EditorID: PRBob1) an iron mace (EditorID: IronMace). These are two items. I make a new script, and click properties for that script. I'm going to need two properties: One for the actor, and one for the mace.
So make the two properties, one named Bob for the actor, the other named Mace for the mace. Point the WEAPON property to the IronMace in the dropdown, and the ActorReference proprety to PRBob1.

Now in your script, use the variables Bob and Mace. So Bob.AddItem(Mace,1) or whatever the syntax is.
User avatar
Kelly John
 
Posts: 3413
Joined: Tue Jun 13, 2006 6:40 am

Post » Sun Jun 17, 2012 11:15 pm

Here's another example of how functions can be used:

Scriptname AddMiscItemScript extends ObjectReferenceMiscObject Property itemToGive AutoActor Property itemReceiver  Autoint Property numberOfItems AutoEvent OnTriggerEnter(ObjectReference akActionRef)	if akActionRef == itemReceiver		itemReceiver.AddItem(itemToGive, numberOfItems)	ElseEndIfEndEvent

This allows you to set what item to give (In this case, a MiscObject type item), who to give the item to, and how many of the item to give.

It also checks to make sure that whoever entered the trigger is the one to give the item to.

Granted, it could be changed to work with other things, such as activators, or in your case, dialog.
User avatar
Alyce Argabright
 
Posts: 3403
Joined: Mon Aug 20, 2007 8:11 pm

Post » Mon Jun 18, 2012 12:49 pm

Ok, I think this will work, I'll give it a try. Now do I change the names like itemToGive and whatnot to the editorid, or leave it called itemToGive and whatnot?
User avatar
Ebou Suso
 
Posts: 3604
Joined: Thu May 03, 2007 5:28 am

Post » Mon Jun 18, 2012 5:45 am

Ok, I think this will work, I'll give it a try. Now do I change the names like itemToGive and whatnot to the editorid, or leave it called itemToGive and whatnot?

If you do that, I think you'll be able to use the "auto-fill" option in the property editor - it looks like if your property name matches an existing item's editor ID, hitting auto-fill will automatically assign that item to the property (makes things a little quicker and easier.) I haven't used it enough though to know what the limitations are.
User avatar
Nymph
 
Posts: 3487
Joined: Thu Sep 21, 2006 1:17 pm

Post » Mon Jun 18, 2012 10:50 am

thanks! now i understand how to write the scripts but i have trouble with the fragment sections at the dialogue...

http://picload.org/image/rapicpc/problem.png

If i try to edit the properties with the right name type and value, it refueses them
i would know how to do it as " stand alone" scrpit but not with these fragments... :confused:
so its like to first problem of tomitskee
User avatar
Kate Norris
 
Posts: 3373
Joined: Mon Nov 27, 2006 6:12 pm

Post » Mon Jun 18, 2012 4:18 am

I'm sorry to bother you but I am still so lost. I don't know where to put what scripts or what to replace in which scripts, and I'm sooo confused :(
User avatar
Jah Allen
 
Posts: 3444
Joined: Wed Jan 24, 2007 2:09 am

Post » Mon Jun 18, 2012 7:34 am

http://picload.org/image/rapicpc/problem.png

You're not declaring the property properly. MiscItem isn't even an type of form. You're wanting MiscObject. And ObjectReference is for selecting something in a cell I believe, rather than a set item/actor.

This should work:

MiscObject Property CastleKeyID AutoGetOwningQuest().SetStage(1)Game.GetPlayer().AddItem(CastleKeyID, 1)

Though I haven't tested it.

Also, Tomitskee, what exactly are you confused on? Did you try the wiki?
User avatar
mishionary
 
Posts: 3414
Joined: Tue Feb 20, 2007 6:19 am

Post » Mon Jun 18, 2012 3:15 am

he says this if i try to compile...
i dont know where the problem is i tried this so many times... :blush:

Starting 1 compile threads for 1 files...Compiling "TIF__0100374D"...c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__0100374D.psc(9,20): no viable alternative at input 'CastleGhoulSteinKey2'No output generated for TIF__0100374D, compilation failed.Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on TIF__0100374D

with this in the fragment:

GetOwningQuest().SetStage(1)Game.GetPlayer().AddItem(CastleGhoulSteinKey2, 1)

and this as propertie:

MiscObject Property CastleGhoulSteinKey2 Auto

it seems like he can't find the key but i tried it with Gold001 and i got the same problem...

besides is it true that i only have to write this in the "End: Papyrus Fragment Box " without declaring these additional Properties? or do i have to add them like in a normal script?
nevertheless this didn't work even with the properties set right...

and thanks for your time
User avatar
Dan Scott
 
Posts: 3373
Joined: Sun Nov 11, 2007 3:45 am

Post » Mon Jun 18, 2012 12:49 pm

Also, Tomitskee, what exactly are you confused on? Did you try the wiki?
Yeah, and I tried what you guys are saying aswell. But IDK where to put these scripts, what to change in them, and stuff like that.
User avatar
Ernesto Salinas
 
Posts: 3399
Joined: Sat Nov 03, 2007 2:19 pm

Post » Mon Jun 18, 2012 9:04 am

the additem still doesn't work... i'll show step by step how i've tried it because i'm struggeling nearly 3 days with this...:

###################

Step1:
i wrote the script in the "Fragment Box"...

http://picload.org/image/rappgil/1.png


Step2:
i clicked on properties and added[ Type: miscObject name:refItemKey value:CastleGhoulSteinKey2"the ID" ]
this window poped up...

http://picload.org/image/rappgip/2.png


####################

there is no typo at value:CastleGhoulSteinKey2...

plz help me with this... :(
User avatar
Amelia Pritchard
 
Posts: 3445
Joined: Mon Jul 24, 2006 2:40 am

Post » Mon Jun 18, 2012 9:11 am

Yeah, and I tried what you guys are saying aswell. But IDK where to put these scripts, what to change in them, and stuff like that.
Did you read follow the tutorials on the wiki? Those should give you a good starting point.
User avatar
Roberta Obrien
 
Posts: 3499
Joined: Tue Oct 23, 2007 1:43 pm

Post » Mon Jun 18, 2012 8:52 am

the additem still doesn't work... i'll show step by step how i've tried it because i'm struggeling nearly 3 days with this...:

###################

Step1:
i wrote the script in the "Fragment Box"...

http://picload.org/image/rappgil/1.png


Step2:
i clicked on properties and added[ Type: miscObject name:refItemKey value:CastleGhoulSteinKey2"the ID" ]
this window poped up...

http://picload.org/image/rappgip/2.png


####################

there is no typo at value:CastleGhoulSteinKey2...

plz help me with this... :(

in that second image, theres a "add property" button you need to use to make a reference to the key, in the new window that pops up drop down the list for TYPE and select key, then enter the ID of the key into the name field, by using the same name as the item it should be able to automatically set the right value, but if doesn't you can always go back to that property window and set the value to match the key's ID manually
User avatar
Iain Lamb
 
Posts: 3453
Joined: Sat May 19, 2007 4:47 am

Post » Mon Jun 18, 2012 2:24 am

the additem still doesn't work... i'll show step by step how i've tried it because i'm struggeling nearly 3 days with this...:

###################

Step1:
i wrote the script in the "Fragment Box"...

http://picload.org/image/rappgil/1.png


Step2:
i clicked on properties and added[ Type: miscObject name:refItemKey value:CastleGhoulSteinKey2"the ID" ]
this window poped up...

http://picload.org/image/rappgip/2.png


####################

there is no typo at value:CastleGhoulSteinKey2...

plz help me with this... :(
It's really easy. When you did Items > Key > Created a new key...you have to IGNORE this editor ID in scripting.

Type this in the fragment..."Game.GetPlayer().AddItem()" then click on the "TIF__..." > PROPERTIES > ADD PROPERTY > Type: Key, Name: myTestKey > OK > Click myTestKey > Edit Value > Now select the key you created (CastleGhoulSteinKey2?).

Now fill in AddItem > Game.GetPlayer().AddItem(myTestKey, 1)

Press Compile.
User avatar
Latisha Fry
 
Posts: 3399
Joined: Sat Jun 24, 2006 6:42 am

Post » Mon Jun 18, 2012 6:40 am

thanks stardog it works!!!!
and of course thank you all for your help! :biggrin:
User avatar
amhain
 
Posts: 3506
Joined: Sun Jan 07, 2007 12:31 pm


Return to V - Skyrim