Speech bubbles

  • #1, z UraalSaturday, 18. May 2013, 08:59 hodinky 12 years ago
    Anyone found a painless way of having speech bubbles on character text? I'd imagine this is possible with LUA somehow but I'd love to hear about any solutions smile

    Bažant

    93 Posts


  • #2, z UraalSaturday, 18. May 2013, 09:18 hodinky 12 years ago
    Go home Amazon advert, you are drunk.

    Bažant

    93 Posts

  • #3, z marvelSaturday, 18. May 2013, 12:26 hodinky 12 years ago
    grin We will fix this issue!

    Zabiják klíčů

    599 Posts

  • #4, z afrlmeSaturday, 18. May 2013, 14:15 hodinky 12 years ago
    simplest solution: create speech bubble images with the text in them & add them to an interface & set which ones should show up via conditions or values. you can disable regular character text via: miscellaneous > Set text and voice output.

    or you could create a few speech bubble images & using Lua, show the required one above the characters head when needed.

    P.S: you can hide the adverts with adblock plus thing wink

    Imperátor

    7285 Posts

  • #5, z UraalSaturday, 18. May 2013, 15:40 hodinky 12 years ago
    So by using LUA scripting I would be able to keep my already written dialog (show text) and use LUA to show a speechbubble image behind that text?

    Bažant

    93 Posts

  • #6, z afrlmeSaturday, 18. May 2013, 15:59 hodinky 12 years ago
    yeah I don't see why not. just a matter of selecting an image size that suits the displayed text (would require a bit of experimentation on your part) & then a bit of math to determine where to display the speech bubble image correctly, which I think can be done by obtaining the current ActiveText x,y position & adjusting accordingly.

    http://wiki.visionaire2d.net/index.php?title=Data_Structure_...

    I don't currently have time to help with the scripting otherwise I'd work on the script myself wink

    * edit: I think another alternative would be to allow the player to draw/create shapes via a Lua function - don't think we can do this with VS currently without creating a function to do so first.

    Imperátor

    7285 Posts

  • #7, z SimonSSunday, 19. May 2013, 14:40 hodinky 12 years ago
    You could use the hooks that are made for something like this.
    registerEventHandler("textStarted", "textStarted") 
    registerEventHandler("textStopped", "textStopped") 
    registerHookFunction("setTextPosition", "setTextPos")
    
    pos={x=0,y=0}
    hook=false
    function textStarted(text)
       local data = text:getLink(VTextSavedObject)
       textOwner = text:getLink(VTextOwner) //this one is global
    
       if textOwner:getId().tableId == eCharacters then //only for Characters
          // now you should switch which bubble to show
           getObject("Conditions[bubble1]"):setValue(VConditionValue, true) //best way to have a condition for the bubble
           pos = {x=100, y=100} //example position
           hook = true
       end
    end 
    
    function setTextPos(text)
      if hook then
        if textOwner:getId().tableId == eCharacters
          text:setValue(VTextPosition, pos)
        end
      end
    end
    
    function textStopped(text)
       if hook then
         hook = false
        //hide all bubbles
      end
    end 
    


    The font you use for the bubble should have a max. width like width of the bubble, there's no other way to auto break the text.

    Kapitán

    1582 Posts

  • #8, z afrlmeSunday, 19. May 2013, 15:39 hodinky 12 years ago
    you're manually placing the text to the top of the screen though no?

    if wanted to create something like character expression/speech boxes used in the remastered versions of broken sword 2 then I suppose this would work well... but I think he wants to place the bubbles above the characters head? I think using shapes would work quite well for this as they can be made to fit around any text. users can format the text somewhat by dropping to a new line. only problem is that the text is centered & if you set text as left aligned then it ends up towards the right hand side of the player & would need correcting I guess.

    the method you've created would be good for adding the text into a box smile

    Imperátor

    7285 Posts

  • #9, z SimonSSunday, 19. May 2013, 15:54 hodinky 12 years ago
    the positions were just examples. i believe it is a better solution to use hooking and not to write all functions for every line of the text manually. That would make actions something like this:

    - show bubble
    - show text for bubble
    - display character text
    - hide text
    - hide bubbel

    So you can still have:

    - display character text

    and you just do all the operations in your luascript.

    you can set the text anywhere on the screen and there's no problem in positioning the bubbles and text in relation to the character, but i didn't write that all down, it's just example code. for now there's no option to draw shapes, and i believe that this won't come later, so you need to have premade bubbles.

    Kapitán

    1582 Posts

  • #10, z afrlmeSunday, 19. May 2013, 16:02 hodinky 12 years ago
    I know wink

    it could be something to consider adding to the source code later on as something optional the users could choose from & then allow them to decide on padding/position etc.

    Imperátor

    7285 Posts