[SOLVED] Change position of text

  • #10, z brut69Sunday, 11. August 2013, 00:05 hodinky 12 years ago
    There is a much MUCH easier way. Just create an "empty" character. Create an object and set it where you want the text to appear (empty object). Set that newly created character to have the starting point of the new object you just created.

    Then just have the empty character talk when ever you want the text to be in another location.
    Thats how I do it 100's of times

    Čestný člen

    266 Posts


  • #11, z afrlmeSunday, 11. August 2013, 01:47 hodinky 12 years ago
    There is a much MUCH easier way. Just create an "empty" character. Create an object and set it where you want the text to appear (empty object). Set that newly created character to have the starting point of the new object you just created.

    Then just have the empty character talk when ever you want the text to be in another location.
    Thats how I do it 100's of times


    depends on exactly what it is he wants to achieve, but yeah an empty character is also possible.
    or narration text via miscellaneous.

    Imperátor

    7285 Posts

  • #12, z rauleMonday, 12. August 2013, 10:15 hodinky 12 years ago
    Hello and thanks for your answers!

    @ARFLME
    what im trying to do is:
    i have a scene where the player starts from a 1st person persperktive while two npc's are looking at him very close to the camera (one guy left, the other right).
    Because the npc's are that big in the picture the text can't appear above them.

    So what im trying to do with LUA is to place the text somewhere else instead above the characters.
    Furthermore the left npc should have the align left, the right character right and the player (1stPerson) centered.

    to your questions:
    i dindnt knew that i cant use bbcode in quotes. i just wanted to mark the line.
    i manged to display the text where i want, works fine!
    I added game because i have no idea what im doing wink - i was just playing a little bit with the code (learning by doing)
    when im using VGameTextAlignment, the text moves over to the right, nothing more. i tested all possible values (0-5). i tried it with npc 1 and 2 aswell with the player.

    so the algin is the main problem on this case wink


    @brut69
    yeah i considered that, and im doing it with the player-character in this case. but i have some trouble with the talking animations when i use a "empty" character. and as far as i know i only can set up the text alignment for the game not for particular spoklen text.


    thanks to you!

    Raul



    Bažant

    53 Posts

  • #13, z afrlmeMonday, 12. August 2013, 16:23 hodinky 12 years ago
    Yeah er code blocks ignore all code as it is for displaying code rather than executing it.

    ok so this is a general script...
    can't say whether or not it works & there's some bits of information you need to fill in yourself...

    I've added an if query to check the name of the current scene as I assume from your description that this is only to be used for that particular scene, so you need to add the name for that scene to the script (line 14) & you also need to enter the character names & enter text alignment integer value for each (0=left, 1=right, 2=center) as well as fill in the XY co-ordinates of the text for each.

    I've also added a textStopped event listener which checks if text is centered & if not then it resets text back to centered after displayed text has finished displaying...

    well at least this script should work in theory, but just to let you know - I haven't tested it, it's all written off the top of my noggin'!

    --[[
    registerHookFunction example for Raule (v1)
    Written by AFRLme
    -- * --
    label@alternatingfrequencies.com | aim, skype, trillian @ AFRLme
    --]]
    
    -- * let's create the function which controls the position of the text * --
    function setTextPosHook(text)
     tblHook = {} -- create a table
     tblHook["_temporary_"] = "" -- set table to temporary
     tblHook["owner"] = text:getLink(VTextOwner) -- store the currently displayed texts owner
     -- * --
     if game:getLink(VGameCurrentScene):getName() == "enter scene name here" and tblHook["owner"]:getId().tableId == eCharacters then
      if tblHook["owner"]:getName() == "enter charater 1 name here" then text:setValue(VTextPosition, {x=, y=}); return true
      elseif tblHook["owner"]:getName() == "enter charater 2 name here" then text:setValue(VTextPosition, {x=, y=}); return true
      elseif tblHook["owner"]:getName() == "enter charater 3 name here" then text:setValue(VTextPosition, {x=, y=}); return true 
      end
     end
      return false
    end
    
    -- * let's create a function for determining what should happen when displayed text ends * --
    function onTextStopped()
     if game:getInt(VGameTextAlignment) ~= 2 then game:setValue(VGameTextAlignment, 2) end -- resets alignment back to center...
    end
    
    -- * let's create the text event position handler * --
    registerHookFunction("setTextPosition", "setTextPosHook")
    -- * let's create the event listener that determines when a text has ended * --
    registerEventHandler("textStopped", "onTextStopped")
    

    Imperátor

    7285 Posts

  • #14, z rauleThursday, 15. August 2013, 12:12 hodinky 12 years ago
    Hi,
    thanks alot for your work!

    but unfortunaly i doesnt work right.
    its changes the position like i want to but it sets the allgnment always for the next sentence - not for the actual shown one.

    for example:
    i
    character 1: align left / charakter 2: align right (scripted)

    the output would be:
    charakter1: "bla bla" (shown left because game option is left)
    character2: "bla bla" (align left)
    character1: "blub" (align right)
    character2: "bla bla" (align left)
    character2: "blabla" (align right)
    aso

    if i leave the onTextStopped() function in the script, it starts the next sentence with the alignment i choose there. and after that like above.

    i hope its clear. im very sorry if not.

    but please, don't bother!!!
    maybe i find out myself one day wink))

    thanks for your help!

    best
    raul

    Bažant

    53 Posts

  • #15, z afrlmeThursday, 15. August 2013, 14:44 hodinky 12 years ago
    hmm there's also a textStarted event handler..

    I asked David the other day what the difference is between textStarted & the hook function method...
    he said that text started/stopped allow you to determine what should happen before text is displayed and after text is displayed.

    Ok simple solution...
    Before/after each displayed text action part for that scene: add an execute a script action part.

    select action part > action, script > execute a script:
    game:setValue(VGameTextAlignment, integer)


    *edit: I didn't see any action parts for setting text alignment hence why I've said to use the execute a script action part.

    I've revised the code above & removed the text align parts.

    Imperátor

    7285 Posts

  • #16, z rauleThursday, 15. August 2013, 17:19 hodinky 12 years ago
    NICE!

    thats what i was looking for!

    thank u very much!

    Bažant

    53 Posts

  • #17, z afrlmeThursday, 15. August 2013, 18:07 hodinky 12 years ago
    no problem, we got there in the end! wink

    Imperátor

    7285 Posts

  • #18, z constantinWednesday, 19. July 2017, 18:11 hodinky 7 years ago
    thanks for this topic - i found out, how to do it for different characters. :-)

    Fanoušek fóra

    167 Posts