Draw Action Text at Cursor

  • #1, by lukey-jFriday, 20. September, 08:26 2 weeks ago
    ive turned on Draw Action Text at Cursor

    i'd like to move the postion of the text so its under the Cursor not next to it

    im new to this! any help would be grand!

    Newbie

    3 Posts


  • #2, by esmeraldaSaturday, 21. September, 18:02 2 weeks ago
    As far as I'm aware, you can do this only with a script.

    This is what I use. Maybe I overcomplicated it, because I did other things as well and changed it to what you want.
    -- if anyone knows a simpler solution, please post it! --

    This script needs to go in the scripting section, set as definition script.
    (go to the scripting section, add a new entry, name it like you want and copy&past the script there. By default the checkmark for "definition script" is set, keep it that way - see image)

    This is the script:
    --** function to position the action text **--
    
    local txt = ""
    local pos = {x=0, y=0}
    local new_pos
    local buffer = 10
    
    function actiontext(mousePos,text)
      if text ~= "" then  -- if there is action text
        txt = text
        
     -- adjust text position 
        pos.y = mousePos.y + 50   
        pos.x = mousePos.x + 25   
        
        graphics.addDrawFunc("draw()", 1) 
        return ""
     else
    
       txt = ""
       
      end
       return text
    end
    
    
    registerHookFunction("getActionText", "actiontext") 
    
    
    function draw()
     if game.Dialog.empty then 
     
    if Conditions.Char_is_speaking.Value == false then   -- to hide the text while speaking // is changed in the text started event
      if game.HideCursor == false then
        local dim = graphics.fontDimension(txt) 
        local halfdim = math.floor(dim.x/2)  -- used to center text
         new_pos = {x = 0, y = 0}
       
       -- adjust position for text when near the edge
        if pos.x + halfdim + buffer > game.WindowResolution.x then 
         new_pos.x = game.WindowResolution.x - dim.x - buffer   
        elseif pos.x - halfdim <= buffer then
         new_pos.x = buffer
        else 
         new_pos.x = pos.x - halfdim  -- center text on x axis
        end
            
       -- position on y axis
        new_pos.y = pos.y 
      
      else
       txt = ""     
      end 
      
       -- draw the text --          
        if txt ~= "" then graphics.drawFont(txt, new_pos.x , new_pos.y, 1) end    
      
      end   
     end
    end
    
    
    -- functions to change the Condition "Char_is_speaking" on text start and text stop
    
    function onTextstart(text)
     if text.Owner.tableId == eCharacters and not text.Background then
      Conditions.Char_is_speaking.Value = true
     end
    end
    
    function onTextstop()
      Conditions.Char_is_speaking.Value = false
    end
    
    registerEventHandler("textStarted","onTextstart")
    registerEventHandler("textStopped","onTextstop") 


    In the script I use a condition that will be changed by the script whenever a character is speaking, but it needs to exist in the game. So somewhere in the game, create a condition and name it: Char_is_speaking, (exactly like this with the capital C, because Lua is case sensitive), set it to false.  I created the condition in the conditions tab of my main character, but it doesn't matter where you put it.

    In the script are a few lines where you need to adjust things. I marked them in the image with two orange lines.
    The first one is the "buffer". This is a variable I use to avoid having the text touching the edge of the screen. The text will stop moving when it is the amount of pixels you set here from the edge. I set it to 10, you can adjust that to your liking.
    The other two lines are the ones where the text position is set relative to the cursor position.
    When you set the animation center of your cursor image, this is the position of the cursor in the game. In the script you need to set the position for the text on the y-axis below your cursor (in my case this was 50) and on the x-axis centered of your image. (in my case 25)
    Adjust that to your cursor image.

    let me know if it worked ok for you.

    If you are using Discord - it's much more lively in the Visionaire Discord than here. So just pop in!

    Key Killer

    529 Posts

  • #3, by lukey-jSunday, 22. September, 18:00 2 weeks ago
    its working but seems to be screwing up my Speechbubbles im using the ArgoBubbles script and seem to be using the wrong font i have a font for interface and a font for Dialogue

    with your cursor script the bubbles seem to stay on screen

    Newbie

    3 Posts

  • #4, by esmeraldaSunday, 22. September, 18:45 2 weeks ago
    ah sorry, I didn't expect you to use any other scripts.

    The ArgoBubble script has an eventhandler for text stopped, like my script has. And there can be only one eventhandler for these events.
    So you need to call the one script inside the other.

    1. delete the last line in my script : "registerEventHandler("textStopped","onTextstop")" or add two -- to change it to a comment
    2. in the Argobubbles is a function where you can call other functions on "textStopped", in the section "advanced settings". That's where you call the funtion by adding: onTextstop()


    Key Killer

    529 Posts

  • #5, by lukey-jSunday, 22. September, 23:45 2 weeks ago
    Bingo!

    You are my hero!

    Newbie

    3 Posts

Write post