Scale item object

  • #30, by afrlmeThursday, 01. October 2015, 17:12 5 years ago
    Ok dokie. You do know that you don't need to create 10 frames. You could just reverse the playback direction of an active animation?

    What you are wanting to do, could be classed as a little overkill > running a loop, to run a loop, to run another loop. Like a bloody tongue twister.

    If you do want to go down the loop method then I recommend only creating the loop event when you show the interface & quiting it when you hide the interface. The animations will reset themselves automatically when the interface is next shown anyway.

    I don't think you really need the multiple for loops either. One should probably be enough. get it to loop through the character items & check if any of the items are the current object & if so check if the current frame is less than 5 and if not set frames 1 to 5 else check is 5 then set frames to 5, 5. Next the else part for not current object you check if animation frame > 1 & if it is then you set animation direction to backwards & frames 1, 5. then same as before you also run a query to check if frame is 1 then set frames to 1, 1. Ah you would also want to set playback direction to forward for when scaling animations up.

    Sounds a little complicated in text, but I think it should work ok - providing the system loop catches the animations while they are on specific frames each time.

    Imperator

    6931 Posts


  • #31, by ke4Thursday, 01. October 2015, 17:26 5 years ago
    That sounds creepy, let me just process that for a while and then try it grin

    Key Killer

    810 Posts

  • #32, by ke4Thursday, 01. October 2015, 20:00 5 years ago
    I'm getting headache now, but...
    i'm pretty happy with that, it works globaly, so there is no need to do anything else.


    I call this on showing the interface and unregister it on hiding.

    local items = game.CurrentCharacter.CharacterItems

    function scaleItem()
    for i =1, #items do
    if game.CurrentObject:getName() == items[i]:getName() then
    if ActiveAnimations[items[i]:getName()].AnimationCurrentSpriteIndex < 4 then
    setAnimFrames(items[i]:getName(), 1, 5)
    else
    setAnimFrames(items[i]:getName(), 5, 5)
    end
    else
    if ActiveAnimations[items[i]:getName()].AnimationCurrentSpriteIndex > 0 then
    ActiveAnimations[items[i]:getName()].PlayOppositeDirection = true
    setAnimFrames(items[i]:getName(), 1, 5)
    else
    ActiveAnimations[items[i]:getName()].PlayOppositeDirection = false
    setAnimFrames(items[i]:getName(), 1, 1)
    end
    end
    end
    end

    registerEventHandler("mainLoop", "scaleItem")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24

    Key Killer

    810 Posts

  • #33, by afrlmeThursday, 01. October 2015, 21:15 5 years ago
    instead of calling the script...

    1. leave local items empty.

    2. above your for loop add items = game.CurrentCharacter.Items -- I don't think you need to add Character before Items (not 100% sure, but most fields under character work without the full path).

    3. instead of the call script action use an execute a script action containing the registerEventHandler line of code.

    4. same as above for the hide inventory bit, but with a unregisterEventHandler.

    This way you are not having to declare multiple instances of same script & variables over & over again. It doesn't really make much of a difference but it's a much cleaner method.

    Anyway... you are certainly starting to get the hang of the scripting side of Visionaire Studio. Nice one. wink

    P.S: the frame index values should start at 1. I have no idea why the counters in the editor start at 0, as the initial frame value is always 1.

    Imperator

    6931 Posts

  • #34, by ke4Thursday, 01. October 2015, 21:35 5 years ago
    Yes you are right, it works with .Items only.

    ... and i thank you for being my guru in that razz

    Key Killer

    810 Posts

Write post