Dupre232 Posted June 4, 2013 Share Posted June 4, 2013 Hello, I'm having some trouble putting together a script and was wondering if someone could help me out. I'm using the Altar of Molag Bal furniture piece which is successfully running a script that casts a spell on the player and triggers a sound. Problem is that as a two-state object, this script runs twice - once when I activate the altar (animation is automatically triggered), and another when I hit a key to end the animation and exit the altar. I'd rather it only run once when the altar is first activated (though it would be nice to trigger a second sound upon exiting, too). I noticed a script already in the CK called default2stateactivator which, judging by its notes, seems like what I need to do, but I can't apply it to my script properly. Here's my script, just a spell and sound: Scriptname MolagAltarScript01 extends ObjectReference Event OnActivate(ObjectReference akActionRef) MolagSpell01.Cast(akActionRef, akActionRef) if akActionRef == Game.GetPlayer() MolagSound01.Play(self) endif EndEvent Sound Property MolagSound01 Auto SPELL Property MolagSpell01 Auto If anyone can help, I'd be very grateful! Link to comment Share on other sites More sharing options...
pmmurphy Posted June 4, 2013 Share Posted June 4, 2013 Hey, your missing alot of information in order for me to help you. I have never done a script for a bethesda title, but i do know how to program. I can help you with psuedo code and generate potential ideas for you to implement if you can't get help from anyone else. I just ask for you to help me, help you. You said you found a script that does what you want, well what is the script? Please copy paste the source code here and its description so i can look at it. I am alittle shakey about your definition of a 2-state object. I would like you to fully explain exactly what a 2-state object is in a way that i can understand how to go about manipulated code that affects it. It is highly important when asking help with technical questsions to put all the information required to assist you in one post and don't assume we know everything ahead of time. Some might, but by doing this you weed out many potential candidtates who can and may very well solve your problem. Last thing i want you to do. Even though i understand your script. Please elaborate on your script and explain to me why you wrote it the way you did and what it does and how it affects the game itself. Why did you implement your script the way you did and why did you choose to do it? When does your script run? Why does it run the way you choose? Did you consider multiple ways to implement this script? Last but not least, what resources do you have to work with? When asking help on technical problems it is best to put all your details and information in one location. This helps the human mind with processes as we don't have to open up many screens or look at different places. Everything is put in one well thought-out post. When you are able to look at everything in one sitting your ability to problem solve increases exponentionally compared to having to open up many seperate problems and web sites. Also you shouldn't expect everyone to know your script as good or better then you. Its your script, not ours. Explain it, explain your approach, then explain your execution. Often times other programmers will tell you to reprogram your script because they don't like how you did it. But that doesn't make their approach any better than yours. Link to comment Share on other sites More sharing options...
stschwarz Posted June 4, 2013 Share Posted June 4, 2013 Hi, try this: Scriptname MolagAltarScript01 extends ObjectReference Auto State waitForPlayer Event OnActivate(ObjectReference akActionRef) if akActionRef == Game.GetPlayer() MolagSpell01.Cast(akActionRef, akActionRef) MolagSound01.Play(self) GotoState("hasBeenActivated") endif EndEvent EndState State hasBeenActivated ; nothing to do here EndState Sound Property MolagSound01 Auto SPELL Property MolagSpell01 Auto Link to comment Share on other sites More sharing options...
Dupre232 Posted June 4, 2013 Author Share Posted June 4, 2013 (edited) Hi pmmurphy, thanks for your reply. I wrote that post at about 3 AM, so I wasn't very thorough at all, my apologies. I was mostly hoping someone who had experience with a script like this would pop in (like stschwarz did). I know how to program a little but as you can see, not very well. I've been dabbling with various languages since the 80s, but I've always been terrible with it and often find it counter-intuitive to the way my mind works (I'm a musician, maybe that has something to do with it). So instead, I specialize in hardware instead of software. =) I'm also fairly new to modding Bethesda titles so I'm not positive on this, but I'm pretty sure a 2-state activator is used for objects with which the player's interaction will have 2 states, unlike most objects that only fire once. An example of this is the Altar of Molag Bal. If you place a new copy of the altar's furniture piece somewhere and try it out in the game, you'll notice that on the first interaction, your character will go into an animation (the first state) which will not end until you hit another key, breaking the animation (second state). When you apply a basic script like mine without controlling the two states, the script will run twice (one during each state) which is usually not something the user wants. I could be completely wrong about my example being a 2-state activator, but it seems logical and makes sense given the testing I've done. I'm off to try stschwarz's script and if it doesn't function the way I need, I'll come back to go into more details, as you suggested. Thanks again for your reply! ------------- Hi stschwarz, thanks very much for the script! I'm off to try it and will post back with my results. Edited June 4, 2013 by Dupre232 Link to comment Share on other sites More sharing options...
Recommended Posts