LUA Question - Adding new size-tags for weapons

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Lc4Hunter
XWiki Moderator
XWiki Moderator
Posts: 2179
Joined: Sun, 2. Apr 06, 16:15
x4

LUA Question - Adding new size-tags for weapons

Post by Lc4Hunter »

Hello everyone!

i wanted to add a new size-tag for the weapons tab in the ship configuration menu (on the top left where the slots are shown with their size and a number S1 S2 and so on).

As this is a UI-thing i looked at the lua-files and found two that seem to be relevant:
..\ui\addons\ego_detailmonitorhelper\helper.lua

For my understanding the section "Helper.upgradetypes" is relevant for my goal so i added the "extrasmall" part to the "weapons" section:
{ supertype = "macro", type = "weapon", category = "weapons", mergeslots = false, allowempty = true, emode = "Weapons",
text = { extrasmall = ReadText(1001, 8075), small = ReadText(1001, 8075), medium = ReadText(1001, 8076), large = ReadText(1001, 8077), extralarge = ReadText(1001, 8078) },
shorttext = { extrasmall = ReadText(1001, 52), small = ReadText(1001, 51), medium = ReadText(1001, 50), large = ReadText(1001, 49), extralarge = ReadText(1001, 48) },
},
I also added the new tag to "function Helper.getSlotSizeText(slotsize)":
function Helper.getSlotSizeText(slotsize)
if slotsize == "extralarge" then
return ReadText(1001, 48)
elseif slotsize == "large" then
return ReadText(1001, 49)
elseif slotsize == "medium" then
return ReadText(1001, 50)
elseif slotsize == "small" then
return ReadText(1001, 51)
elseif slotsize == "extrasmall" then
return ReadText(1001, 52)

end

return ""
end
And last but not least in "Helper.slotSizeOrder"
["extralarge"] = 1,
["large"] = 2,
["medium"] = 3,
["small"] = 4,
["extrasmall"] = 5,
But that all does not work. If i give a weapon the extrasmall tag, it shows nothing...
Image

Did i miss something? Is there a hardcoded part which makes my attempt impossible?

Hopefully someone can help me out here :-)

Thanks in advance!

EDIT: The modification of the file in general works. When i replace the Text for the "Small" Tag, the changed text is shown in the game.
User avatar
Casishur
Posts: 2109
Joined: Fri, 1. Jul 05, 10:04
x4

Re: LUA Question - Adding new size-tags for weapons

Post by Casishur »

would extrasmall weapons or turrets be a good candidate for Pdc turrets?

That would be wonderful.
CPU Typ Ryzen 9 3900x
Grafikkarte Radeon RX 7600 XT 16GB
Arbeitsspeicher: Corsair Vengeance LPX 64GB (4 x 16 GB) DDR4 3200MHz
Motherboard Name/Typ MSI B550 Gaming Plus
Win 10 64 bit

Betty : Autopilot.... hat.... total Versagt.

Twitch https://www.twitch.tv/Casishur
User avatar
Dj_FRedy
Posts: 245
Joined: Mon, 27. Jun 11, 05:58
x4

Re: LUA Question - Adding new size-tags for weapons

Post by Dj_FRedy »

Hi Lc4Hunter,

The block that handles this in first instance in your particular case is in the function 'menu.getDataAndDisplay' of the file 'menu_ship_configuration.lua':

Code: Select all

                if not slot.isgroup then
                    slot.slotname = i
                    slot.slotsize = ffi.string(C.GetSlotSize(menu.object, 0, menu.macro, false, upgradetype.type, i))
                    if slot.slotsize ~= "" then
                        if sizecounts[slot.slotsize] then
                            sizecounts[slot.slotsize] = sizecounts[slot.slotsize] + 1
                        else
                            sizecounts[slot.slotsize] = 1
                        end
                        slot.slotname = upgradetype.shorttext[slot.slotsize] .. sizecounts[slot.slotsize]
                    end
                end
The GetSlotSize() function does not return anything for your slot. This function is hardcoded.
"All my contributions to the Technical Support and Public Beta Feedback sections will be concise and to the point, no diatribes, that's what the other sections are for".
Thank you for your efforts.
Lc4Hunter
XWiki Moderator
XWiki Moderator
Posts: 2179
Joined: Sun, 2. Apr 06, 16:15
x4

Re: LUA Question - Adding new size-tags for weapons

Post by Lc4Hunter »

After some research and help from other modders it SEEMS that the games exe-file is responsible for reading the size tags and forwarding it to the interface... so a modification of the exe would be the way to go. But i thinks thats not worth it...

@Dj_FRedy: I will take a look on this part! Maybe my initial suggestion was wrong and this could work... :)

Return to “X4: Foundations - Scripts and Modding”