Zero-K icon indicating copy to clipboard operation
Zero-K copied to clipboard

Replace `include("bla.h")` with `Spring.Utilities.Bla`

Open sprunk opened this issue 11 months ago • 1 comments

Including the file over and over in each gadget recreates the whole table (-> waste of cycles, garbage collector pressure) and pollutes the gadget with a ton of mostly useless globals.

For custom commands, the utilities table exists. Change

VFS.Include("LuaRules/Configs/customcmds.h")
Spring.Echo(CMD_FOO)

into

local CMD_FOO = Spring.Utilities.CMD.FOO
Spring.Echo(CMD_FOO)
  1. create a Spring.Utilities subtable for other similar includes: keysym.h, colors.h[.lua] and apply the same treatment as above to gadgets.

sprunk avatar Mar 06 '24 12:03 sprunk