Getting on-screen ACTION TEXT to preview the resulting interaction when dragging an ITEM over a SCENE OBJECT.... (USE KEY on DOOR)

  • #1, by andiliddellTuesday, 11. February 2014, 23:51 7 years ago
    Firstly I don't think I've ever experienced so much great help on a forum as this, big thanks to AFRLme for all of his help so far.

    This next hurdle might well be the end of my personal quest to get the verb coin interface to work as I wanted. I'm using RIGHT CLICK to open INVENTORY then LEFT CLICK to "pickup" an ITEM from the inventory, this can then be dragged over OBJECTS in the scene to "USE" the ITEM on the OBJECT.

    The Problem is the ACTION TEXT that appears at the top of my screen doesn't show this basic text as you hover over objects.... "USE KEY on DOOR"

    I must admit I'm ready to give up and go with a Sam n Max style UI, as it's so frustrating knowing exactly which parameters i need to access (from the datastructure wiki) and what I need to do, but lacking the understanding of the structure of the LUA code and the visionaire back end to actually get a handle on the things I need.

    I actually expected the engine to do this by default, otherwise what's the point of action text if it doesn't tell you what actions you can do with a dragged object, but I've been keen to try and script this myself and learn more about LUA in the process.

    It seems REALLY simple in my mind but is proving almost impossible to implement with my current level of knowledge, as I can't find a good explanation of all of the methods and data structures to learn from.

    in PSEUDO CODE this is what I need to do... ( I've given up trying to get my actual LUA working)

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------


    • On each scene object that needs this behaviour I add an "execute script" on "cursor enters object area" action in the editor
    • This calls a function named interactionText() created on a global definition script


    • I need this function to find out the following THREE pieces of information as STRINGS


    1) The NAME of the ITEM that the user has clicked on in the inventory which is now "stuck" to their mouse cursor e.g KEY
    The datastructure wiki says this is called GameUsedItem

    2) The NAME of the SCENE OBJECT that the users cursor is hovering over e.g DOOR
    The datastructure wiki says this is called GameCurrentObject

    3) The VERB to use for the ITEM which the user has clicked on in the inventory which is now "stuck" to their mouse cursor e.g USE
    AFRLme has already helped hugely in defining a way to add this to objects (use,push,pull,give etc)


    • Then all I need to do is join all THREE of these STRINGS together with the word "on" added in the middle

    creating a new string like this..."USE KEY on DOOR"


    • Finally that new STRING needs to be pushed out to whatever displays the ACTION TEXT on-screen

    The datastructure wiki is not clear how to do this, but AFRLme has helped me to amend this before

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------

    I have tried and tried to get all of these pieces together,and found some really useful scripts on the forum for finding parts of this but then it all goes to crap when I start to deal with getList, getLists, getObject, tables, languages, invalid fields and properties not existing in tables, and with no definitive list of what exists on each table or list type I'm just left guessing.... badly razz

    I would be hugely appreciative if anyone can either help me with this next level of understanding or put together a script for me that does the simple operations above.

    This would also help the community to get to a position where we have a functional action text system for the "draggable" inventory type.

    Here's hoping!

    Forum Fan

    178 Posts


  • #2, by afrlmeWednesday, 12. February 2014, 01:33 7 years ago
    damn! what a long post!

    in the case of dragged items it will be the scene object that brings up the action text on mouse over. no action text is displayed for dragged items; far as I can tell.

    umm I think I will wait until the morrow before I answer this post, as it's a bit late now & I want to unwind a wee bit.

    Imperator

    6846 Posts

  • #3, by andiliddellWednesday, 12. February 2014, 20:37 7 years ago
    Yeah, apologies for the epic post!

    Please don't feel obliged to have to answer it all. you've done me so many favours already smile

    If you could identify how I get a handle on the string name of these three objects that would be a huge starting point. smile

    Object under mouse
    Object "stuck" to mouse (drag n drop ui)
    current On screen action text.

    Much appreciated! smile

    Forum Fan

    178 Posts

  • #4, by afrlmeMonday, 17. February 2014, 18:23 7 years ago
    Here's a working script.
    --[[
    Global action name for dragged items (v1) [17/02/2014]
    Written by AFRLme
    -- + --
    alternatingfrequencies@hotmail.com | skype @ AFRLme
    --]]

    -- * local variables * --
    local item, txt, current, lang, old, new, icj, mcj -- empty variables

    -- * tables * --
    old = {} -- table which will contain original item names
    new = {} -- table which will contain updated names
    iw = {} -- intial word table
    iw["English"] = "Use "
    iw["French"] = "Usage "
    iw["German"] = "Benutzen "
    iw["Spanish"] = "Usar "
    cj = {} -- conjuntion word
    cj["English"] = " on "
    cj["French"] = " en "
    cj["German"] = " auf "
    cj["Spanish"] = " en "

    -- * function for udating object name with action text * --
    function itemActionName()
    item = game:getLink(VGameUsedItem) -- get currently held item
    current = game:getLink(VGameCurrentObject) -- get current object (under cursor)
    lang = game:getLink(VGameStandardLanguage):getName() -- get current game language
    -- + --
    if not item:isEmpty() then -- if held item exists then...
    txt = item:getLink(VObjectName):getLinks(VTextAll) -- get all texts for the held item
    for i = 1, table.maxn(txt) do if txt[i]:getLink(VTextLanguageLanguage):getName() == lang then item = txt[i]:getStr(VTextLanguageText) end end -- store item name
    -- + --
    new = current:getLink(VObjectName):getLinks(VTextAll) -- get all texts for the object under cursor
    for i = 1, table.maxn(new) do table.insert(old, new[i]:getStr(VTextLanguageText)) end -- insert string names of table above
    -- + --
    for i = 1, table.maxn(new) do if new[i]:getLink(VTextLanguageLanguage):getName() == lang then new[i]:setValue(VTextLanguageText, iw[lang] .. item .. cj[lang] .. old[i]) end end -- update object name with action text (initial word, item, conjunction word, object)
    end
    end

    -- * function for resetting object name back to original name * --
    function resetItemActionName()
    for i = 1, table.maxn(new) do new[i]:setValue(VTextLanguageText, old[i]) end -- reset all text (for each language) back to original text...
    end
    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
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46

    It just updates the text for currently selected language only but resets all texts for the last linked object back to default via a secondary table in which I stored the original string names of the object.

    P.S: It seems to work ok with the other script too.

    just edit the execute a script actions for the mouse over/out actions & replace them with:
    --[[ mouse over ]]--

    -- original
    renameBtn()

    -- replace with...
    renameBtn(); itemActionName()

    --[[ mouse out ]]--

    -- original
    resetBtn()

    -- replace with...
    resetBtn(); resetItemActionName()
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16

    Imperator

    6846 Posts

Write post