How to reset text repositioning script back to default Visionaire text position

  • #1, by el_geeSaturday, 20. October 2018, 11:44 A year ago
    Hey guys!

    I put a script I found in this forum to fix a bit of text position weirdness in a scene. 
    The script fixed that problem just fine, but it seems now that the 'called script' is permanently set throughout the rest of the game. Which doesn't work.

    I'm quite happy with the default script positioning of the game, so I was wondering if anyone knew how to either:
    - quit the called script 
    or
    - what the script for Visionaire's default text position is?

    Cheers!

    Newbie

    33 Posts


  • #2, by sebastianSaturday, 20. October 2018, 11:59 A year ago
    hi el_gee,

    what script did you use?

    Thread Captain

    2331 Posts

  • #3, by el_geeSaturday, 20. October 2018, 12:05 A year ago
    Hi Sebastian!

    I used.. 


    function adaptedTextPosition(text)
      -- show texts of character Hero 10 pixel below character position
      local owner = text:getLink(VTextOwner)
      if owner:getId().tableId == eCharacters and owner:getName() == 'hero' then
        local pos = owner:getPoint(VCharacterPosition)
        pos.y = pos.y + -150
    pos.x = pos.x + 1 
        text:setValue(VTextPosition, pos)
        return true
      end
      return false
    end

    registerHookFunction("setTextPosition", "adaptedTextPosition")



    The positions are my own tweaking

    Newbie

    33 Posts

  • #4, by afrlmeSaturday, 20. October 2018, 12:22 A year ago
    function adaptedTextPosition(text)
      -- show texts of character Hero 10 pixel below character position
      local owner = text:getLink(VTextOwner)
      if owner:getId().tableId == eCharacters and owner:getName() == 'hero' and game.CurrentScene:getName() == "insert name of scene here" then
        local pos = owner:getPoint(VCharacterPosition)
        pos.y = pos.y + -150
    pos.x = pos.x + 1
        text:setValue(VTextPosition, pos)
        return true
      end
      return false
    end
    registerHookFunction("setTextPosition", "adaptedTextPosition")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13

    replace insert name of scene here with the actual scene name -- names are case sensitive.

    the small tweak I made means the script will only work on the scene you specify.

    Imperator

    6771 Posts

  • #5, by el_geeSaturday, 20. October 2018, 12:37 A year ago
    thanks AFRLme!
    That fixed that issue.

    But I was wondering if there's a way to return to the default setting within a scene?
    There are certain times where just one part of a scene's text shows up in a weird place, where it could be nice to be able to just tweak that particular instance, and then go back to the normal setting.

    Newbie

    33 Posts

  • #6, by afrlmeSaturday, 20. October 2018, 12:57 A year ago
    You could replace the edit I made with a condition query instead, then you can manually determine when the script should take effect by changing the linked condition to true or false.

    function adaptedTextPosition(text)
      -- show texts of character Hero 10 pixel below character position
      local owner = text:getLink(VTextOwner)
      if owner:getId().tableId == eCharacters and owner:getName() == 'hero' and Conditions["ftp"].ConditionValue then
        local pos = owner:getPoint(VCharacterPosition)
        pos.y = pos.y + -150
    pos.x = pos.x + 1
        text:setValue(VTextPosition, pos)
        return true
      end
      return false
    end
    registerHookFunction("setTextPosition", "adaptedTextPosition")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13


    Create a condition somewhere that's easy for you to access, such as in the conditions tab of your main character & name it ftp & set it to false by default. To use it, you should change the condition to true just before any display text or group of display text action parts where you want to force the text position. Add another change condition action part when you no longer need to force the text position to set the condition back to false.

    Imperator

    6771 Posts

  • #7, by el_geeSaturday, 20. October 2018, 13:25 A year ago
    Ahhh thats so nice AFRLme!

    Think that's exactly what I was hoping for.

    Thanks for that and the speedy replies!

    Newbie

    33 Posts

  • #8, by afrlmeSaturday, 20. October 2018, 13:46 A year ago
    No problem. wink

    Imperator

    6771 Posts

  • #9, by el_geeSunday, 21. October 2018, 19:50 A year ago
    Hey guys,

    Sorry to already be back. 

    Really happy with the script I got last time, but have found that when my character is at the edge of the screen, parts of the text go outside the screen borders.

    Been looking around for a solution but haven't had any luck.

    Anyone know a script I can add to the current one? To keep text within the screen borders.

    Thanks.

    Newbie

    33 Posts

  • #10, by sebastianSunday, 21. October 2018, 21:02 A year ago
    by using the character position as your "anker point" this doesnt take the screen edge into account. I would suggest that you use the text.Position, instead of the character.Position. Thats the point axactly above the head of the character and should also have the screen edge detection calculated in.

    But you need to do some checking manually anyway: For example when you substract 150 pixels to display the text below the character: what happens, when your chraracter stands at the bottom of the screen? 

    Thread Captain

    2331 Posts

  • #11, by afrlmeSunday, 21. October 2018, 21:40 A year ago
    I believe it's above the character + -150. grin

    Imperator

    6771 Posts

Write post