[SOLVED] changing frames of inactive animations (cursor)

  • #1, by sebastianFriday, 09. September 2016, 22:24 8 years ago
    hello herps and derps,

    i have a question regarding changing animation frames kf a cursor.

    Because i only can change active animations I dont know if changing a "not shown" animation will work (i guess not) .

    So my scenario is as follows: I have one item with 8 different states. Each state is a combination of several conditions. Because i dont want to use 8 separate items it came to my mind to use the item animation frames which I can easily change to one specific frame via lua. So far so good...

    My cursor is also an item which represents a dragged item (not the actual item dragging, but replicated to simulate it ==> outlines for active state only for cursor)
    NOW: I want also change the cursors animation frames to get updated. But when using an item on the item with the 8 stages to get its new stage the cursors animation are not active (because not shown)
    How do i change these frames to represent my item later correctly?

    Hope i wrote it understandable enough. quite deep xD


    Thread Captain

    2346 Posts


  • #2, by afrlmeFriday, 09. September 2016, 22:51 8 years ago
    You can check which item is present with Lua.
    local itm = game.UsedItem:getName()
    
    if itm == "strawberry" then
     ActiveAnimations["default_cursor (inactive)"].AnimationFirstFrame = 10
     ActiveAnimations["default_cursor (inactive)"].AnimationLastFrame = 10
    elseif ...
     ...
    end
    

    ... don't forget that you can directly create loops by creating execute a script action parts inside of animation frames themselves. So you only really need to add the query inside of the first frame as each time you move the mouse cursor onto or off of something it will change between cursor active & cursor inactive. Having it inside of the first frame means you can force the frames as soon as the animation starts playing. Also as a bonus the animation has to be active if the animation is playing so it will only trigger the queries while the animation is playing.

    If you wanted to organize it a bit better so you don't have tons of if queries then I would suggest writing a Lua table with the item names as the table field names & then adding the start > end frame values inside of them so you can simply return the values based on the name of the currently held item. So you need to check if useditem == nil else return x value from table.

    Imperator

    7285 Posts

  • #3, by sebastianSaturday, 10. September 2016, 11:22 8 years ago
    yeah i know that already. seems that i expressed myself a bit wrong.

    I have lets say 2 Items
    Item 1: Item with 8 animation stages which is locked to frame 1 because its state is 1
    Item 2: Item which is part of Item 1. When Using Item 2 on Item 1 they are combined and Item 1 gets state 1 for example (locked on that frame by that fancy lua script).

    Now the cursor for Item 1 (when used for "dragging") should also update its appearence because it changed to state 1, right?

    The cursor for Item 1 wasn't active at all yet, right? I want to change its appearence without having it active.

    The only solution i see here is to have in each frame of active/inactive cursor animation a (lua)if-query to check permanently what state the item has to lock itself to the right frames.








    Thread Captain

    2346 Posts

  • #4, by afrlmeSaturday, 10. September 2016, 11:59 8 years ago
    To my knowledge you can only manipulate certain things with animations when they are active. Somethings you can change in general with just Animations["name"].somedatastructurefield, but you will have to check under Animation & ActiveAnimation in the data structure wiki page.

    Quick note: I'm still a bit confused as to what you are wanting. Why is it important that you edit the animation before it is shown? As soon as any animation is shown it will automatically play frame 1, so any code you add into that frame should instantly update it to the relevant frames if that's what you want it to do. Each time the animation / cursor changes state or cursor changes to another cursor it unloads the animation & reloads the next animation from scratch, hence anything you applied to it via ActiveAnimations previously is undone.

    Imperator

    7285 Posts

  • #5, by sebastianSaturday, 10. September 2016, 13:15 8 years ago
    Isn't it a bit bad in performance aspects if I permanently check my frames with deep (LUA)if conditions to check itself if the state is changed? Wouldn't it be better to change the frame ONCE when i want to change them?
    It seems the only possible way to do it only when showing the animation yet, but its far away from "great" if i do it like that (but will work). ^^

    Also im not sure what happens when frame 1 is played and then executes the script to show another frame that the first frame blinks up for a milli second until the change is done...

    Thread Captain

    2346 Posts

  • #6, by afrlmeSaturday, 10. September 2016, 14:22 8 years ago
    Not much I can do about that. My item method was to create cursors for each item & also to create a command for each item. I then link the cursor to the command inside of the "command properties" tab.

    I didn't bother using the dragged item options or the set command + item options as I didn't like them. It was far more flexible & easier to control everything as commands, because you don't have to worry about updating the cursor & you can also prevent on mouse over scene objects / characters from changing the cursor by querying if x command. It was one of the reasons I ended up setting up commands & items the way I did.

    https://gyazo.com/a5ae1ea32ad860dfe137523f914182b4

    https://gyazo.com/716f13250c718057b2b05cd2ab33a943

    I'm still using a single command interface system aka the broken sword interface as I only have one command for interaction which I called "left_click". The rest are items. How it works is on mouse over a scene object or character I query if command = "left_click" then update to x cursor (take, use, talk, examine, etc). If it doesn't = left_click then it must be an item thus do nothing.

    Imperator

    7285 Posts

  • #7, by sebastianSaturday, 10. September 2016, 18:06 8 years ago
    i guess i have to check it then in every frame^^ Hope the cursor items updates itself fast enough razz

    Thread Captain

    2346 Posts

  • #8, by afrlmeSaturday, 10. September 2016, 19:55 8 years ago
    I guess it'll depend on the delay value you set for the frame but it should be pretty much instantaneous. I think I did that for another cursor before I started using my current method.

    Imperator

    7285 Posts

  • #9, by sebastianSaturday, 10. September 2016, 22:56 8 years ago
    by the way how are the cursor animations named? "cursorname_inactive", "cursorname_active" or some kind of way? because these animations are not named directly like all others...

    EDIT: Just read your code and saw that it answers my question exactly =)

    EDIT 2: As it seems that the interface animations are always active and are permanently loaded (when interface is shown), also its cursors. I will try to change the inactive/active animation once and not every time in each framewink

    EDIT 3: seems that they are not always loaded. Have to do what you recommended in the first place

    Thread Captain

    2346 Posts

  • #10, by afrlmeSaturday, 10. September 2016, 23:12 8 years ago
    like in the code block example I provided above.
    ActiveAnimations["cursor_name (active)"]
    ActiveAnimations["cursor_name (inactive)"]
    

    ... though the active / inactive may be in German if you are using the editor in German. You can check the names of all active animations via the developer console though... Open up dev console with TAB then type PRINT ANIMATIONS then press enter. Now check the log to see names of all your animations - the cursors should also be listed.

    By the way, do you know how to scroll through the log via the console on a mac when you are using the small bluetooth mac keyboard? I have no clue.

    Imperator

    7285 Posts

  • #11, by sebastianSaturday, 10. September 2016, 23:21 8 years ago
    I used "show animationdetails on" for listing (and showing) all currently loaded animations wink . See EDIT 1/2 above.

    @keyboard: I am using the wider keyboard with numpad and page up/down keys over the arrows. But i guess you have to press... *opens drawer and looks at his bluetooth small keyboard* ... hmmmm... fn + ARROW UP/DOWN

    FN+(Arrow up/down) = Page up / down
    FN+(Arrow left/right) = go to top or bottom of a page
    CMD+(Arrow up/down) = go to top or bottom of a page
    CMD+(Arrow left/right) = go to beginning/end of a line

    Thread Captain

    2346 Posts