3 button status....help!!

  • #1, by divas1980Thursday, 12. June 2014, 11:09 10 years ago
    Hi grin

    Hello I have a new problem.
    1-I have a button on the interface this button enables a power , I put this script to lock it to the frame 1. "GetObject (" ActiveAnimations [Power] "): setValue (VAnimationLastFrame, 1)". Power is the name of the animation.
    and this script work,

    This button has 3 frames, the first frame when the power is turned off (not active o usable), the second when it is activated and usable, and the third when the mouse enters the area. When the mouse left the status return in second frame (active e usable).

    At begin the status button is in frame 1 (not active).
    The button is enabled when you read a letter. I wish that after reading the letter the button go to the frame 2 and when the mouse enter in button area go to frame 3 and back to 2 when the mouse leaves the button area,
    Once used the power instead return to frame off (frame 1) ..

    how can I do? Thanks for the great help you have given me so far.

    Newbie

    46 Posts


  • #2, by afrlmeThursday, 12. June 2014, 16:25 10 years ago
    you need to use an if query...

    so, set up a condition like "cond_powername_active". set as "false" by default.

    after reading the letter set condition as true.

    inside of your execute a script add this...
    local anim = getObject("ActiveAnimations[Power]")
    
    if getObject("Conditions[condition_name]"):getBool(VConditionValue) then
     anim:setValue(VAnimationFirstFrame, 2); anim:setValue(VAnimationLastFrame, 2)
    else
     anim:setValue(VAnimationFirstFrame, 1); anim:setValue(VAnimationLastFrame, 1)
    end 
    

    ...or, you could even create a global function for it (add as definition script).
    function setAnimFrames(ani, v1, v2)
     anim = getObject("ActiveAnimations[" .. ani .. "]")
     anim:setValue(VAnimationFirstFrame, v1); anim:setValue(VAnimationLastFrame, v2)
    end
    

    ... to run the function you would create an execute a script action & add something like this...
    setAnimFrames("Power", 1, 1) -- name of animation (case sensitive), first frame value, last frame value.
    

    ... you might want to add the if query part for the condition into the first frame of the animation too, as it would automatically set it to frame 1 or 2 each time the animation is reloaded (at begin of scene etc).

    Hope you found this post useful & all enlightening & what-have-you? wink

    Imperator

    7278 Posts

  • #3, by divas1980Thursday, 12. June 2014, 17:35 10 years ago
    The second method is perfect! with the first did not work but it's probably my noob fault.

    Now when I read the letter the button turn on the frame 2 in power. How can I do because because when mouse enter in area go to frame 3 and when leave it to the frame 2. In the animation for the moment, there is always the same script .....
     "GetObject (" ActiveAnimations [Power] "): setValue (VAnimationLastFrame, 1)".
    


    Thank you again and thank you very much!

    Newbie

    46 Posts

  • #4, by afrlmeThursday, 12. June 2014, 18:01 10 years ago
    Sorry I don't understand what you are trying to say...

    You have to set both the first & last frame of an animation to lock the playable frames. If you only set last frame then it will still play between frames 1 & 2 etc.

    The first method won't work unless you create a condition in the editor & edit the condition_name in the script to the condition name.

    The second method was a global function to save you from having to type out a load of code each time you want to swap animation frames, but does not have anything to do with the conditions.

    If you are using the second method then in the first frame of the animation add an if query...

    -----

    if condition 'condition_name' is false
    execute a script...
    setAnimFrames("animation_name", 1, 1)
    

    else
    setAnimFrames("animation_name", 2, 2)
    

    end if

    -----

    Do you understand now? This should be included in the mouse out action of the object & in the first frame of the animation itself.

    If you need still need a bit of help then send me some screenshots or your .ved & resource files & I will see what I can do.

    Imperator

    7278 Posts

  • #5, by divas1980Friday, 13. June 2014, 10:15 10 years ago
    first to all tk for your help AFLRme..

    i post a image for help y to undestard me xD

    for clarity the object is a interface item.

    Image 1 indicates when the status is off and it works here (frame1).
    Image 2 shows when the status is on and the mouse is not over (frame 2) and work fine when i change condition to true.
    Image 3 indicates when the status is on and the mouse is over and here I do not know how to do it for do it. (frame3).

    The other 2 images instead are:

    the 4 the main script and that or put between script with defintion mode
    the 5 instead is the power button in invetory.. It has 3 frame as you can see. And I put the script in the first frame that has given me. And it works. But I Would indeed that when you pass the mouse go to frame 3 and when you let it go to frame 2.

    I hope it's more clear. And thanks again!

    Newbie

    46 Posts

  • #6, by afrlmeFriday, 13. June 2014, 16:11 10 years ago
    A larger image would have been a bit more helpful but no worries.

    So... You have created the object & the animations, but have you...
    1. Set the object area polygon?
    2. Have you created a mouse enter & mouse leave action part for the object?
    3. If so then here would be the editor actions inside of the mouse enter action...
    if condition 'powerwhatsitactive' is true
     execute a script 'setAnimFrames...'
    end if
    

    4. In the mouse leaves action part just add the if query version you put into the first frame of the animation.

    Just a quick note: You MUST remember to close off if queries with an END IF action part. There should be the same amount of END IF as IF.

    Imperator

    7278 Posts

  • #7, by divas1980Friday, 13. June 2014, 20:29 10 years ago
    Great! now work!! tk again!!!razz

    Newbie

    46 Posts