Standing Stone Activation Add item

Post » Sat Nov 17, 2012 7:35 pm

Hi. I was wondering if it is possible to have the player activate a standing stone and the stone gives the player an item in their inventory. If it is possible could someone give me a scripting example please. Thank you so much!
User avatar
Shiarra Curtis
 
Posts: 3393
Joined: Thu Jan 04, 2007 3:22 pm

Post » Sat Nov 17, 2012 1:10 pm

I'm going to assume you have no knowledge of scripting for posterity.

In the Creation Kit's scripting there are different "events" which, as you can tell by the name, are triggered by certain actions by the player. For what you're asking, the OnActivate event - when the player activates the object the script is attached to - will work perfectly.

The next bit are the "properties", which are - again, as the name aptly suggests - are objects the script has access to. I will touch on how to set up properties correctly later. For now, the code for adding an item when a player activates an object.

Scriptname czAddGold extends ObjectReference ;This tells the engine some stuff that isn't very important at the moment.                                             ;If you want to learn more about what all this means, look on the wiki. :)MiscObject Property czGoldCoin Auto ;Gold coins are now a property of this script.Event OnActivate(ObjectReference czUser) ;Everything between here and EndEvent will be processed when the object's activated.    game.getplayer().additem(czGoldCoin, 100) ;Look familiar? This is very similar to the console command additem.                                              ;This simply adds 100 gold coins to the player's inventory.EndEvent
I hope the code and my comments helped you understand what is going on. Now, as I said earlier, the property isn't exactly "correctly" set up with just this code attached to an object. If you ran this and used the object it's attached to it would not give you any gold. Oh no! Don't worry though, it's simple to get the desired effect. Find the object you attached the script to and then find the button that says "Properties" under add/remove script (I believe). You'll see our beautiful variable czGoldCoin all alone, with no value attached to it. Let's help a girl out (variable genders are a separate topic that need not be discussed) and click her. You'll see a drop down menu and find Gold001. There we go, now the script knows where Gold001 is and can properly give it to the player.

Again: Hope this helps! Don't hesitate to ask questions, the worst kind of coder is the one who doesn't ask any!

*When I say object it can be anything from a Standing Stone to a Dwemer Cog. Object is a general term to describe something that exists in the game.
**I wrote this all from memory. There may be some discrepancies, but hey, if you want to get into scripting (which you may not, now that I think about it :P) then problem solving is the name of the game.
***Variables don't have genders. Thankfully programming isn't Romantic - I find most programmers aren't either! Zing!
User avatar
Taylah Haines
 
Posts: 3439
Joined: Tue Feb 13, 2007 3:10 am

Post » Sat Nov 17, 2012 9:34 pm

I have very little experience scripting and I am trying to figure out how to make a script to let the player select two stones. One of the stones will give the player add an item in their inventory.

Can someone help me figure out how to
1. Let the player pick 2 out of 3 standing stones to activate
2. Script one standing stone to add a created item to the player's inventory upon activation
User avatar
Krystina Proietti
 
Posts: 3388
Joined: Sat Dec 23, 2006 9:02 pm

Post » Sat Nov 17, 2012 11:11 am

Bump. i could really use some help. If someone doesn't mind giving me an example.
User avatar
Chris Cross Cabaret Man
 
Posts: 3301
Joined: Tue Jun 19, 2007 11:33 pm

Post » Sat Nov 17, 2012 6:05 pm

Let me make sure what you are asking: you plop down three Standing Stones, and allow the player to select two of them. If he selects the right one, he gets an item, and if he doesn't, he gets one more try. Then if he misses that try, he's SOL. Correct?

Int property MyIndex AutoWeapon property MyWeapon AutoActor property Player AutoGlobalVariable property NumTries AutoEvent OnActivate(ObjectReference akActionRef)	If akActionRef == Player			If NumTries.GetValue() == 0					Debug.Notification("Nothing happens")					Else					If MyIndex == 1							Debug.Notification("Correct!")				Player.AddItem(MyWeapon, 1, false)				NumTries.SetValue(0)							Else							Debug.Notification("Incorrect")				NumTries.SetValue(NumTries.GetValue() - 1)							EndIf					EndIf			EndIf	EndEvent

