Custom command property names for same interface action button (use door handle, pickup coin, press button)

  • #20, by andiliddellTuesday, 11. February 2014, 01:22 11 years ago
    Thanks again AFRLme.

    Im now trying to code the manual action text for the dragged item razz

    I've dived into the data structure wiki and think i can build my own custom action text (for dragging an item over a scene object) from the current GameUsedItem, plus some of the renamebut function above, to get the cmd_state and finally the scene Object Name as you mouse over it.

    Ive fallen at the first hurdle as i can't seem to get the string name of the GameUsedItem mentioned in the datastructure under the game table

    local activeObj
    
    function dragItem()
       activeObj= game:getLink("VGameUsedItem"):getName() -- get current gameusedItem name
       print("active dragged object:", activeObj)
    end
    
    


    I'm unsure of whether i should be using game:getLink or game:getObject and what the differences between :getStr(VValueString) and :getName() are?

    Forum Fan

    178 Posts


  • #21, by afrlmeTuesday, 11. February 2014, 03:18 11 years ago
    hmm... getObject doesn't have game in front of it. use game in front of the first thing you use getLink for. also only wrap text inside of getObject with "..." getLink & other get/set functions do not contain quotation marks; apart from the bits where you need to add a string.

    getName() returns the objects name & not the displayed names... according to David (I've not tested yet) but we supposedly have a getText function for next version rather than having to do all that textlanguage textall nonsense.

    hehe - I see you have started adding comments after things too grin I only do that because I have shitty short term memory so it's just as much there for me to remind myself what each thing is for & also to explain to everyone else who reads the scripts.
    local obj, texts, lang
    
    function dragItem()
     obj = game:getLink(VGameUsedItem)
     lang = game:getLink(VGameStandardLanguage):getName()
     texts = obj:getLinks(VTextAll)
     print("active dragged object:", obj:getName()) -- will print item table name
     for i = 1, table.maxn(texts)
      if texts[i]:getLink(VTextLanguageLanguage) == lang then print(texts[i]:getStr(VTextLanguageText)) end
     end
    end
    

    I think? (off the top of my head)

    also I think that I could technically shorten the other script I wrote... the if statements are not really needed.

    Imperator

    7278 Posts

  • #22, by fritozTuesday, 11. February 2014, 08:56 11 years ago
    i just want to say thanks to both AFRLme and andiliddell , ive just finished reading this whole thread, and have learned alot- what you wanted to achieve sounded easy enough, but it took some real skills to pull it off! AFRLme must be a scripting Wizard!

    smile

    Newbie

    16 Posts

  • #23, by afrlmeTuesday, 11. February 2014, 12:58 11 years ago
    i just want to say thanks to both AFRLme and andiliddell , ive just finished reading this whole thread, and have learned alot- what you wanted to achieve sounded easy enough, but it took some real skills to pull it off! AFRLme must be a scripting Wizard!

    smile


    not really... I only started learning Lua early last year sometime I think but it was surprisingly quite similar - in a way - to jquery, java etc. & yeah the script should have been simple enough to sort out, but I ended up forgetting (short term memory) that I had to access the language texts instead of the object names.

    Imperator

    7278 Posts

  • #24, by EvrenFriday, 14. March 2014, 07:47 11 years ago
    I want to make this interface too but I couldn't follow the code. I was using Unity game engine now I switched to Visionaire. Unfortunately I couldn't find good tutorials for Visionaire scripting. I was thinking when I want to change the command name, I would add a value to that scene object (a button) and call it CustomVerbName and change the name of command according to that value when mouse is over the command button. (monkey island 3 verb coin like interface)
    I will try to go over the thread again roll

    Newbie

    19 Posts

  • #25, by EvrenFriday, 14. March 2014, 07:50 11 years ago
    ... When mouse button is held, I save the object (GameSavedObject I assume) then I will check its CustomVerbName value. But by default my objects won't have that value.

    Newbie

    19 Posts

  • #26, by afrlmeFriday, 14. March 2014, 12:27 11 years ago
    http://wiki.visionaire-tracker.net/wiki/Compiled_Index_of_Lu... - I have been compiling Lua scripts for Visionaire Studio here; written by myself & others. I've not added all of them yet but I have been writing a little guide on how each script works.

    See the left hand navigation menu of the wiki for more Lua script related pages.

    http://wiki.visionaire-tracker.net/wiki/Scripting - this teaches you about scripting in vs.
    http://wiki.visionaire-tracker.net/wiki/Data_Structure - a list of controllable data tables
    http://wiki.visionaire-tracker.net/wiki/Player_Commands - exclusive vs functions
    http://wiki.visionaire-tracker.net/wiki/Common_Commands - common vs functions
    http://wiki.visionaire-tracker.net/wiki/Basic_lua - introductory guide to Lua (I've more to add)

    http://wiki.visionaire-tracker.net - new wiki for vs I am working on.
    wiki.visionaire2d.net - old wiki

    Hopefully some of this stuff helps.

    I'll see if I find the time to create a page & guide for this script later on.

    Imperator

    7278 Posts

  • #27, by AlexFriday, 14. March 2014, 18:46 11 years ago
    I've added a method (getTextStr) for Vis 4.0 to easily get the language dependent text.
    So iterating of language texts is not necessary anymore: http://wiki.visionaire2d.net/index.php?title=Scripting#getTe...

    This combined with a "getActionText" hook function should make it quite easy to generate any action text you want.

    What you could also do (for the initial question of this thread - I haven't followed the whole thread): create separate commands (use, press, pickup, ...) and set a condition for each command. When you hover an object only set those conditions to true if an action for this command exists. In lua you could easily do this in a generic way so one function called in the mouse move event handler should be enough.

    Great Poster

    378 Posts

  • #28, by afrlmeFriday, 14. March 2014, 19:11 11 years ago
    yeah the idea behind the script was that a value was set in the editor & then if said value was met, then return the string command word.

    I know that getText has been added. I was going to address this issue after you have released 4.0 as the getTextAll was not returning anything in the beta version David sent me (the one with the installer).

    P.S: I think I wrote a more compact version of this script. One that automatically checked language using for loop.

    Imperator

    7278 Posts

  • #29, by andiliddellFriday, 14. March 2014, 19:24 11 years ago
    This is great news, thanks alex!

    Now you know what my next question will be....

    When will vis 4.0 be available? smile

    Forum Fan

    178 Posts

  • #30, by AlexFriday, 14. March 2014, 19:27 11 years ago
    I know that getText has been added.

    I added getTextStr (and not getText) just today, so you can't know about that wink

    Plan for vis 4.0 is unchanged (end of month).

    Great Poster

    378 Posts