Skip to content

Made tweakunits load before tweakdefs and extended available tweakunits/defs slots - #6597

Open
goldjee wants to merge 2 commits into
beyond-all-reason:masterfrom
goldjee:tweakoptions-extension
Open

Made tweakunits load before tweakdefs and extended available tweakunits/defs slots#6597
goldjee wants to merge 2 commits into
beyond-all-reason:masterfrom
goldjee:tweakoptions-extension

Conversation

@goldjee

@goldjee goldjee commented Jan 7, 2026

Copy link
Copy Markdown

Work done

Altered the processing order of tweaks so tweakunits are prioritized over tweakdefs. This change allows setting up simple unit definitions and then tweak them in bulk using tweakdefs. For example, one might want to add new units for a lobby, and then apply an optional tweak that iterates over all the units in the game and removes their metal cost. Previously it wasn't possible.

Changed available tweakunits and tweakdefs slots from 10 to 30 to allow more heavily modded lobbies.

Addresses Issue(s)

Test steps

  • Spin up a multiplayer lobby without any tweakdefs/tweakunits set. The lobby should start normally.
  • Add up to 30 tweakunits with !bset tweakunits<N> <base64>, where N is omitted for slot 0, and max N is 29. The commands should be accepted without errors. The lobby should start normally and expected unit definitions added by the commands should be added to the game.
  • Add up to 30 tweakdefs with !bset tweakdefs<N> <base64>, where N is omitted for slot 0, and max N is 29. The commands should be accepted without errors. The lobby should start normally and expected tweaks should be applied.
  • Add metal cost removing tweakdefs alongside tweakunits with metal costs. The lobby should start normally and the units defined by tweakunits should have altered metal and energy costs.

Example "no metal cost" tweakdefs script:

for name, ud in pairs(UnitDefs) do
	if ud.metalcost and ud.metalcost > 0 and ud.energycost and ud.energycost > 0 then
		ud.energycost = ud.energycost + 5 * ud.metalcost
		ud.metalcost = 0
	end
	if ud.metalcost and ud.metalcost > 0 then
		ud.energycost = 5 * ud.metalcost
		ud.metalcost = 0
	end
end

for name, ud in pairs(UnitDefs) do
	if ud.extractsmetal and ud.extractsmetal > 0 then
		ud.maxthisunit = 0
	end
	if ud.customparams and ud.customparams.energyconv_efficiency and ud.customparams.energyconv_efficiency > 0 then
		ud.maxthisunit = 0
	end
end

Corresponding bset command:

!bset tweakdefs29 Zm9yIGEsYSBpbiBwYWlycyhVbml0RGVmcylkbyBpZiBhLm1ldGFsY29zdCBhbmQgYS5tZXRhbGNvc3Q-MCBhbmQgYS5lbmVyZ3ljb3N0IGFuZCBhLmVuZXJneWNvc3Q-MCB0aGVuIGEuZW5lcmd5Y29zdD1hLmVuZXJneWNvc3QrNSphLm1ldGFsY29zdDthLm1ldGFsY29zdD0wIGVuZDtpZiBhLm1ldGFsY29zdCBhbmQgYS5tZXRhbGNvc3Q-MCB0aGVuIGEuZW5lcmd5Y29zdD01KmEubWV0YWxjb3N0O2EubWV0YWxjb3N0PTAgZW5kIGVuZDtmb3IgYSxhIGluIHBhaXJzKFVuaXREZWZzKWRvIGlmIGEuZXh0cmFjdHNtZXRhbCBhbmQgYS5leHRyYWN0c21ldGFsPjAgdGhlbiBhLm1heHRoaXN1bml0PTAgZW5kO2lmIGEuY3VzdG9tcGFyYW1zIGFuZCBhLmN1c3RvbXBhcmFtcy5lbmVyZ3ljb252X2VmZmljaWVuY3kgYW5kIGEuY3VzdG9tcGFyYW1zLmVuZXJneWNvbnZfZWZmaWNpZW5jeT4wIHRoZW4gYS5tYXh0aGlzdW5pdD0wIGVuZCBlbmQ

@sprunk

sprunk commented Jan 7, 2026

Copy link
Copy Markdown
Collaborator

@goldjee

goldjee commented Jan 7, 2026

Copy link
Copy Markdown
Author

Thanks for pointing out! Sent a PR there as well.

@WatchTheFort

Copy link
Copy Markdown
Member

Do not merge this PR before an announcement is made so all current tweak users can modify their tweak scripts accordingly.

@WatchTheFort

Copy link
Copy Markdown
Member

@PtaQQ Please coordinate announcing and merging the two PRs.

  1. Announce to modders
  2. Give time for them to modify their tweak scripts
  3. Merge this (game) PR
  4. Merge linked SPADS PR Tripled the number of available tweakunits/tweakdefs slots spads_config_bar#210

@WatchTheFort

Copy link
Copy Markdown
Member

Also don't we need a Chobby PR to expand the tweak inputs to 30?

@PtaQQ

PtaQQ commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator

@AntlerForce can you check the above question pls?

@AntlerForce

Copy link
Copy Markdown
Collaborator

@AntlerForce can you check the above question pls?

Disclaimer: Am not tweak enthusiast

From what I can tell the answer is No. We don't need a chobby PR because modoptions config is pulled from the game repo itself. The only tweak-specific code in chobby is one line that automatically enables legionfaction if the tweak references legcom and this part which provides a summary (or failure report) if the key starts with tweakdefs/tweakunits:

https://github.com/beyond-all-reason/BYAR-Chobby/blob/0be67dae6203e11cad07c17682edafb1a72acf27/LuaMenu/widgets/gui_modoptions_panel.lua#L1145

@WatchTheFort

Copy link
Copy Markdown
Member

@PtaQQ Reminder to coordinate release of this

@WatchTheFort

Copy link
Copy Markdown
Member

@PtaQQ Don't forget....

@efrec

efrec commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

@PtaQQ :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants