Changing the text position for a comment set without having to change position of ALL text

  • #1, by sophie-yMonday, 17. May 2021, 15:20 3 years ago
    Hi there - I'm fairly new to Visionaire, and completely inexperienced with any kind of coding, but I'm loving the learning curve of making my own game so far!

    I've recently added in a comment set for my main character when they carry out item interactions which don't work, but I'd like these to appear in the same position as my narration text (at the bottom of the screen, in the middle), instead of above my character's head. 

    I'm using a Broken Sword, past tense narration style, but also have lots present tense dialogue with NPCs in the game (appearing above my character's head). If the comment set text appears above the character's head, though, this appears as if he's walking around talking to himself which I'd rather avoid! Instead, I'd like the comments to be past tense narration, e.g. "That didn't work" as opposed to "That doesn't work", which would need to appear at the bottom to fit in with the rest of the game.

    The only option I've found so far is the script provided by afrlme in this thread - https://www.visionaire-studio.net/forum/thread/moving-commen... - but this changed the position of all text, or all the text spoken by my main character if I add in a text owner query.

    Is there any other way I can change the comment set position to the bottom middle of the screen, without having to change the position of ALL text, and allowing me to keep my character's dialogue above their head?

    I was going to try adding in a "Comment set placeholder" character and change the text position for that, but then realised comment sets are character-specific, so I couldn't assign the comment set from there to my main character. I also used use a similar (I think!) code, again from afrlme, to change my narration text position, which I was very grateful for! I wonder if this can be edited somehow to query whether the text is a comment set, rather than narration?

    Other than that, I'm completely out of ideas, as I have no clue where to start with any coding and I can't find a solution using the standard settings or action parts, so any help would be massively appreciated!

    Newbie

    6 Posts


  • #2, by afrlmeTuesday, 18. May 2021, 16:33 3 years ago
    I've sent Simon a ping on our Discord server to see if it's possible to check if a text belongs to a comment set. I'm not seeing any way to check after a quick look over the data structure tables myself, but maybe he knows a way.

    Anyway, to be honest the comment sets are a bit basic. You could create a manual one for each object/item & use narration texts instead. In the screenshots below you can see that I've created a called by other action type block & a value. Inside of the called by other action block (which I have renamed to "random_comment_set_1") I have created a set random value action part so that we can have it display a random display narration text action part which is selected via the elseif value queries. In the example scene object I have created an action at the bottom of the list so that when any item is dropped on the scene object it will call the called by other action block that I created earlier.

    It's more work for you, but not that much & it should work - also it's much more flexible than the comment sets as you can add whatever action parts/scripts to it as you like, which means you could have the character play certain animations instead of saying something, etc.

    https://i.gyazo.com/d059cfe558833fc0b775c1565cff348f.png



    Imperator

    7278 Posts

  • #3, by afrlmeTuesday, 18. May 2021, 16:58 3 years ago
    Ok thanks to Simon, it seems that it is possible to check if the displayed text belongs to a comment set.

    function updateTxtPos(text)
    
    
    
      if text.SavedObject.parent.tableId == eCommentSetEntries then
    
        text.Position = {x = game.ScrollPosition.x + (game.WindowResolution.x / 2), y = game.ScrollPosition.y + (game.WindowResolution.y - 50)}
    
        return true
    
      end
    
    
    
      return false
    
    
    
    end
    
    
    
    registerHookFunction("setTextPosition", "updateTxtPos")

    Delete the old text handler script you were using & add this one instead. You are only allowed one instance per project.

    Imperator

    7278 Posts

  • #4, by sophie-yThursday, 20. May 2021, 15:52 3 years ago
    Ok thanks to Simon, it seems that it is possible to check if the displayed text belongs to a comment set.

    function updateTxtPos(text)
    
    
    
      if text.SavedObject.parent.tableId == eCommentSetEntries then
    
        text.Position = {x = game.ScrollPosition.x + (game.WindowResolution.x / 2), y = game.ScrollPosition.y + (game.WindowResolution.y - 50)}
    
        return true
    
      end
    
    
    
      return false
    
    
    
    end
    
    
    
    registerHookFunction("setTextPosition", "updateTxtPos")

    Delete the old text handler script you were using & add this one instead. You are only allowed one instance per project.

    Ah thank you so much! I was so pleased when it worked I did a little happy dance in my chair!

    I loved your idea of making individual, manual comment sets for each item/object too, but the game is going to be on a pretty large scale so it would take quite a lot of extra work. I'll definitely keep it in mind as a solution for any unique comment sets I want to create, or instances where I want the character to do something instead of just saying something smile

    Newbie

    6 Posts

  • #5, by afrlmeThursday, 20. May 2021, 15:59 3 years ago
    No problem. smile

    Imperator

    7278 Posts