Keep an Item (UsedItem) after use/combine

  • #1, by PanSFriday, 19. July, 10:34 5 months ago
    I  maybe have an unusual method to use inventory items. Every item has its own cursor and I used this script for it when clicking on an item:
    function setObjectCursor()
      if game.CurrentObject then
        local objName = game.CurrentObject
     
        game.ActiveCommand = Interfaces.int_interactions.Buttons.act_combine
        print(game.ActiveCommand)
       
        if game.Cursors["cur_"..objName:getName()] then
          system.cursor = game.Cursors["cur_"..objName:getName()]
        else
          system.cursor = game.Cursors["cur_obj_default"]
        end

        game.UsedItem = objName -- game drop this part after try to combine
        print(game.UsedItem)

        lastUsedItem = objName
      end
    end
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20

    Works fine but after combine an item with something the engine clears game.UsedItem. So there is still  the correct cursor and combine command but no item to use.

    At the moment I bypass this problem with an script which is called if clicked the left mousebutton and combine command is still active:
    function getUsedItem()
        game.UsedItem = lastUsedItem
    end
    1
    2
    3
    4

    Is there a better method. Maybe an option or function in Visionaire Studio or something I didnt see or so?

    Newbie

    56 Posts


  • #2, by afrlmeFriday, 19. July, 13:07 5 months ago
    It's probably to do with what you have set "activate standard command" to in the main game settings section of your project. Only after successful execution or always will clear the item/command on left click, though the former will only clear if you click on an object/character/item that contains x command/item in the actions list.

    You current method sounds about right, but that depends on how you setup what I just mentioned. Never would never clear the current item/command, & you would have to manually reset the item/command yourself, via scripting or action parts or the mouse properties section of the editor.

    Imperator

    6633 Posts

  • #3, by PanSFriday, 19. July, 13:55 5 months ago
    active standard command is on "never (ger: Nie)"

    So the command (combine) and the cursor (item_cursor) stay but the item doesnt.

    My method works like that:
    You click on the item and the script starts (setObjectCursor()).

    If you click on nothing in a scene, the char walks to the position (how I want it)-> command (combine), cursor AND item remain active

    If you click on an action-area in the scene or an other item in inventory it ALLWAYS starts a action. Mostly only the char says something like "I cant combine that" -> command (combine) and the cursor remain, BUT the item doesnt. UsedItem is now "---empty---"

    I attach a pic for better understanding what happens when interacting with the world.

    Maybe its a bug?

    Newbie

    56 Posts

  • #4, by afrlmeFriday, 19. July, 14:16 5 months ago
    it could be that objects clear automatically when you left click on something? I don't personally use items that way. I use a pure command based system with commands linked to cursors. When I use command "left_click" on an item it sets command "itm_item-name" & changes to the cursor linked to the command.




    Imperator

    6633 Posts

  • #5, by PanSFriday, 19. July, 17:37 5 months ago
    Oh, nice idear. Next game I should use this way grin

    Could "SavedObject" works in my case or caus it troubles with other functions?

    Newbie

    56 Posts

Write post