Attach that script to the three Stones you want to use, and assign the Int property there to either 1, 2, or 3 for each one to uniquely identify them to each instance of the script.
User avatar
Kevin S
 
Posts: 3457
Joined: Sat Aug 11, 2007 12:50 pm

Post » Sat Nov 17, 2012 4:55 pm

Opps I guess I worded it wrong. I wanted to have three standing stones, two with a spell and one with an item attached. I wanted the player to be allowed to only pick 2 of the 3 stones. Once the player selected his second choice of a stone, I wanted the last stone to be disabled.
User avatar
Spaceman
 
Posts: 3429
Joined: Wed May 23, 2007 10:09 am

Post » Sat Nov 17, 2012 12:05 pm

Oh, in that case...

Int property MyIndex AutoWeapon property MyWeapon AutoSpell property MySpell AutoSpell property MyOtherSpell AutoActor property Player AutoGlobalVariable property NumTries AutoEvent OnActivate(ObjectReference akActionRef)        If akActionRef == Player                        If NumTries.GetValue() == 0                                        Debug.Notification("Nothing happens")                                        Else                                        If MyIndex == 1                                                        Debug.Notification("Stone 1 selected")                                Player.AddItem(MyWeapon, 1, false)                                NumTries.SetValue((NumTries.GetValue() - 1)                                                        ElseIf MyIndex == 2                                                        Debug.Notification("Stone 2 selected")                                Player.AddSpell(MySpell, false)                                NumTries.SetValue(NumTries.GetValue() - 1)                        ElseIf MyIndex == 3                                                        Debug.Notification("Stone 3 selected")                                Player.AddSpell(MyOtherSpell, false)                                NumTries.SetValue(NumTries.GetValue() - 1)                                                        EndIf                                        EndIf                        EndIf        EndEvent

Give the NumTries Global a default value of 2. Every time the player activates a Stone and NumTries is not already 0, the player will get either a Weapon or a Spell and NumTries will be reduced by 1. After two Stones are selected, NumTries becomes 0 and the stones will cease to function.
User avatar
ZzZz
 
Posts: 3396
Joined: Sat Jul 08, 2006 9:56 pm

Post » Sat Nov 17, 2012 7:23 pm

omg Thank you so much! This is going to be very helpful! You are awesome!
User avatar
Kat Lehmann
 
Posts: 3409
Joined: Tue Jun 27, 2006 6:24 am

Post » Sat Nov 17, 2012 4:30 pm

I was trying to set the value of the Global Variable to 2 but it doesn't give me the option to set a value. It keeps asking to pick an object.
User avatar
Monika
 
Posts: 3469
Joined: Wed Jan 10, 2007 7:50 pm

Post » Sat Nov 17, 2012 7:43 pm

I am having another issue. When I try to put the script on each stone it compiles but when I go to play the game, the stones are not activating at all. Its seems like the player cannot activate any of the stones. Please advise anyone!
User avatar
Motionsharp
 
Posts: 3437
Joined: Sun Aug 06, 2006 1:33 am

Post » Sat Nov 17, 2012 3:47 pm

Did you actually setup the GlobalVariable, NumTries, as an object in the CK?

http://www.creationkit.com/Globals

(I think globals are under miscellaneous items ... or maybe World Data ... in the CK - My CK is not open to check)

Other than that, as far as I can tell the scripts should work (as well as compile)
User avatar
Robyn Lena
 
Posts: 3338
Joined: Mon Jan 01, 2007 6:17 am

Post » Sat Nov 17, 2012 7:22 am

Thank you so much! took me a while but I was able to figure it out! Thanks for everything!
User avatar
Madison Poo
 
Posts: 3414
Joined: Wed Oct 24, 2007 9:09 pm


Return to V - Skyrim