TheFuzzler Posted July 1, 2014 Posted July 1, 2014 (edited) Hi, I'm migrating from the GECK to the creation kit. How do I call a function on a reference? The wiki page is useless at explaining it. The Wiki states that a function is location.function ( params)Where exactly do I state what i'm running the function on?I assumed it may be ref.function (params) but that gives me the error <function> is not a function or does not exist. Here's exactly what I'm trying to do: ScriptName HCRP_ItemManagement extends ReferenceAliasForm VarNewItemint VarWeapType = 0Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)VarNewItem = akBaseItem;; Check if the new item is a weapon and armour or something else.if VarNewItem as Weapondebug.Notification("a Weapon!");; Check what type of weapon was picked up.VarWeapType = akItemReference.GetWeaponType()elseif VarNewItem as armordebug.Notification("an armor!")elsedebug.Notification("I don't know what this is!")endifEndEvent So basically when I pick up an item I want to know what it is. Here's what I've tried:Reinstalling SKSEUsing other SKSE functions Which worked so it's unlikely to be SKSECopying Examples (i can't find them) from the wiki which gave the same error which probably means I'm missing somethingimport WeaponImport formUsing IsDagger or IsWarAxe functionsI think it's something to do with Property references but i'm still not sure how it all ties in. Does anyone have any idea? Any help would be appreciated.Thanks. Edited July 1, 2014 by TheFuzzler
TheFuzzler Posted July 2, 2014 Author Posted July 2, 2014 Okay I found the solution after actually sleeping on it. I was right that it was something to do with property references.So since i'm using ' GetWeaponType' the reference needed to be cast as a weapon as it falls in the weapon script. if i'm using it as a form you won't find the function.Furthermore I needed a variable which is not really a variable but a property which is pretty much just a variable that stores data as a weapon type, which is where the property comes in. The script becomes: ScriptName HCRP_ItemManagement extends ReferenceAliasForm VarNewItemInt VarWeapTypeWeapon Property kNewWeapon autoEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)VarNewItem = akBaseItem;; Check if the new item is a weapon and armour or something else.if VarNewItem as Weapondebug.Notification("a Weapon!")kNewWeapon = VarNewItem as weaponVarWeapType = kNewWeapon.GetWeaponType()debug.Notification("The weapon type is " + VarWeapType as string + "!")elseif VarNewItem as Armordebug.Notification("an armor!")elsedebug.Notification("I don't know what this is!")endifEndEvent
Recommended Posts