Jump to content

Recommended Posts

Posted (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 ReferenceAlias

Form VarNewItem
int VarWeapType = 0

Event 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 Weapon
debug.Notification("a Weapon!")
;; Check what type of weapon was picked up.
VarWeapType = akItemReference.GetWeaponType()

elseif VarNewItem as armor
debug.Notification("an armor!")
else
debug.Notification("I don't know what this is!")
endif

EndEvent

 

 

So basically when I pick up an item I want to know what it is.

 

Here's what I've tried:

  • Reinstalling SKSE
  • Using other SKSE functions Which worked so it's unlikely to be SKSE
  • Copying Examples (i can't find them) from the wiki which gave the same error which probably means I'm missing something
  • import Weapon
  • Import form
  • Using IsDagger or IsWarAxe functions

I 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 by TheFuzzler
Posted

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 ReferenceAlias

Form VarNewItem
Int VarWeapType
Weapon Property kNewWeapon auto

Event 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 Weapon
debug.Notification("a Weapon!")

kNewWeapon = VarNewItem as weapon
VarWeapType = kNewWeapon.GetWeaponType()

debug.Notification("The weapon type is " + VarWeapType as string + "!")

elseif VarNewItem as Armor
debug.Notification("an armor!")

else
debug.Notification("I don't know what this is!")
endif

EndEvent

 

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...