LUA Script to access dropped item name

  • #10, z sebastianWednesday, 08. June 2016, 21:01 hodinky 9 years ago
    Alrighty tighty lets get this done...
    Did i understand it right that it could be any item which can be dropped on the table or is only this bread successfull placeable?
    Must the moving from the placed item to this second inventory be animated or was it just to visualize where it should go?

    Kapitán

    2346 Posts


  • #11, z OrlixWednesday, 08. June 2016, 21:46 hodinky 9 years ago
    Well for now i would like to escape from the work of doing one cursor to each item (have lot of them).

    (AFRLme) Besides the name it seems to be working more or less, no? Not sure what's up with the crazy character position jump though.

    With the name is working, but once that is the table who trigger the action, i´m not able to check what is the item dropped without a crazy million conditions. shock

    Besides that, i think me character gain wings and the ability to stand up in the air wile i´m thinking razz. I think this is probably related with way system. Any clue about this?


    (Sebastian.204) I guess because you dropped the item already on the object, the game:UsedItem is nil when you print it to the console.

    Well, i´m not sure. I have created an simple action from type "Execute command on object", command = left click to run a "execution script" printing the object name before the "item dropped" action, and made the test:

    1 - Pick the item from the inventory.
    2 - left click on the table (to print the object name to log)
    3 - Object name came empty again, while i had´t dropped the item yet.


    (Sebastian.204) Did i understand it right that it could be any item which can be dropped on the table or is only this bread successfull placeable?

    Yes, any item which can be dropped on the table. The bread is only one item to test.


    (Sebastian.204) Must the moving from the placed item to this second inventory be animated or was it just to visualize where it should go?

    I would like to have this animation, but if that is not possible, i will be glad just if the item go to the specified position.

    thank you both, very much!

    Bažant

    20 Posts

  • #12, z afrlmeWednesday, 08. June 2016, 22:03 hodinky 9 years ago
    If you want you could query on the fly via the developer console. Hit TAB to open the console & type exec print( game.UsedItem:getName() ) then hit enter. I'd say to then type PRINT LOG & hit enter to show the log in the developer console, but seeing as you are using a tail app it's a bit pointless. You can use TAB to close dev console screen once done.

    The character moving could be because you are moving the object & its relevant object interaction position outside of the way system border you have defined for the scene. The reason I don't like moving actual objects & their polygons is because it also adjusts the object center value which VS doesn't like very much. It has enough of an hissy fit if you don't correctly order your scene objects based on their object center values, so I can't imagine what moving an object outside of a way border would do.

    Imperátor

    7285 Posts

  • #13, z sebastianThursday, 09. June 2016, 08:39 hodinky 9 years ago
    Does the log also print nothing when the action is "on mouse enter" and an item is at your cursor?
    By the way i think it isn't neccessary for you to get that item anyway

    Just create for each possible item a "dropped item" action which checks the desired item. For each item you can then set a value (lets call it "placed_item") from 0 to x
    After that you call a further "called by another action" which you can create inside the object, too.
    By that you dont have to repeat everything again for each item.
    What we will do inside this action i will come to later.

    Eat some slice of pizza

    You have to create one animation inside the scene object which shows in each frame a different item graphic. (no moving animation. Just each frame a different item. We will move the animation later via lua )
    Try to arrange the images inside each frame so that the center of them are above each other. Set the animation to infinite.
    Place the animation inside the scene, so that the center of the item is on the table. To test out if every frame fits correctly on the table you can click the play button on the top right corner of the scene preview.

    Now you have an animation with frame from 0-x and a value "placed_item" which gets set to 0-x depending what item is placed. Now we have to tie that together.

    Go to the "called by another action" action you created before in the object and add an "execute a script" action part.
    In it add
     
    local itemgraphic = Values["placed_item"].Int
    
     ActiveAnimations["myanimationname"].AnimationFirstFrame = itemgraphic
     ActiveAnimations["myanimationname"].AnimationLastFrame = itemgraphic
    



    Go to the petshop, buy a duck

    After the "execute a script" action part add a "play animation" action part and select the before created animation.
    Right now it should play the right frame depending on the item which was placed on the table.

    Lets go and move that animation.
    The next action part you add is again a "execute a script" type.
    In it add:

    ActiveAnimations["myanimationname"]:to(500, {VAnimationCurrentPosition = { x = destinationx, y = destinationy}}) 
    

    Replace destinationx and destinationy with the desired values on the scene.
    The 500 is the time it needs (500ms). You can also edit it

    Watch all seasons of two and a half man.

    I guess thats it. Didn't test i though because im on the way to work with the bus and typed all with my mobile phone...
    Hope i didnt miss anything. If it doesn't work you may have not watched all episodes of two and a half man.

    grin

    Kind regards
    Sebastian

    Kapitán

    2346 Posts

  • #14, z OrlixThursday, 09. June 2016, 19:18 hodinky 9 years ago
    Ahaha Thank you mate, i´m on my way to the pet-shop grin

    Then i will try this approach. Yesterday i managed to check that the object name is only available in "game.UsedItem" for the period the object keeps grabbed. So what i did was to save the object name in the cursor out action if the object exist.

    For now is half working, but i will try your approach either then i give you some feedback.

    Thank you very much
    Orlix

    Bažant

    20 Posts

  • #15, z sebastianMonday, 20. June 2016, 18:29 hodinky 8 years ago
    I never tested my mentioned steps above. Did it help? How was the pizza grin?

    Kapitán

    2346 Posts