Objekttext auf zwei Linien

  • #1, by irinaWednesday, 19. April 2023, 17:07 A year ago
    Hallo zusammen

    Kann der Objekttext auf zwei Linien angezeigt werden ?

    Wäre toll wenn le pont unterhalb von die Brücke stehen würde. Ist das möglich und wie? 

    LG Irina

    Newbie

    14 Posts


  • #2, by esmeraldaThursday, 20. April 2023, 14:15 A year ago
    Ich gehe mal davon aus, dass es um den Aktionstext geht, also die Objektnamen und Charakternamen, die direkt am Cursor angezeigt werden können. (Objekttext ist in meinem Verständnis der Text der mit dem Aktionsteil "Objekttext anzeigen" aufgerufen wird.)

    Ohne auf ein Script zurück zu greifen, geht es leider nicht.

    Vielleicht wäre es einfacher, eine Einstellung zur Sprachwahl hinzu zu fügen? Oder ist die zweisprachige Darstellung genau das, was du willst?

    Zum Scipt: AFRLme hatte vor einer Weile auf dem Discordserver von VS ein Script geteilt, mit dem man die Funktion des Aktionstextes mit der Draw-Funktion nachbauen kann.
    Dazu muss man in den Spieleinstellungen den Aktionstext ganz ausschalten und ein Script als Definitionsscript einfügen. Damit kann man die Position des Aktionstextes modifizieren.

    Ich habe das Script soweit abgeändert, dass damit auch mehrere Zeilen möglich sein sollten. 
    Der Name des Fonts (bei mir Action_font) müsste angepasst werden, genauso wie die Position. Ich wollte den Text zentriert unter dem Cursor.

    function objName(obj)
      local t = obj:getId().tableId -- store table ID belonging to the linked visOBJ
      -- + --
      if t == eObjects then -- check if scene object or item
        return obj:getTextStr(VObjectName) -- return object/item name
      elseif t == eCharacters then -- check if character
        return obj:getTextStr(VCharacterName) -- return character name
      elseif t == eButtons then -- check if interface button
        return obj:getTextStr(VButtonName) -- return interface button name
      end
    end
    
    
    function draw()
    
      local txt = ""
      if objName(game.ActiveCommand) ~= "" then txt = txt .. objName(game.ActiveCommand) end
      if not game.CurrentObject:isEmpty() then txt = txt .. " " .. objName(game.CurrentObject) end
      local font_used = Fonts["Action_font"] -- set font
      graphics.font = font_used 
    
      -- + --
      txt = txt:gsub("","\n") -- change linebreak to readable linebreak
      local lines = graphics.performLinebreaks(txt)
      local dim = {x=0, y=0}
      local pos = getCursorPos()
    
      pos.y = pos.y + 20 -- y position of text 20 pixel below cursor position
    
        for k,v in ipairs(lines) do 
          local tempdim = graphics.fontDimension(v)
          if dim.x < tempdim.x then dim.x = tempdim.x end -- get the dimension of the longest line
        end
      pos.x = pos.x - game.ScrollPosition.x - dim.x / 2 -- x postion of text centered on cursor postion
          if dim.x game.WindowResolution.x - dim.x - 15 then pos.x = game.WindowResolution.x - dim.x - 15
        end 
    
       -- draw the text line by line -- 
        for k,v in ipairs(lines) do 
          local tempdim = graphics.fontDimension(v)
          local text_pos = {x = 0, y = 0} 
          text_pos.x = pos.x + (dim.x - tempdim.x)/2
          text_pos.y = pos.y + (k-1)* (font_used.Size + font_used.VerticalLetterSpacing)
    
          if #txt > 0 then graphics.drawFont(v, math.floor(text_pos.x) , math.floor(text_pos.y), 1) end
       end
    
    end
    
    graphics.addDrawFunc("draw()", 0) 


    Die Forensoftware zerschießt leider den Code ein wenig. Die Zeile müsste  txt = txt:gsub("_br/_".."_>","\n") lauten, ohne die Unterstriche _  .

    Key Killer

    513 Posts

  • #3, by esmeraldaThursday, 20. April 2023, 14:37 A year ago
    Nochmal als Screenshot zum Vergleichen. Ich bin nicht sicher, ob noch etwas verändert wurde.

    Ändere die letzte Zeile zu:  
    graphics.addDrawFunc("draw()", 1) 
    damit der Text über Interfaces, z.B. Inventar, geschrieben wird (0 = unter Interface, 1 = über Interface)


    Key Killer

    513 Posts

  • #4, by irinaThursday, 20. April 2023, 20:39 A year ago
    Vielen Dank esmeralda für den Aufwand! 

    Am Weekend schaue ich es mir an! 

    Ja ich möchte, wenn man mit der Maus über ein Objekt fährt dass der Text auf 2 Linien angezeigt wird. 1x auf Deutsch und 1x auf Französisch, jeweils gleichzeitig. ??

    Lg Irina 

    Newbie

    14 Posts

  • #5, by irinaThursday, 20. April 2023, 20:41 A year ago
    Ohne ?? Am schluss. Sollte ein Smiley sein. (Kennt visionaire wohl nicht)

    Newbie

    14 Posts