Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

Yakuzashi

[Configuration Menu] Configurable perk

Recommended Posts

Yakuzashi    80

Hello, I have question to anybody willing to help me. In the configuration menu you can change values of certain item for example. But can you make perk (from charactername.lua in scripts folder) switchable between on and off option ? I have no clue how to start it, so I am here for help.

 

	local handle = inst.sg.sg.actionhandlers[ACTIONS.PICK]
    handle.deststate = function(inst) return "doshortaction" end

 

Here's where did I get this perk

@no_signal's solution in this topic

 

Share this post


Link to post
Share on other sites
Ultroman    619

	{
		name = "BedrollCanSleepAtDay",
		label = "SR Usable At Day",
		hover = "Straw Roll: Usable at day?\nMake players be able to use Straw Rolls at daytime?",
		options =	{
						{description = "Enabled", data = true},
						{description = "Disabled", data = false},
					},
		default = false,
	},

 

Share this post


Link to post
Share on other sites
Yakuzashi    80

Thanks, but I still don't know how to connect it with function inside master_postinit in character.lua. Could you help me with this too ? Thank you in advance.

Share this post


Link to post
Share on other sites
Ultroman    619

Expanding on the example I posted before, you'd do this to get the setting values.

local myValue = GetModConfigData("BedrollCanSleepAtDay")

 

Share this post


Link to post
Share on other sites
Serpens    523
8 minutes ago, Ultroman said:

Expanding on the example I posted before, you'd do this to get the setting values.


local myValue = GetModConfigData("BedrollCanSleepAtDay")

 

additional information:
GetModConfigData only works in modmain (and in scripts you import via modimport from modmain). So it wont work within your custom prefab file.
To still get the value there, you can save it within the TUNING list or within your own GLOBAL variable.
So eg.
TUNING.MY_UNIQUE_VARIABLE_NAME = GetModConfigData("BedrollCanSleepAtDay")
And then use this TUNING within your prefab file.

Share this post


Link to post
Share on other sites