Login / Registrieren
DE EN FR ES IT CZ
Zurück Nach oben

Moving comment set text position away from character?

  • #1, by Radicaa 11 years ago Zitieren
    Hey, just a quick question I guess. In our game the MC never speaks and the exposition is always displayed as narration text rather than characther text. Comment sets however always place the text above the character. Is there any way to change the position of the comment set text? (perhaps with Lua?)

    Thanks
  • #2, by afrlme 11 years ago Zitieren
    I'm not really sure you can just force comment set text away from a character. You can reposition all text spoken by the character &/or narration text though...

    Just use the registerHookFunction with the textPosition hook.

    local offset = 34 -- offset from bottom (in pixels)
    local x = (game.WindowResolution.x / 2) -- calculate center value of resolution width
    local y = (game.WindowResolution.y - offset) -- calculate offset of text from bottom
    
    function txtPos(text)
      text:setValue(VTextPosition, {x = game.ScrollPosition.x + x, y = game.ScrollPosition.y + y})
      return true
    end
    
    registerHookFunction("setTextPosition", "txtPos")
    

    ...this script will automatically set the text to the bottom-center of the screen. Adjust offset to adjust distance from the bottom.
  • #3, by Radicaa 11 years ago Zitieren
    Thank you very much. I'll try it.
  • #4, by Radicaa 11 years ago Zitieren
    Well, it works but now all text, including NPC:s text is moved to the narration position. Is there anyway to tell the script only to position the text of the main character in this manner?
  • #5, by afrlme 11 years ago Zitieren
    Indeed. You can query the textOwner.

    local offset = 34 -- offset from bottom (in pixels)
    local x = (game.WindowResolution.x / 2) -- calculate center value of resolution width
    local y = (game.WindowResolution.y - offset) -- calculate offset of text from bottom
    
    function txtPos(text)
     if text:getLink(VTextOwner):getName() == game.CurrentCharacter:getName() then
      text:setValue(VTextPosition, {x = game.ScrollPosition.x + x, y = game.ScrollPosition.y + y})
      return true
     end
    end
    
    registerHookFunction("setTextPosition", "txtPos")
    
  • #6, by Radicaa 11 years ago Zitieren
    Nice. I guess I have to enter the character name into the getName() part? or is the part "game.CurrentCharacter:getName ()" already assigning it to the main character?
  • #7, by afrlme 11 years ago Zitieren
    game.CurrentCharacter:getName() is automatically returning the string name of the current character. So if the string name of the text owner is the string name of current character it will reposition the text, otherwise it will ignore the text.

    P.S: I messed up the script a little previously. I've updated the block with the correct code.
  • #8, by Radicaa 11 years ago Zitieren
    Alright, thanks again. What the world do without AFRLme? grin
  • #9, by afrlme 11 years ago Zitieren
    No idea? In the case of the online world regarding VS... probably curl up into a little ball & cry. In the case of the real world... carry on as per usual, most likely. grin