Jump to content

How to create kneeboard jpg from text using lua


chromium
 Share

Recommended Posts

Hi everyone,

 

I'm looking for a way to create kneeboard size .jpg image (or .pdf) starting from a lua text string. Is there a way to do so w/o having to install any software or addition?

 

Thanks!

ChromiumDis.png

Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Openbeta: https://github.com/Chromium18/DSMC

 

The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.

Link to comment
Share on other sites

  • 10 months later...

Create lua file inside kneeboard folder. Call it 1.lua and it will show up as first kneeboard page. Now you can write lua stuff to output your text on the kneeboard page:

 

dofile(LockOn_Options.common_script_path.."elements_defs.lua")

 

local FONT = MakeFont({ used_DXUnicodeFontData = "font_dejavu_lgc_sans_condensed_17" }, { 0, 0, 0, 255 }) 

 

    local txt = CreateElement "ceStringPoly"
    txt.value = "My text"
    txt.material = FONT
    txt.init_pos = { h_center, v_center }
    txt.alignment = "CenterCenter"
    txt.stringdefs = { 0.005, 0.0013, 0, 0 }
    txt.use_mipfilter = true
    txt.h_clip_relation = h_clip_relations.COMPARE
    txt.level = DEFAULT_LEVEL
    Add(txt) 

 

Define h_center and v_center with the position you want the text to appear on the kneeboard page.


Edited by dcs76
Link to comment
Share on other sites

Yes, sure. Like this:

 

    local imageMaterial = MakeMaterial(path, { 255, 255, 255, 255 })

    local back = CreateElement "ceTexPoly"
    back.name = create_guid_string()
    back.material = imageMaterial
    back.init_pos = { x - 1, GetAspect() - y }
    back.vertices = {
        { 0, 0 },
        { width, 0 },
        { width, -height },
        { 0, -height }
    }
    back.indices = { 0, 1, 2; 0, 2, 3 }
    back.tex_coords = texture_box(0, 0, 1, 1)
    back.h_clip_relation = h_clip_relations.COMPARE
    back.level = DEFAULT_LEVEL
    Add(back) 

 

This basically defines two triangles building a rectangle. The texture(material) of that rectangle is the picture loaded from "path". You need to define x, y, width and height to define where the rectangle/image should be drawn inside of the kneeboard page.

Link to comment
Share on other sites

very cool thanks, so path is one path in computer like "D:\...\image.png" ?

 

Another question, is it possible to link that lua file with one mission script lua file to put some dynamic variables depending of the mission and insert new pages during the mission ?

Link to comment
Share on other sites

Hi,

 

I tried the single message text, add 1.lua file in F18 KNEEBOARD. I see a new page but empty, no background no text !

 

I remplaced  txt.init_pos = { h_center, v_center } with txt.init_pos = { 0, 0}  et set 

local FONT = MakeFont({ used_DXUnicodeFontData = "font_dejavu_lgc_sans_condensed_17" }, { 0, 0, 0, 255 })  with 

local FONT = MakeFont({ used_DXUnicodeFontData = "font_dejavu_lgc_sans_condensed_17" }, { 255,255,255, 255 }) 

 

And no change !

 

Help !

 

 


Edited by sunski34
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...