饥荒联机版

饥荒联机版

Convenient Configs便捷配置
 此主题已被置顶,因此可能具有重要性
Remi  [开发者] 3 月 22 日 上午 1:02
Color config example
Since the version 0.4 the mod now supports color config options.
Here's a quick example:

In modinfo.lua:
configuration_options = { -- some other options... { name = "internal_name_here", -- this is passed to GetModConfigData label = "Display Name", -- this is shown to the player options = { {description = "Enable the mod!", data = {0.1,0.2,0.3,1}}, -- make sure... }, default = {0.1,0.2,0.3,1}, -- ...that the 2 color tables are the same is_rgb_config = true, -- or "is_rgba_config = true" if you want opacity to be changeable hover = "Shown when the player hovers their cursor over the option, optional.", }, -- some other options... }

Without comments or any extra fluff:
{ name = "name", label = "label", options = { {description = "desc", data = {0.1,0.2,0.3,1}}, }, default = {0.1,0.2,0.3,1}, is_rgb_config = true, hover = "hover", },

To obtain the value, call GetModConfigData in modmain.lua (or any modimport-ed script) and pass the internal config name as a parameter. The value will always be a table consisting of 4 numbers ranging from 0 to 1, each one representing a color component: red, green, blue, alpha (opacity).