Script Help - Notifications

Post » Tue Jun 19, 2012 10:13 am

Hi,

I have a mod where I have some preplaced items (1 necklace on a counter, 1 in a locked box, 1 key, 3 books) that when the player picks them up, I would like to have a notification displayed in the upper left corner of the screen.

A simple "XYZ has been added" message will suffice.


I have attempted to look at similar items in other cells (other keys laying on a table) and observe their scripts. I have placed those same scripts from the available selections on my game items, but do not receive any notification.
I cannot seem to find any sample code anywhere for this simple, generic message, nor any step by steps in creating one from scratch.


Can someone please point me in the right direction or perhaps provide the script code in question if it is common knowledge? This is my first foray into scripting so I don't know all the helpful sites etc.


Thanks!
User avatar
Casey
 
Posts: 3376
Joined: Mon Nov 12, 2007 8:38 am

Post » Tue Jun 19, 2012 5:31 pm

after the pertanent code adding the item to the player

Debug.Notification("MyObject added to Player") <- this prints MyObject added to player to the screen.

Debug.MessageBox("MyObject added to Player") <- this open a messagebox that says MyObject added to player. You must click OK to close the messagebox.
User avatar
Mike Plumley
 
Posts: 3392
Joined: Wed Sep 05, 2007 10:45 pm

Post » Tue Jun 19, 2012 1:44 pm

Okay, I'm not even sure what to do with that.

I'm off to try and make sense of it. I'm real new to this.

Thank you!!!
User avatar
Mariaa EM.
 
Posts: 3347
Joined: Fri Aug 10, 2007 3:28 am

Post » Tue Jun 19, 2012 4:13 pm

When I am adding Properties to the script, what Type would this kind be?
User avatar
Joe Alvarado
 
Posts: 3467
Joined: Sat Nov 24, 2007 11:13 pm

Post » Tue Jun 19, 2012 10:46 am

You can use the http://www.creationkit.com/OnContainerChanged_-_ObjectReference event to catch when the player has added items to their inventory--in a script on your item, have something like this:

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)  if akNewContainer == Game.GetPlayer()	Debug.Notification("XYZ has been added.")  endIfendEvent

Note that will trigger if the player stores or drops, and then picks up, the item again, so for anything important that can only happen once, you'd want to set a variable the first time it is picked up, and then check that variable on subsequent container changes.
User avatar
Kit Marsden
 
Posts: 3467
Joined: Thu Jul 19, 2007 2:19 pm

Post » Tue Jun 19, 2012 6:54 pm

Thank you! I had seen that in the CK wiki, but wasn't sure the player's inventory qualified as a container.

Let's say I want this to only happen with the 1 key I have placed... since the keys cannot be dropped by default, perhaps the addditional checks for subsequent drops are not needed...


Gonna fiddle... thank you so much guys!
User avatar
Nikki Hype
 
Posts: 3429
Joined: Mon Jan 01, 2007 12:38 pm

Post » Tue Jun 19, 2012 2:36 pm

You can use the http://www.creationkit.com/OnContainerChanged_-_ObjectReference event to catch when the player has added items to their inventory--in a script on your item, have something like this:

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)  if akNewContainer == Game.GetPlayer()	Debug.Notification("XYZ has been added.")  endIfendEvent




I cannot figure this out.

Does akOldContainer need to be identified or is it any container that this one item is pulled from? In my case, this Key is not in a container, but out on a counter in the cell.
I have attached the script to the physical key in the render window, but I am at a loss as to why it wont fire the message.

Would screenshots of my windows help?
User avatar
Soph
 
Posts: 3499
Joined: Fri Oct 13, 2006 8:24 am

Post » Tue Jun 19, 2012 9:13 am

Posting your exact code and/or screenshots is always a help, yes.

You only need to be concerned with akOldContainer if you want to do different actions depending on where it came from. In the case of your key, it doesn't sound like it matters: you know where it is coming from, and once the player picks it up, they won't be able to drop it.
User avatar
Amber Ably
 
Posts: 3372
Joined: Wed Aug 29, 2007 4:39 pm

Post » Tue Jun 19, 2012 2:32 pm

In the case of your key, it doesn't sound like it matters: you know where it is coming from, and once the player picks it up, they won't be able to drop it.

Indeed. That describes it perfectly.



Okay!

The exact code I am using is:


Scriptname AddingKeyToPlayer extends ObjectReferenceReference Property AmuletsQuestItems AutoInt Property StageToSet AutoEvent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)  if akNewContainer == Game.GetPlayer()		Debug.Notification("Rorlund's Strongbox Key has been added")  endIfendEvent 


I've probably overlooked something completely stupid. My apologies.

Here are the windows in question:

http://i.imgur.com/BdVlQ.jpg
User avatar
Scarlet Devil
 
Posts: 3410
Joined: Wed Aug 16, 2006 6:31 pm

Post » Tue Jun 19, 2012 11:08 am

I'm all set folks. A kindly stranger by the name of LG worked me through this arduous and painful process in the CK group chat...


http://i.imgur.com/7VHME.jpg


:foodndrink:
User avatar
Miragel Ginza
 
Posts: 3502
Joined: Thu Dec 21, 2006 6:19 am


Return to V - Skyrim