How to display text " Use item with obj" ?

  • #1, by AkcayKaraazmakSaturday, 04. July 2015, 22:58 7 years ago
    Hello mates,

    Lets say that we have a item called " pen " and we want to use the pen item on the paper object on the scene. And when we drag the pen on to paper object in scene, I want to write on the screen or on the inventory panel; " Use pen with paper" . How we can do this? smile


    Great Poster

    440 Posts

  • #2, by afrlmeSunday, 05. July 2015, 00:35 7 years ago
    You need to add names / conjunction words to the properties tab of each object / item. It's also possible to use the Lua hook function for action text.

    from the wiki:
    -- testing action text snippet which I pasted from the wiki...
    function myActionText(mousePos)
      -- individual action text: object name (in current language) of object below cursor, if there is no object then '<empty>' is shown as action text
      local obj = game:getLink(VGameCurrentObject)
      if obj:getId().tableId == eButtons then
        return 'current object: ' .. obj:getTextStr(VObjectName)
      return '<empty>'
    registerHookFunction("getActionText", "myActionText")

    function I wrote for updating the actual text...
    Update action text of current language with new text
    Written by AFRLme [Lee Clarke]
    -- * function which updates the action text of an object for the current language * --
    function setText(obj, txt)
     local texts = obj.TextTextLanguages -- get all texts belonging to the object
     -- + --
     for i = 1, #texts do -- iterate through the stored texts
      if texts[i].language == game.StandardLanguage:getId().id then
       texts[i].text = txt;  obj.TextTextLanguages = texts -- update old text with new text
       break -- no need to keep iterating, cancel the loop

    to use my function...
    setText(Buttons["use"].ButtonName, "new text") -- far as I remember. something like that anyway!


    7052 Posts

  • #3, by AkcayKaraazmakSunday, 05. July 2015, 00:43 7 years ago
    Thank you so much Lee!

    Great Poster

    440 Posts