YesNo on lever use

Post » Tue Jun 19, 2012 8:58 pm

Hey Modders,

my problem is pretty easy in theory. I want a message to pop up on the use of a lever saying something along the lines of "using x,y will make a,b happen. are you sure you want to do that?" and then a Yes or No inputbox. (proceed on yes, nothing happens on no)

Can anyone give me a helping hand here?


Cheers


Its just a messagebox + if action yes=true execute. But i dont know how to do it correctly.
User avatar
~Amy~
 
Posts: 3478
Joined: Sat Aug 12, 2006 5:38 am

Post » Wed Jun 20, 2012 9:40 am

You need to make a message and attach the message to the script through the properties on the Lever.
The message needs 2 menu button indexes, a 'Yes' and a "No'.

The script you put on the lever: (no animation, but should get you started)

Scriptname myLeverQuestionScript extends ObjectReferenceMessage Property MesgQuestionBox1  Autoint Buttonint myStateEVENT onActivate(objectReference akActionRef)If akActionRef == Game.GetPlayer()  if myState == 0   button = MesgQuestionBox1.show()   if Button == 0	myState = 1	Debug.messagebox("Answered yes")   elseif Button == 1	Debug.messagebox("Answered no")   endif  else   Debug.messagebox("Already answered yes")  endifEndIfendEVENT
User avatar
Leonie Connor
 
Posts: 3434
Joined: Mon Mar 12, 2007 4:18 pm

Post » Wed Jun 20, 2012 5:04 am

This is a heavily modified version of the script NorLever01SCRIPT, and should play the animations correctly:

Spoiler
scriptname MyLeverScript extends ObjectReferencebool property isInPullPosition = True Automessage property MessageProp autoEvent OnLoad()    SetDefaultState()EndEventEvent OnReset()    SetDefaultState()EndEventFunction SetDefaultState()    if (isInPullPosition)        playAnimation("FullPull")    Else        playAnimation("FullPush")    EndIfEndFunctionAuto State Idle    Event OnActivate(ObjectReferece akTriggerRef)        int choice = MessageProp.Show()        if (choice == 0)    ;the first choice, assumed to be 'yes'            GoToState("Busy")            PullLever()        else            ;do nothing        endif    EndEventEndStateState Busy    Event OnActivate(ObjectReferece akTriggerRef)        ;do nothing    EndEvent    Function PullLever()        if (isInPullPosition)            isInPullPosition = false            playAnimationandWait("FullPush","FullPushedUp")        else            isInPullPosition = true            PlayAnimationAndWait("FullPull","FullPulledDown")        endif        GoToState("Idle")    EndFunctionEndState
User avatar
Cayal
 
Posts: 3398
Joined: Tue Jan 30, 2007 6:24 pm

Post » Tue Jun 19, 2012 8:15 pm

Does this work anological for a valve based on:


scriptName DwePipeValve01SCRIPT extends ObjectReference

bool property bidirectional = False Auto
{Should the valve alternate directions with each activation? Default: False}

bool flip = False

Auto STATE Waiting
EVENT onActivate (objectReference triggerRef)
self.BlockActivation(true)
if (flip)
playAnimationandWait("trigger02","Trans02")
Else
playAnimationandWait("trigger01","Trans01")
EndIf
flip = !flip
self.BlockActivation(false)
endEVENT
endState

?

Thanks for your answers anyways. Really appreciate your help!
User avatar
Lovingly
 
Posts: 3414
Joined: Fri Sep 15, 2006 6:36 am

Post » Wed Jun 20, 2012 4:15 am

I don't know what you mean by anological... The script I gave you should work on the MetalLever01, and probably all the levers. The DwePipeValve01SCRIPT seems to be for a valve. The names of the animations are different for levers and valves, so the scripts are not interchangeable. In your first post you said you wanted a lever. What exactly do you want?
User avatar
Sheila Esmailka
 
Posts: 3404
Joined: Wed Aug 22, 2007 2:31 am

Post » Tue Jun 19, 2012 6:25 pm

I didnt check the script of the valve beforehand and assumed it would work exactly like a lever. Additionally, I didnt keep in mind that the animation would need script as well. Im sorry for that. I wouldnt be asking if i knew how the script would have to look like.
User avatar
Penny Flame
 
Posts: 3336
Joined: Sat Aug 12, 2006 1:53 am

Post » Tue Jun 19, 2012 9:17 pm

I didn't mean to sound so critical, I just wanted to be sure whether you wanted a valve or a lever. This is a modified script based on the one you posted:

Spoiler
scriptName MyValveScript extends ObjectReferencemessage property MessageProp autobool flip = FalseAuto STATE Waiting    EVENT onActivate (objectReference triggerRef)        int choice = MessageProp.Show()        if (choice == 0) ;first choice, assumed to be 'yes'            GoToState("Busy")            TurnValve()        endif    endEVENTendStateState Busy    Event onActivate(objectReference triggerRef)        ;do nothing    EndEvent        Function TurnValve()        if (flip)            playAnimationandWait("trigger02","Trans02")        Else            playAnimationandWait("trigger01","Trans01")        EndIf        flip = !flip        GoToState("Waiting")    EndFunctionEndState

Remember to set MessageProp to your custom message. Looks like in the original script, whoever wrote it intended to use the BlockActivation() function to control whether or not the code ran. But according to the creation kit wiki, even when the object's activation is blocked, the code still runs. So I added a "busy" state like how it's done in the lever script.
User avatar
BlackaneseB
 
Posts: 3431
Joined: Sat Sep 23, 2006 1:21 am

Post » Tue Jun 19, 2012 8:22 pm

Thanks a lot, mate!


I hope this will work out so don't have to bother you again.
User avatar
Oscar Vazquez
 
Posts: 3418
Joined: Sun Sep 30, 2007 12:08 pm


Return to V - Skyrim