Jump to content

Pointing LUA files at new texture files


Recommended Posts

So, I've been working on a mod for an alternate HUD for the KA-50, and I've run up against the problem that I don't have enough space inside the Inication_HUD_KA-50 texture file, and I need to move the element to a new texture file.

 

I found in the LUA where it defines the texture source for the HUD element:

 

pitch_bank_scale1          = create_HUD_element("ceTexPoly")
pitch_bank_scale1.name     = "pitch_bank_scale1"
pitch_bank_scale1.vertices = {{-0.23, -0.013}, {-0.23, 2.1}, {0.22, 2.1}, {0.22, -0.013}}
pitch_bank_scale1.indices  = default_box_indices
pitch_bank_scale1.init_pos = bird_position
[color="Red"][b]pitch_bank_scale1.material   = "INDICATION_HUD_KA50"[/b][/color]
pitch_bank_scale1.tex_params = {0.087890625, 0.74169, tex_scale, tex_scale}
pitch_bank_scale1.controllers   = {{"scales_reject"}, {"PitchBankAvail"}, {"pitch", pitch_K}}
if flag_hardware_clip then
pitch_bank_scale1.h_clip_relation = h_clip_relations.COMPARE
pitch_bank_scale1.level = HUD_DEFAULT_LEVEL + 1
end
Add(pitch_bank_scale1)

 

 

And I modified the line to point at my new texture file:

 

pitch_bank_scale1          = create_HUD_element("ceTexPoly")
pitch_bank_scale1.name     = "pitch_bank_scale1"
pitch_bank_scale1.vertices = {{-0.23, -0.013}, {-0.23, 2.1}, {0.22, 2.1}, {0.22, -0.013}}
pitch_bank_scale1.indices  = default_box_indices
pitch_bank_scale1.init_pos = bird_position
[color="Red"][b]pitch_bank_scale1.material   = "INDICATION_LADDER_KA50"[/b][/color]
pitch_bank_scale1.tex_params = {0.087890625, 0.74169, tex_scale, tex_scale}
pitch_bank_scale1.controllers   = {{"scales_reject"}, {"PitchBankAvail"}, {"pitch", pitch_K}}
if flag_hardware_clip then
pitch_bank_scale1.h_clip_relation = h_clip_relations.COMPARE
pitch_bank_scale1.level = HUD_DEFAULT_LEVEL + 1
end
Add(pitch_bank_scale1)

 

I thought this would do it, but I've missed something, and when I enable the MOD i simply get no pitch ladder.

 

Anyone got any leads on what i need to change to point the HUD element at a new .tga?

Link to comment
Share on other sites

Im having that problem for custom symobology to... Im assuming for a texture you would use the same technique as a custom font. For example create the texture and in the txt file for that tga use a hex code for your symbol. The values from left to right should be your starting pixel on your x axis, the next is your y axis start, the next would be the width in pixels of the symbol, and the last would be the height in pixels. You can see ED's example in the font folder. What method do you use for custom symbols?

 

Anyway I tryed that and it would display the letter of my hex code rather than the actual texture it was using even though I changed the material line.

 

I will look into it more, actually I think I have an idea. Ill let you know.

 

Could you provide some insight into making things move on the HUD? For instance a pitch ladder or heading tick marks and such. As far as im seeing you define a variable in the definitions.lua and use it as init.pos in the indication page. Is this correct, im confused because it is not working for me.


Edited by Wabacku
Link to comment
Share on other sites

Could you provide some insight into making things move on the HUD? For instance a pitch ladder or heading tick marks and such. As far as im seeing you define a variable in the definitions.lua and use it as init.pos in the indication page. Is this correct, im confused because it is not working for me.

 

I'm unsure about making things move, but i believe the Controllers line is the factor (have not experimented)

 

As far as defining the location of the symbology, you want this line:

 

pitch_bank_scale1.tex_params = {0.087890625, 0.74169, tex_scale, tex_scale}

 

Those coordinates are from the top-left of the image. 0.0, 0.0 would be top left, and 1.0, 1.0 would be bottom right. When I have been editing symbology, I have been replacing that decimal with pixel location divided by texture size, so that i don't need to use a calculator to find out where the origin is if i need to go back and tweak, so that line in my current version looks like this:

 

pitch_bank_scale1.tex_params = {[color="Red"]90 / 1024, 760 / 1024[/color], tex_scale, tex_scale}

 

The line that determines the extents of the object on the texture file is:

pitch_bank_scale1.vertices = {{-0.23, -0.013}, {-0.23, 2.1}, {0.22, 2.1}, {0.22, -0.013}}

These have normal grid orientations (positive is right and up). Vertices are as follows: lower left, upper left, lower right, upper right. These are reference from the origin point. I do not know exactly what the scaling is for this number into pixels. To find it out, I had to count how many pixels tall the texture was from origin to top, divide by the value for the vertical limit (2.1) and then i used that number as my scaling factor going from pixels back to the LUA.

Link to comment
Share on other sites

  • 2 weeks later...
Glad y'all like it. If I can ever figure out how to point the LUA files at new texture files, I intend to do some more work on it, but the stock texture doesn't have enough space for what I want to do.

 

DCS World\Mods\aircrafts\Ka-50\Cockpit\Scripts\materials.lua

line #50:

textures["INDICATION_HUD_KA50"] = {IndicationTexturesPath.."Indication_hud_ka-50.tga", HUD_color}
simply add a new line that specifies the path to your new textures file.

Example:

your new texture file is named DCS World\Mods\aircrafts\Ka-50\Cockpit\Resources\IndicationTextures\Indication_ladder_ka-50.tga.

 

Than add a new line (#51) to the materials.lua like this:

textures["INDICATION_LADDER_KA50"] = {IndicationTexturesPath.."Indication_ladder_ka-50.tga", HUD_color}

 

now the code from your first post should be working.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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