Dragging items in the inventory

  • #1, by gustySaturday, 31. August 2013, 12:42 7 years ago
    Hey I would like to:

    a) set a custom cursor while I'm dragging an item (left click on the item = set a cursor). I mean in the default, when you click on the item in the inventory, there is the item's image itself instead of cursor, right? So I want to set my own cursor instead of that "item's thumbnail" - hope you understand.

    b) change the item's image in the inventory while I click it. I don't mean the cursor/item I'm dragging, but the image which is stuck in the inventory interface after I click it. Or hide the image at least - no duplication of the item/icon, just pick the item a drag it.

    Is that a possible?

    Forum Fan

    159 Posts


  • #2, by gustyTuesday, 03. September 2013, 02:21 7 years ago
    Anyone knows? :-/

    Forum Fan

    159 Posts

  • #3, by gustySunday, 08. September 2013, 06:01 7 years ago
    Did I insult someone here or did I say something inappropriate? I don't understand why there is no reply from anyone..

    Forum Fan

    159 Posts

  • #4, by afrlmeSunday, 08. September 2013, 12:04 7 years ago
    sorry, just overlooked your post is all...

    I'll try & answer it later on when I've woken up properly wink

    Imperator

    6846 Posts

  • #5, by gustySunday, 08. September 2013, 12:44 7 years ago
    Thank you AFRLme :-)

    Forum Fan

    159 Posts

  • #6, by afrlmeSunday, 08. September 2013, 19:59 7 years ago
    A. instead of item dragging (which works via left click & sets item image as cursor) you need to do it manually...

    1. disable dragging of items from the inventory
    2. inside of each item add an executed x command (immediate) - "walk", "use" or whichever command you want to use for setting the item.
    3. then inside of the action you just created add the action parts: interfaces > set item "item_name" (dragged item left unchecked) & miscellaneous > set cursor "cursor_name"

    simple as that! requires a bit more work on your end though.

    B. this one is a little complicated as it will most likely involve using Lua Script to control which frames of the items animation can be shown seeing as we can't remove the item in question from the inventory & then put it back after seeing as the item has to be in the inventory to be able to select/use it.

    Let's say you are using a static image for each item which consists of a single frame. so what we need to do is add an additional blank frame which we can use to pretend the item is no longer in the inventory...

    & hmm...
    I need to think about the solution for this a little bit as I have not made my mind up whether or not it would be better to create a global script or to add a small script to each individual item.

    for a global script you could just call the script quite simply with a single line every time you set an item & have the script automatically check which item it is & then set the animation frames automatically & then call another function just before you set the item back to empty (providing the action you performed didn't remove the item)

    Imperator

    6846 Posts

  • #7, by gustyMonday, 09. September 2013, 20:36 7 years ago
    Well, there is a problem with the first solution you suggested. The thing is I have already a bunch off actions on the objects in the scene. I use broken sword style interface, so I have only one action (left click) and I set everything manually (examine, use..). So when I click on the item in the inventory, cursor would changes nicely but when I drag the item on some object in the scene, cursor changes again because I already have another action on this object (cursor enters area, cursor leaves area). And it's not only the "set cursor" thing, other object's actions with the item doesn't work neither (remove item from inventory after it's been use, display text etc.). I guess object's actions simply overbeats item's actions...

    Another thing I would like to accomplish is when I select (drag) item from the inventory and click in the scene on floor or sky (just graphics part, no active objects) item isn't selected anymore (= it clears the selection) and cursor changes back to default one obviously - just like in Broken Sword 1.

    Forum Fan

    159 Posts

  • #8, by afrlmeMonday, 09. September 2013, 21:01 7 years ago
    well you could add a query inside of the mouse properties for left mouse button...

    if current object does not exist
    set item "[empty]"
    end if
    1
    2
    3
    4


    there is no query to check current item held with action parts so simplest solution, is what I've just added in the code box above. the if query checks if no objects or characters are present beneath the cursor & if there aren't any then it sets currently held item to empty.

    according to what you've written above it seems you don't need to do anything other than manually set the clicked on item as the currently held item; as long as it's not set as "dragged item" then the cursor will stay as whatever it currently is or whatever you assign it as via the set cursor action part.

    if you have a specific cursor to show the character is currently holding an item then you will need to create a condition; something like: "item_held?"... & add a query to the mouse over/out actions for each item.

    if condition "item_held?" is false
    set cursor "whatever_you_want"
    end
    1
    2
    3
    4


    the other thing I mentioned about the global Lua script is perfectly do-able but as I mentioned it's a little complicated & I'm a wee bit short on time at the minute to write the script or create an example.

    can you elaborate some more on object actions over item actions please?
    & to use item on an object, the object has to contain the "item dropped [item_name]" action or the immediate action version.

    Imperator

    6846 Posts

  • #9, by gustySunday, 15. September 2013, 15:43 7 years ago
    can you elaborate some more on object actions over item actions please?
    & to use item on an object, the object has to contain the "item dropped [item_name]" action or the immediate action version.


    I'll try to explain more properly. I set two actions for that one scene object like that:

    (1) "action executed" ('action' is name of my "left click" button/command - I have only one)
    a) display text by character (this is like a regular LOOK feature when you click on the object without any selected item)


    (2) "item dropped" (I tried "execution at destination" as well as "immediate", no difference at all. Of course that I specified an individual item)
    a) remove item from inventory
    b) display text


    What happen during the play test is when I choose the item in the inventory and click on scene object, my character walks to the object and then item is no more selected. Item still remains in the inventory and no character text is displayed. After this first click, like I said, item is no more selected=set (seems like it would execute "set item [empty]" instead of whole (2)). Then with a secondary and next left clicking it would performs correctly (1)

    Btw this behaviour I just described is same with or without the "if query" setup for left mouse button.


    I also tried to add two new entries to the object:

    (3) and (4) "cursor enters and leaves" = "set cursor" and it works just fine.

    Forum Fan

    159 Posts

  • #10, by gustySunday, 15. September 2013, 15:46 7 years ago
    well you could add a query inside of the mouse properties for left mouse button...

    there is no query to check current item held with action parts so simplest solution, is what I've just added in the code box above. the if query checks if no objects or characters are present beneath the cursor & if there aren't any then it sets currently held item to empty.



    Wow, it's working beautifully, thanks for that!

    Forum Fan

    159 Posts

  • #11, by gustySunday, 15. September 2013, 23:30 7 years ago


    if you have a specific cursor to show the character is currently holding an item then you will need to create a condition; something like: "item_held?"... & add a query to the mouse over/out actions for each item.

    if condition "item_held?" is false
    set cursor "whatever_you_want"
    end




    Well I doubt I got it right, but I came up with this setup. It's a quite messy solution and it doesn't work very well. I did screw something up, but I'm not sure what.

    [Btw yes, I have prepared an individual cursor for each item. That cursor is set via immediate action after clicking on the item in the inventory exactly like you suggested in your first post.]


    1) I created a new condition "itemX_held?", defaultly set on False

    2) I added a new entry for action to "itemX" - when "action" is executed (immediate):
    Change condition "itemX_held?" to True

    3) I set action for active object in the scene - when "Cursor enters":

    If condition "itemX_held?" is false
    Set cursor to "look"
    End if

    4) And for "Cursor leaves" I set:

    If condition "itemX_held?" is false
    Set cursor to "walk"
    End if
    Change condition "itemX_held?" to false


    Did you mean something like that or am I completely wrong? smile I'm not sure where exactly (in which place/event) should I change that condition back to False in order to get whole setup right :-/

    Forum Fan

    159 Posts

Write post