Look object button in inventory tab [SOLVED]

  • #1, by blablo_101Monday, 16. July 2018, 13:34 2 years ago
    Hi! I have a question.
    I'm using a one-button cursor. I only use left click for my game.
    In the inventory I need to create an object to look items. I want to drag items in the eye icon and see a narration text with the description of that item. Image 1 
          
    But in the interface tab, I can`t create an ordinary object. I can`t create a new area with “item dropped”. I only can create buttons and areas with basic actions (like left click, right click, etc…). Image 2
          

    My first idea was to add a fake/transparent/permanent item in the game. I placed the fake item above the eye icon…
    But when I scroll the items with the arrows, my fake/transparent item changes position because it´s a placeholder and as a placeholder it´s become occupied by other items roll Image 3
          

    I don`t know if there is any way to fix an item place permanently in a specific position and prevent it from moving when scroll…




    The next thing I tried is to make an “action area” in the interface (by defining it as "Action area" in the properties tab). But, in the actions tab there is no "Item dropped" action part.
    Then, I realized that if I copy the “item dropped” action part from an item to the “Actions” tab “object” in the inventory, It works in the game… But in the visionaire editor something weird happens… The item dropped part appears invisible… Image 4
          

    This last experiment works perfectly in the game, but I`m not sure if this action can crash the game or create some kind of bug in the future…
    So, I really don`t know what to do…. Is there any way to add a “look object” button in the inventory interface?

    Thanks in advance!







    Newbie

    69 Posts


  • #2, by sebastianTuesday, 17. July 2018, 05:00 2 years ago
    the thing is that the engine works differently for handling that. It is designed to use Commands on Objects, not the other way around. 

    Either you switch the order: first clicking the command button and then using the set command on the item. 

    Or you would need some Lua which fires up by the buttons Left click function. There you need to check if an item is hold and if it is call its e. g. "look_at_<item name>" Action. 

    Thread Captain

    2336 Posts

  • #3, by blablo_101Thursday, 19. July 2018, 13:12 2 years ago
    Hi sebastian, thank you for your answer!

    Finally I have something that works.
    I have created a left click event to store the name of the item being dragged.
    registerEventHandler("mouseEvent", "onMouseEvent", {eEvtMouseLeftButtonDown}) 
    function onMouseEvent(eventType, mousePosition)
    <b>  </b>-- action on left click to not tease the drag item action
        if eventType == eEvtMouseLeftButtonDown
        then
          local v_item = nil
          if not game.UsedItem:isEmpty()
          then
            if game.UsedItem:getName() ~= v_item
            then
                v_item = game.UsedItem:getName();
                Values.current_item_string.String = v_item
            end

            if Values.current_item_string.String == "Key"
            then Values.current_item_num.Int = 1
            end
              --assign a numeric value, comparing strings does not work to me :S
            if Values.current_item_string.String == "Bottle"
            then Values.current_item_num.Int = 2
            end

            if Values.current_item_string.String == "Glass"
            then Values.current_item_num.Int = 3
            end  
            
          else
            if game.UsedItem:isEmpty() and v_item ~= nil
            then v_item = nil;
            end
          end
        end
      end
    else
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34


    In the inventory,  when click on the eye object, call this script:
    if not game.UsedItem:isEmpty() --if have an item dragged
    then
       startAction(description_item)
    end
    1
    2
    3
    4

    "description_item" action compares the value assigned to "current_item_num" with a number.

    If value 'curren_item_num'=1
    Narration: Description for Key item here
    End if
    If value 'curren_item_num'=2
    Narration: Description for Bottle item here
    End if
    If value 'curren_item_num'=3
    Narration: Description for Glass item here
    End if
    .
    .
    .

    Newbie

    69 Posts

  • #4, by sebastianThursday, 19. July 2018, 13:22 2 years ago
    very complicated but if it works, it works smile


    Would be also possible to just use the following on the left click action :

    Execute a script:
    if not game.UsedItem:isEmpty() then 
      startAction(Actions["desc_".. game.UsedItem:getName()] ) 
    end
    1
    2
    3


    and in every items actions you create an action called "desc_(itemname)" where you do narration

    Thread Captain

    2336 Posts

  • #5, by blablo_101Thursday, 19. July 2018, 13:40 2 years ago
    Great! I'll try .

    Newbie

    69 Posts

  • #6, by sebastianThursday, 19. July 2018, 19:07 2 years ago
    Great! I'll try .


    Hope this works. Was on the bus to work when i wrote it out of my mind razz

    Thread Captain

    2336 Posts

  • #7, by blablo_101Friday, 20. July 2018, 08:56 2 years ago
    Hey sebastian, works perfect.

    Thank you very much !


    Newbie

    69 Posts

Write post