change cursor - item inventory

  • #20, by EinzelkämpferMonday, 24. July 2017, 14:26 5 years ago
    I haven't read through all the posts of this thread, but looking at the initial request - having the dragged item (cursor) looking different than the item in the inventory - there is a very easy way to achieve this (and I believe, it hasn't been mentioned already).

    For your item create two different graphics: one for the inventory, one for the cursor when dragged. Add the first one as a 1-frame animation to your item and the second one as the image file. That should do the trick. No further messing with commands or scripts necessary.

    Newbie

    81 Posts


  • #21, by stered86Tuesday, 25. July 2017, 11:10 5 years ago
    einzelkaempfer, that would be the easiest way if we could set a center point for image files, but as for now the center is automatically set to the center of the image while I want it to be in the upper left corner (where the point of the arrow is).
    I could draw larger images with the cursor right in the center, but I think the sprites would become too big.

    Sebastian, thank you for your tip, it seems to be working fine apart the cursor changing (I really can't use lua, so I'll be waiting for your code)!

    There just another thing about this system I don't know how to fix: after I use a "left click + item" on an object, the engine automatically reset the standard command, while I'd like the item to remain active until the player press the mouse right button.

    Newbie

    62 Posts

  • #22, by sebastianTuesday, 25. July 2017, 11:54 5 years ago
    arg shit, forgot to post my code, sorry. 

    Hopefully this afternoon then smile 


    Thread Captain

    2346 Posts

  • #23, by EinzelkämpferTuesday, 25. July 2017, 14:29 5 years ago
    einzelkaempfer, that would be the easiest way if we could set a center point for image files, but as for now the center is automatically set to the center of the image while I want it to be in the upper left corner (where the point of the arrow is).
    I see.

    I could draw larger images with the cursor right in the center, but I think the sprites would become too big.
    That would work, though. If your cursor image is supposed to have 100 x 100 px, make the sprite 200 x 200 px and put the image in the lower right corner (and add your arrow graphics to the center if you like). Keep the rest of the image transparent. The point of interest is in the center, but appears to be on the upper left. Works fine for me.

    If not for you, then maybe this is of help for others, who are looking for some simple non-lua solution.

    Newbie

    81 Posts

  • #24, by sebastianTuesday, 25. July 2017, 22:31 5 years ago
    allright. So before you can use my script you need to add for each item an action which is called "cur_<exact_itemname>"
    also create an action "cur_default" anywhere (i did it in my coin interface)

    so an item named "spear" has an action called "cur_spear" . This action sets the cursor to the "spear cursor"

    The "cur_default" action sets the cursor to the default cursor

    Also create a condition called "item_used" , which is by default false

    Script section, Set as definition script:
    local itm = nil
    
    function cursorLoop()
     if not game.UsedItem:isEmpty() then
      if game.UsedItem:getName() ~= itm then
       itm = game.UsedItem:getName(); startAction(Actions["cur_" .. itm])
       Conditions["item_used"].ConditionValue = true
      end
     elseif game.UsedItem:isEmpty() and itm ~= nil then
      itm = nil; startAction("Actions[cur_default]")
      Conditions["item_used"].ConditionValue = false
    
     end
    end
    
    registerEventHandler("mainLoop", "cursorLoop")
    
    



    Thread Captain

    2346 Posts

  • #25, by afrlmeWednesday, 26. July 2017, 00:18 5 years ago
    Aye bit of a pain in the arse not being able to change mouse cursor with Lua script. I asked Simon to implement Lua support for it a while back. Not sure if he got round to it, or forgot all about it.

    Imperator

    7211 Posts

  • #26, by sebastianWednesday, 26. July 2017, 00:51 5 years ago
    would be a great addition razz

    Thread Captain

    2346 Posts

  • #27, by EinzelkämpferWednesday, 26. July 2017, 01:03 5 years ago
    I still don't see the advantage of using commands as items or setting the dragged cursor via Lua.

    But do as you like. I'll stick with what I think is the easy way... wink

    Newbie

    81 Posts

  • #28, by afrlmeWednesday, 26. July 2017, 01:40 5 years ago
    I still don't see the advantage of using commands as items or setting the dragged cursor via Lua.

    But do as you like. I'll stick with what I think is the easy way... wink
    grin

    Imperator

    7211 Posts

  • #29, by sebastianWednesday, 26. July 2017, 07:38 5 years ago
    I still don't see the advantage of using commands as items or setting the dragged cursor via Lua.

    But do as you like. I'll stick with what I think is the easy way... wink
    le possibilities :p

    I use it to have an indicator when an item is above an object like in mobkey island 3 . So i need something with inactive/active animations. 

    Thread Captain

    2346 Posts

  • #30, by EinzelkämpferWednesday, 26. July 2017, 10:32 5 years ago
    I use it to have an indicator when an item is above an object like in mobkey island 3 . So i need something with inactive/active animations.
    Good point.

    But the best solution for this would be forcing the developers to add it to the system. grin

    Newbie

    81 Posts