Forum overview > if item is dragged currently?
  • if item is dragged currently?

    by Damiano · Thursday, 25. February 2016, 16:50 h ~ 4 years ago
    If my "go to" cursor enters object area it changes individually to "look at" or "use" or "speak to/eat" (btw. i have a scroll through commands interface).
    But if i want to use a dragged item on one of these objects it also happens that my item dissapears and the "look at.. etc" cursor appears. How do i avoid this? Isn´t there a decent way to ask if an item is dragged currently?
  • by afrlme · Thursday, 25. February 2016, 17:27 h ~ 4 years ago
    Sure, you can run a query to check if an item is currently being held.

    if game.UsedItem:isEmpty() then


    ... you will have to create a called by other action to call or you could have it set a condition or value & then immediately add an if query after the execute a script action to check if the condition or value is met to determine if the cursor should be changed or not.

    Quick note: unfortunately it is not currently possible to update the active cursor with Lua script - I really should make a note of it to Simon, at some point, as it would definitely save a lot of time having to arse around with workaround action blocks & if queries.
  • by Damiano · Thursday, 25. February 2016, 19:41 h ~ 4 years ago
    Thank you ARFLme.
    I really don´t know exactly how to achieve what i want.
    I dont know any lua. so i am sure that what i am doing is wrong.
    "cursor enters object area" then i call the script..
    does the script mean: if i have no item dragged?
    because if it´s like that i want to set the command in this specific object to "look at" else i want it to hover with the draged item over the object and left-click it in order to use item with object.
  • by afrlme · Thursday, 25. February 2016, 19:50 h ~ 4 years ago

    1. create a called by other action somewhere. In you main characters action tab or somewhere global. Give it a relevant name, something like: "set_command-look" & inside of this called by other action add the set command "look" (whatever you called it).

    2. I didn't mean call script. I meant an execute a script action. You directly add code to it. If you are only using it for setting look then I suppose you can use the call script, if you have other commands then I recommend writing a function or directly writing the if query into an execute a script action each time.

    if game.UsedItem:isEmpty() then -- basically we are checking if item table returns empty, if it does then we call an action.
    startAction("Actions[set_command-look]") -- calling the called by other action we created in step 1
    end -- closing the if query


    P.S: the UsedItem data structure field is item held (dragged or manually set).
  • by Damiano · Thursday, 25. February 2016, 20:26 h ~ 4 years ago
    Fantastisch! smile
    It works. Thx! When it comes to programming logic i am such a noob.
  • by afrlme · Thursday, 25. February 2016, 20:38 h ~ 4 years ago
    You're technically programming when you are selecting action parts in the editor. Actual programming / scripting works in a similar logic. & no problem.wink
  • by Glenfx · Tuesday, 13. February 2018, 23:51 h ~ 2 years ago
    I was looking at an old game I was working on in 2008, and I noted the "cursor enter object" overriding the item drops now (those used to work back then), anyway, last year I was working on a test project which used a similar setup so for me is kind of a recurrent issue because I kind of like that setup.

    I'm using Version 5.0.3, but I wanted to know if this script is the only way of fixing the problem?.

    Will something like a checkbox next to the "items can be dragged with this command" be added so the item won't get overridden while it's being dragged? or added into the "items can be dragged with this command" option since that is kind of what it should do?

    In any case if a fix won't be added I think this workaround should go into the wiki tutorials for us non programmers.
  • by afrlme · Wednesday, 14. February 2018, 00:21 h ~ 2 years ago
    In 5.x there's a new query action part called "if lua result". You could use that to check if item is dragged. Wrap the on mouse enter/leaves action block in an if query like so...

    if lua result...
    return game.UsedItem:isEmpty()

     change cursor "look"
    end if

    if the held item is empty it will return true which will then execute the actions below the query.
  • by Glenfx · Wednesday, 14. February 2018, 03:38 h ~ 2 years ago
    Nice,  thank you AFRLme that one works as well.
    Will these solutions be added to the wiki tutorials?
  • by afrlme · Wednesday, 14. February 2018, 03:44 h ~ 2 years ago
    Maybe...? At some point if someone reminds me.

    What we really need is for the search function on here to work properly & the ability to create tags that the search function can use besides the thread title.
  • New post