Is it possible to add a new "preferred building method" ?
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
-
- Posts: 99
- Joined: Fri, 30. Nov 18, 23:54
Is it possible to add a new "preferred building method" ?
I am currently working on a Xenon mod which allows you to use Xenon structures, ships, weapons, equipment, and economy but I am having to overwrite the "closedloop" method for drones so I can build them on my stations using Xenon economy, is there a way to create a new selectable build method ?
- Stoats not Goats
- Posts: 144
- Joined: Wed, 6. Dec 17, 09:49
Re: Is it possible to add a new "preferred building method" ?
Yeah mate, most of what you'll be looking for is in wares.xml, particularly the Terran DLC's patch for it. At the start of the file you can declare a new build method as well as which faction(s) will use it as a default.
Taking a bath in Kingdom End
My X4:F guides, maps and summaries|My highway mods|Get involved with the X4 wiki
My X4:F guides, maps and summaries|My highway mods|Get involved with the X4 wiki
-
- Posts: 99
- Joined: Fri, 30. Nov 18, 23:54
Re: Is it possible to add a new "preferred building method" ?
That is indeed the way to create a new building method, but you can't select the new build method in your global orders tab: https://prnt.sc/XFE7eKxcdNsM meaning , your player faction can't use this new method.Stoats not Goats wrote: ↑Sat, 1. Oct 22, 13:28Yeah mate, most of what you'll be looking for is in wares.xml, particularly the Terran DLC's patch for it. At the start of the file you can declare a new build method as well as which faction(s) will use it as a default.
- Stoats not Goats
- Posts: 144
- Joined: Wed, 6. Dec 17, 09:49
Re: Is it possible to add a new "preferred building method" ?
I wonder what makes the vanilla build methods different then? Have you tried adding the player as a faction to the list?
Taking a bath in Kingdom End
My X4:F guides, maps and summaries|My highway mods|Get involved with the X4 wiki
My X4:F guides, maps and summaries|My highway mods|Get involved with the X4 wiki
Re: Is it possible to add a new "preferred building method" ?
Check the lua files. I think it requires the player's race to have this build method.
Cheers Euclid
Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786
-
- Posts: 99
- Joined: Fri, 30. Nov 18, 23:54
Re: Is it possible to add a new "preferred building method" ?
Thanks for narrowing it down, sadly I am not that proficient in Lua, but I think I did found the area where you can set the preferred build method:
Code: Select all
-- preferred build method
local row = ftable:addRow(false, { bgColor = Helper.defaultTitleBackgroundColor })
row[1]:setColSpan(8):createText(ReadText(1001, 11298), Helper.headerRowCenteredProperties)
local cursetting = ffi.string(C.GetContainerBuildMethod(controllable))
local curglobalsetting = ffi.string(C.GetPlayerBuildMethod())
local foundcursetting = false
local locresponses = {}
local n = C.GetNumPlayerBuildMethods()
if n > 0 then
local buf = ffi.new("ProductionMethodInfo[?]", n)
n = C.GetPlayerBuildMethods(buf, n)
for i = 0, n - 1 do
local id = ffi.string(buf[i].id)
-- check if the curglobalsetting (which can be the method of the player's race) is in the list of options
if id == curglobalsetting then
foundcursetting = true
end
table.insert(locresponses, { id = id, text = ffi.string(buf[i].name), icon = "", displayremoveoption = false })
end
end
-- if the setting is not in the list, default to default (if the race method is not in the list, there is no ware that has this method and it will always use default)
if not foundcursetting then
curglobalsetting = "default"
end
local hasownsetting = cursetting ~= ""
local rowdata = "info_buildrule_global"
local row = ftable:addRow({ rowdata }, { bgColor = Helper.color.transparent })
row[1]:createCheckBox(not hasownsetting, { width = config.mapRowHeight, height = config.mapRowHeight })
row[1].handlers.onClick = function(_, checked) return menu.checkboxSetBuildRuleOverride(controllable, checked, curglobalsetting) end
row[2]:setColSpan(7):createText(ReadText(1001, 8367))
local row = ftable:addRow("info_buildrule", { bgColor = Helper.color.transparent })
row[1]:setColSpan(8):createDropDown(locresponses, { height = Helper.standardTextHeight, startOption = hasownsetting and cursetting or curglobalsetting, active = hasownsetting }):setTextProperties({ fontsize = config.mapFontSize })
row[1].handlers.onDropDownConfirmed = function (_, id) return menu.dropdownBuildRule(controllable, id) end
row[1].handlers.onDropDownActivated = function () menu.noupdate = true end
ftable:addEmptyRow()
local row = ftable:addRow(false, { bgColor = Helper.defaultTitleBackgroundColor })
row[1]:setColSpan(8):createText(ReadText(1001, 7725), Helper.headerRowCenteredProperties)
Edit1: so method definition is as follows:
Code: Select all
} ProductionMethodInfo;
typedef struct {
const char* name;
int32_t skilllevel;
uint32_t amount;
Code: Select all
function menu.dropdownOrdersBuildRule(_, id)
C.SetFactionBuildMethod("player", id)
end
Last edited by errorname1002 on Sun, 2. Oct 22, 20:07, edited 3 times in total.
-
- Posts: 99
- Joined: Fri, 30. Nov 18, 23:54
Re: Is it possible to add a new "preferred building method" ?
Yes I did try that but sadly a negative result, I believe this used to work before 4.0 since before that you were not able to select different build methods so technically the game treated the player faction like any other faction.Stoats not Goats wrote: ↑Sun, 2. Oct 22, 07:50I wonder what makes the vanilla build methods different then? Have you tried adding the player as a faction to the list?