Jump to content

Please help me get this simple script working


irswat

Recommended Posts

It is my first script and there are some concepts in CK that I don't really understand much: how to properly use selfRef and the precise meaning of script extends x. The script is a time check for dawnfang/duskfang. It is attached to the swords. Between 6 am and 5:59 pm the sword becomes dawn fang. At 6 pm the sword becomes duskfang.

here is the script. Please help me get it working!

  Reveal hidden contents

Edited by irswat
Link to comment
Share on other sites

  • Replies 135
  • Created
  • Last Reply

Top Posters In This Topic

Typically a script on an object will extend the script for that object type. So a script on a placed object will extend ObjectReference, a script on a quest will extend Quest. However, there is more to it than that. What the extends really does is allow the current script to use events/functions from the script being extended as if they were the same script. This is how MCM scripts can work. A mod's MCM script extends upon a base script in SkyUI's framework thus allowing the mod's MCM script to run functions and events without having to directly call the other script first.

 

I would not refer to the player as selfRef. It gets confusing as 'self' refers to the object running the script. Use PlayerRef instead. Also, you keep casting it as an actor. It would be better to simply start out with the variable as an actor instead of an ObjectReference. But for this script it isn't even needed as the OnEquipped event contains an actor variable which passes into the script the actor that equipped the item.

 

Furthermore, I'm not even sure if you can call EquipItem from an item in the inventory. You may need to consider using a player alias script to handle this.

 

At any rate, here is a much shortened version which would do the exact same thing, provided that EquipItem does work from an object in an inventory. And following, after the comment marks, is a player alias version if you'd like to try that instead.

 

  Reveal hidden contents

 

FYI - spaces are your friend. There is no benefit to removing all the spacing in a script.

 

And you changed your script from what you originally posted... So some of what I said, might not make sense now to anyone who follows along.

 

 

Link to comment
Share on other sites

thanks. You're right the script was changed.

  Reveal hidden contents



It's like I'm not using the right script extend x, or event, because the debug message displaying time of day isn't playing, and that isn't a conditional statement. I'm going to try using your OnEquipped (actor akActor) event to see if that works.

Edited by irswat
Link to comment
Share on other sites

OnLoad triggers when the object's 3d is loaded, so while in inventory it won't, i don't its the appropiate event for this. Indeed go for onequipped.

 

And extend objectreference, not weapon, both OnLoad and Onequipped belong to objectreference so that's what you'd want to extend.

Link to comment
Share on other sites

Thank you both very much! The script is working. Any idea why the sound effect won't play?

I created a sound descriptor with the wav, and a sound marker that points to the descriptor, which I declared as a property in the script.

  Reveal hidden contents

Edited by irswat
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...