Equipping misc items and calling on arrays

Post » Mon Apr 04, 2016 12:27 am

Hi!


I'm currently working on a mod where the player writes a diary. I'm planning on doing this by having the player "equipping" inkwells while in certain trigger boxes, and then get a pre-written note from an array based on which trigger box he is in.



I have a quest where I keep my array of notes, and a quest objective for every note. When the player triggers one of my trigger boxes it will display one of the quest objectives. I then have a script added to my inkwells that will read what quest objective is displayed and give the player the proper note.



This is the script I'm using on the inkwells.




Spoiler
Scriptname tstInkwellScriptTest extends ObjectReference



MiscObject Property Inkwell Auto

Quest Property tstQuest Auto

Actor Property playerRef Auto

tstQuestTest Property tstArray Auto

int tstnum



Event OnEquipped(Actor akActor)

if akActor == playerRef

Debug.MessageBox("Hi!")

if tstQuest.IsObjectiveDisplayed(0) == 0

playerRef.RemoveItem(Inkwell)

playerRef.AddItem(tstArray)

tstQuest.SetObjectiveDisplayed(0)

endif

endif

endEvent



Now to my problems:



1. When I activate my inkwell in the inventory nothing happens. I've tried both OnEquipped and OnActivate and can't even get my messagebox. Any idea on how I solve this?



2. I don't really know how to call on my array, let alone specific items in it. I'll post my tiny little array from the quest script for good measure. Can anyone help me?




Spoiler
Scriptname tstQuestTest extends Quest



Book[] Property tstArray Auto



3. I have yet to find a good way to check what quest objective is displayed. I'm thinking that it might be better to use quest stages, but I'm not certain.


Thank you!
User avatar
vanuza
 
Posts: 3522
Joined: Fri Sep 22, 2006 11:14 pm

Post » Mon Apr 04, 2016 3:53 am

My coding is rusty so bear with me. Does this work:



Event OnEquipped(Actor akActor)

playerRef.RemoveItem(Inkwell)

endEvent

Are you sure the inkwell is actually pointing to the inkwell that the player has equipped? Maybe you could use the following to make sure the item that is being pointed to is the correct item:


http://www.creationkit.com/GetEquippedObject_-_Actor


http://www.creationkit.com/GetEquippedItemType_-_Actor


I suggest you test using a vanilla item before inserting your own.

User avatar
Kellymarie Heppell
 
Posts: 3456
Joined: Mon Jul 24, 2006 4:37 am

Post » Mon Apr 04, 2016 12:42 am

1. Is your playerref property filled?



2. Have you checked out these pages on the wiki for arrays? http://www.creationkit.com/Array_Reference, http://www.creationkit.com/Arrays_%28Papyrus%29.%C2%A0 That should help you get started. A formlist may be easier to manage over an array, depending on what you're doing.



E.g.



Scriptname _test_testscript extends Quest

MiscObject[] Property kList Auto ;fill with CK

Function SomeFunction()
Game.GetPlayer().AddItem(kList[0]) ;give the player the first item in the list
endFunction
User avatar
Kaylee Campbell
 
Posts: 3463
Joined: Mon Mar 05, 2007 11:17 am

Post » Mon Apr 04, 2016 8:36 am

1: OnEquip should fire. you'll get the "can't equip..." nag in game though.



2: to fill your array, just fill the property like you'd fill any other: you'll get according buttons to add and remove items to the array. 1st item is "0", not "1"!!!


to call functions on something in your array, go like "MyReference [17].disable ()", so you'd just add ["item n# in array"] and else call it like any other object



since you say you want to spawn messages depending on what trigger box you're in, it might be easier to have the respective trigger boxes do that:


you can put a property for a single note (which will be the one to read) on your trigger base object and individually fill it for any trigger ref (change property in ref's "script" tab), so you can have one script that reads one note and determine which one that'll be per trigger

User avatar
Noely Ulloa
 
Posts: 3596
Joined: Tue Jul 04, 2006 1:33 am

Post » Mon Apr 04, 2016 12:31 pm

Thanks for all the help! I've gotten a basic functionality where I can equip inkwells to recieve notes, and have different notes based on which trigger box I'm in.



I realized that my playerRef wasn't properly filled, so thank you Elias555.



This is my script on my quest for now (thank you Mojo22) :



Spoiler
Scriptname tstQuestTest extends Quest



Book[] Property kList Auto

int property tstnum auto



Function Write()

Game.GetPlayer().AddItem(kList[tstnum])

endFunction





This is the script on my inkwells:




Spoiler
Scriptname tstInkwellScriptTest extends ObjectReference



MiscObject Property Inkwell Auto

Actor Property playerRef Auto

tstQuestTest Property tst Auto



Event OnEquipped(Actor akActor)

playerRef.RemoveItem(Inkwell)

tst.Write()

endEvent






And thanks s7o for the idea of using the individual trigger boxes to decide what note you recieve. I dont think I actually understood exactly how you meant, but what I got works. So this is my script on the trigger boxes:





Spoiler
Scriptname tstTriggerScriptTest extends ObjectReference



int property oldtrigger auto

int property newtrigger auto ;the "name" of the individual trigger box

tstQuestTest property tstQuest auto

Actor property playerRef auto





Event OnTriggerEnter(ObjectReference akActionRef)

if akActionRef == playerRef

oldtrigger = tstQuest.tstnum

tstQuest.tstnum = newtrigger

endif

EndEvent



Event OnTriggerLeave(ObjectReference akActionRef)

if akActionRef == playerRef

tstQuest.tstnum = oldtrigger

endif

EndEvent





I think this might not be the most effective way of doing this, as my game drops in performance when I walk about in my test cell. It works though, so I'm happy!



My next challenge is that I only want notes to be added once. Oblivion had a "DoOnce", so I guess that I will find something similar. I also want some of my trigger boxes to have several notes that you can recieve if you "write" in them more than once, but I guess that will solve itself when I find the "DoOnce"-equivalent in Skyrim. Does anyone know?

User avatar
Heather Kush
 
Posts: 3456
Joined: Tue Jun 05, 2007 10:05 pm


Return to V - Skyrim