Item highlights

  • #10, by afrlmeTuesday, 03. June 2014, 19:49 10 years ago
    the tables are same as the variables but they are all the same table. & temporary. I don't need the data to be saved, hence the use of the temporary local table, each time the function is called, it updates the data inside of the tables.

    sure I could have created empty local variables outside of the function but I wouldn't use them on the inside of a function as it creates a new table entry each time you call local inside of a function & not much point in that! wink

    I know Lua is pretty efficient now & I enjoy using whenever I can instead of using the pre-made editor action parts as it is just far quicker to type a few lines of code than it is to click here & there.

    Here's my version of the script you wrote above...
    prevItem = nil -- initial value of previously highlighted item
    
    function checkItemStatus()
     if prevItem ~= nil then prevItem:setValue(VAnimationFirstFrame, 1); prevItem:setValue(VAnimationLastFrame, 1); prevItem = nil end
     -- + --
     if game:getLink(VGameCurrentObject):getId().tableId == eObjects then
      if game:getLink(VGameCurrentObject):getBool(VObjectIsItem) then
       prevItem = getObject("ActiveAnimations[" .. game:getLink(VGameCurrentObject):getName() .."]"); prevItem:setValue(VAnimationFirstFrame, 2); prevItem:setValue(VAnimationLastFrame, 2)
      end 
     end
    end
    
    function onMouseEvent(eventType)
     if eventType == eEvtMouseMove then checkItemStatus() end
    end
    
    registerEventHandler("mouseEvent", "onMouseEvent", {eEvtMouseMove})
    

    my version uses the mouseEvent handler instead & is a little more compact.

    I'm not sure if you told him or not but he needs to add a line of code to the first frame of each item's animation to force it to only play the first frame.
    getObject("ActiveAnimations[item_name]"):setValue(VAnimationLastFrame, 1)
    

    Imperator

    7278 Posts


  • #11, by divas1980Tuesday, 03. June 2014, 20:30 10 years ago
    tk guys for help! tomorrow try the script rollroll

    Newbie

    46 Posts

  • #12, by afrlmeTuesday, 03. June 2014, 20:43 10 years ago
    use either... it doesn't matter wink

    I will be adding mine to the script index section of the wiki, where most of my other scripts can be found with instructions. I'll add some instructions for my above script too, so don't worry! It's not that complicated!

    Imperator

    7278 Posts

  • #13, by divas1980Wednesday, 04. June 2014, 09:44 10 years ago
    The script work! but there is a problem , for the mini script

    getObject("ActiveAnimations[item_name]"):setValue(VAnimationLastFrame, 1)

    i should to use a execute script or a call script?
    and i should change Item_name with the name of item in properties?

    tk !!

    Newbie

    46 Posts

  • #14, by afrlmeWednesday, 04. June 2014, 13:10 10 years ago
    1. select first frame of item animation
    2. click on the edit frame button
    3. there is a bit where you can add actions (click on the lightning icon)
    4. create a "execute a script" action part
    5. add the line of code you mentioned above
    6. change "item_name" to the name of the item (this is the name in the left hand column)
    getObject("ActiveAnimations[rock]"):setValue(VAnimationLastFrame, 1) -- this forces the last frame (to frame) to stop playing at frame 1
    

    names are case & character sensitive, so they have to be written exactly as you typed them in the editor; the same goes for pretty much everything, when accessing/manipulating data with Lua script.

    Imperator

    7278 Posts