License from €75 Log in
DE EN FR ES IT CZ

Set frame range error [SOLVED]

This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials

  1. · 3 years ago
    Hello.
    I am using script to select animation frame:
    https://wiki.visionaire-tracker.net/wiki/SetAnimFrames_(CMS)

    Everything works, but for some reason it causes a repeating error:

    18:19:03.606:stack traceback:
     [C]: in metamethod 'newindex'
     [string "(30,57)"]:9: in function 'setAnimFrames'
     [string "(8,33905)"]:17: in main chunk
    18:19:03.606:Unknown data-field "FirstFrame" for object (-1,-1) Unnamed.
    18:19:03.607:1
    18:19:03.607:stack traceback:
     [C]: in metamethod 'newindex'
     [string "(30,57)"]:8: in function 'setAnimFrames'
     [string "(8,33905)"]:18: in main chunk
    18:19:03.607:Unknown data-field "LastFrame" for object (-1,-1) Unnamed.

    and so on...

    My script is placed in the first frame of object animation (call action function):

    local val = Values["choice"].Int
    if val == 1 then
    setAnimFrames("char1", 2)
    setAnimFrames("char2", 1)
    setAnimFrames("char3", 1)
    setAnimFrames("char4", 1)
    setAnimFrames("char5", 1)
    setAnimFrames("char6", 1)
    elseif val == 2 then
    setAnimFrames("char1", 1)
    setAnimFrames("char2", 2)
    setAnimFrames("char3", 1)
    setAnimFrames("char4", 1)
    setAnimFrames("char5", 1)
    setAnimFrames("char6", 1)
    elseif val == 3 then
    setAnimFrames("char1", 1)
    setAnimFrames("char2", 1)
    setAnimFrames("char3", 2)
    setAnimFrames("char4", 1)
    setAnimFrames("char5", 1)
    setAnimFrames("char6", 1)
    elseif val == 4 then
    setAnimFrames("char1", 1)
    setAnimFrames("char2", 1)
    setAnimFrames("char3", 1)
    setAnimFrames("char4", 2)
    setAnimFrames("char5", 1)
    setAnimFrames("char6", 1)
    elseif val == 5 then
    setAnimFrames("char1", 1)
    setAnimFrames("char2", 1)
    setAnimFrames("char3", 1)
    setAnimFrames("char4", 1)
    setAnimFrames("char5", 2)
    setAnimFrames("char6", 1)
    elseif val == 6 then
    setAnimFrames("char1", 1)
    setAnimFrames("char2", 1)
    setAnimFrames("char3", 1)
    setAnimFrames("char4", 1)
    setAnimFrames("char5", 1)
    setAnimFrames("char6", 2)
    else
    setAnimFrames("char1", 1)
    setAnimFrames("char2", 1)
    setAnimFrames("char3", 1)
    setAnimFrames("char4", 1)
    setAnimFrames("char5", 1)
    setAnimFrames("char6", 1)
    end


    Can you suggest what could be the problem??
    Thanks

    • Image in post
  2. Working on a game?

    The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license.

    See licenses Try it for free
  3. · 3 years ago
    It's either trying to access something that doesn't exist, or it's trying to access an active animation that's not actually active or isn't loaded yet.

    Also instead of that massive list of else if, why didn't you consider using a table or using iteration?
    for i = 1, 6 do
    
     if Values["choice"].Int == i then
    
      setAnimFrames("char"..i, 2)
    
     else
    
      setAnimFrames("char"..i, 1)
    
     end
    
    end


  4. · 3 years ago
    Thank you. In my case, this is an animation that is not yet loaded / active.

    Tables... I don't know how to work with that. Will be studying
  5. · 3 years ago
    The code I shared wasn't a table. It was a short iteration method example using the for loop, which does the same as your if else queries, except it's much less code. wink
  6. · 3 years ago
    The code I shared wasn't a table. It was a short iteration method example using the for loop, which does the same as your if else queries, except it's much less code. wink
    Yes, I got it, thanks. Very handy for these occasions

  7. · 3 years ago
    Can this error create any problems? reduce performance? 
    So everything works...

    This solutionis convenient to use for "highlighting" items in the inventory (so as not to highlight empty cells)...
  8. · 3 years ago
    Is it possible to track in the inventory whether the cell is filled with an item or not?

    For example:
    click to placeholder for items:
    if placeholder is full - do something (animation)
    else - nothing
  9. · 3 years ago
    1. The log messages are just warnings, so they shouldn't really impact performance, however it would be ideal to try & remedy the issues so that you don't have any warnings/errors being generated - add a small pause or something before trying to force the animation frames in whatever method you are using to prevent it trying to update them before they've all started playing. Or you could add the code directly into the frames themselves as that way they will definitely be playing when the code is executed.

    2. You could use the mouse event handler to check if an object exists below the cursor & that it's an item. Another thing you could do is use code to check how many items exist in the character inventory & set a value to that so you can check how many slots are filled up.

    Values["example"].Int = #game.CurrentCharacter.Items
  10. · 3 years ago
    1. The log messages are just warnings, so they shouldn't really impact performance, however it would be ideal to try & remedy the issues so that you don't have any warnings/errors being generated - add a small pause or something before trying to force the animation frames in whatever method you are using to prevent it trying to update them before they've all started playing. Or you could add the code directly into the frames themselves as that way they will definitely be playing when the code is executed.

    2. You could use the mouse event handler to check if an object exists below the cursor & that it's an item. Another thing you could do is use code to check how many items exist in the character inventory & set a value to that so you can check how many slots are filled up.

    Values["example"].Int = #game.CurrentCharacter.Items
    Cool, thanks a lot! This is a great option

This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.

New thread

Really delete this post?