Jump to content

Recommended Posts

Hey Guys, I'm pretty new to modding. I've gone thru the basic steps, tried to learnt the language, looked at the logs, modded some mods and Now I think I want to try my best at making a new simple game mod.

I'm thinking about a wilderness-like Spawn point, (By looking at the log I've found its called [Scatter]) and When people die, instead of getting their save file wiped clean, they will just become ghost. It's kind of like wilderness mixed with endless. However, I would like for this to be easily configurable. By looking at the mod files of all the other currently working game modes (pretty much all of them by PeterA) I found that the setting of the game modes are defined in the modinfo.lua and as such:

 

game_modes =
{
    {
        name = "custom_game",
        label = "Custom",
        description = "BlahBlah I'll Figure something out!",
        settings =
        {
            spawn_mode = "scatter",
            resource_renewal = true,
            ghost_enable = true,
            portal_rez = true,
            reset_time = nil


        }
    }
}

 

I've spent more time than I should've digging thru the game files, mod files and reading the guide posted on here to try figure out how to change this in the gamemain.lua or even in the gamelogic.lua files to enable me to change just one of those settings without having to physically open the modinfo; i.e. I can't figure out how to configure those setting using the configuration options provided in the modinfo.lua.

 

Why do I want to change those easily via the configuration options? so people don't have to manually open the modinfo.lua to change those setting. 

I hope someone can figure this out,

-Gonzo

27 minutes ago, Muche said:

I haven't tried this, but it might work

It does work.

I was wondering if even for stuff that needs to be client side (like invalid_recipes) work.

And it also works.

 

So in modinfo you are going to want

all_clients_require_mod = true

game_modes = {
	{
		name = "CUSTOM_ID",
		label = "Label Text",
		settings = {
			text = "Box title (label text, if this is empty)",
			description = "You can read this\n by pressing the little box with a red ?\n This is the box description\n of the mod",
			mod_game_mode = true,
			spawn_mode = "scatter",
			resource_renewal = true,
			ghost_sanity_drain = false,
			ghost_enabled = true,
			portal_rez = true,
			reset_time = nil,
			invalid_recipes = {},
		}
	},
}

configuration_options = {
	{
		name = "tent_recipe",
		label = "Tent Recipe",
		hover = "",
		options = {
			{description = "No", data = false, hover = ""},
			{description = "Yes", data = true, hover = ""},
		},
		default = true,
	},
}

This is an example that will manipulate the recipes (you can use the same logic to disable telltale hearts and meat effigies).

 

And then in modmain

local tent_recipe = GetModConfigData("tent_recipe")

if not tent_recipe then
	GLOBAL.GAME_MODES["CUSTOM_ID"].invalid_recipes = { "tent" }
end

 

Just now, DarkXero said:

It does work.

I was wondering if even for stuff that needs to be client side (like invalid_recipes) work.

And it also works.

 

So in modinfo you are going to want


all_clients_require_mod = true

game_modes = {
	{
		name = "CUSTOM_ID",
		label = "Label Text",
		settings = {
			text = "Box title (label text, if this is empty)",
			description = "You can read this\n by pressing the little box with a red ?\n This is the box description\n of the mod",
			mod_game_mode = true,
			spawn_mode = "scatter",
			resource_renewal = true,
			ghost_sanity_drain = false,
			ghost_enabled = true,
			portal_rez = true,
			reset_time = nil,
			invalid_recipes = {},
		}
	},
}

configuration_options = {
	{
		name = "tent_recipe",
		label = "Tent Recipe",
		hover = "",
		options = {
			{description = "No", data = false, hover = ""},
			{description = "Yes", data = true, hover = ""},
		},
		default = true,
	},
}

This is an example that will manipulate the recipes (you can use the same logic to disable telltale hearts and meat effigies).

 

And then in modmain


local tent_recipe = GetModConfigData("tent_recipe")

if not tent_recipe then
	GLOBAL.GAME_MODES["CUSTOM_ID"].invalid_recipes = { "tent" }
end

 

Awesome! thanks guys! The string looks like it'll work. 

I just couldn't figure out the phrasing of the Global.game_modes

I was trying to create a string of inst. pathways but that ended up just not working and making it much more difficult than needed to be. .

I'll try it out on Thursday and try to have it published by the end of the weekend. Since both of you pretty much wrote what I needed, once I finish up the mod would you both like to be added to author list?

Alrite, So I everything worked out fine, I'm trying to make a table for the DST_Character list to be modified

I know that when the modinfo is like this:

Spoiler

{
        name = "Ban_wathgrithr",
        label = "Ban wigfrid",
        hover = "blahblah",
        options =
        {
            {description = "Make her the only playable character", data = true},
            {description = "Nah", data = false},
        },
        default = false,
    },

 

and the mod main has this:

Spoiler

GLOBAL.TUNING.BanWigfrid = GetModConfigData("Ban_wathgrithr")

if TUNING.BanWigfrid then
    GLOBAL.DST_CHARACTERLIST= { "wathgrithr" }
end

 

Then wigfrid is the only character playable, and I know if I wanted to make her the only character unplayable I would just need to copy the DST_CHARACTERLIST and exclude "wathgrithr"

Now I'm trying to make it fully customizable what character people are allowed to play, Because I don't think anyone has ever done that before and Here's the Table I'm having real trouble making it work. I've tried numerous variables and I realize that its out of my reign of knowledge in how to make it work. I was wondering if you guys knew what i'm missing?

local IncludeWigfrid= GetModConfigData("Ban_wathgrithr")


local function NEWER_DST_CHARACTERLIST( inst )
	local NEW_DST_CHARACTERLIST = {} ------table name-----

	if IncludeWigfrid then -----Allowed characters
			table.insert(NEW_DST_CHARACTERLIST, "Wigfrid")
	end
	------------------(Get the Current game's Character list?-------
		GLOBAL.DST_CHARACTERLIST = DST_CHARACTERLIST end
	-------------- Replace the current DST_character list with the new one------
	DST_CHARACTERLIST =

		for i,char in ipairs(DST_CHARACTERLIST) do

			DST_CHARACTERLIST{}
		-- do stuff to the i (index) and v (value) pair that it got from the table-- 
		--the first loop has i == 1, v == "wilson"-- the first loop has i == 2, v == "willow"-- 
		--the first loop has i == 3, v == "wx78"--
		-- the first loop has i == 4, v == "wickerbottom"
		end
	end
end

Whenever I try to load a game,I get the error message of unexpected symbol near 'for'

What am I doing wrong?

There is also MODCHARACTEREXCEPTIONS_DST table that can exclude default characters, easily reachable via RemoveDefaultCharacter(name).

The Disable Characters mod allows a customization of disabled characters.

 

The piece of code posted suffers from several syntax errors:

GLOBAL.DST_CHARACTERLIST = DST_CHARACTERLIST end
Based on indentation, the end is out of place (cause the end of NEWER_DST_CHARACTERLIST function).

DST_CHARACTERLIST =
There is no value assigned to the variable.

DST_CHARACTERLIST{}
I don't know what this is supposted to do; what it is, is a variable followed by an empty table. Had the variable contained a function, it would be a function call with the argument being the empty table.

 

For the table manipulation there is table.insert() and table.remove() functions, see e.g. http://www.lua.org/pil/19.2.html

For general arrays operations one can use ExceptionArrays() and others defined in util.lua.

Edited by Muche

@Muche wow, thanks! I'm a total  numnuts! I looked into the Disabled Characters Mod script and its complicated I would copy and paste it, from his mod into mine but then I wouldn't learn anything.I think I'll contact the author of that mode so he can show me what he did if I can't figure it out.  Thanks for showing me the link to the official Lua guidbook. I'll try cracking the code and figuring out how to manipulate the tables better. I'll probably come back to this forum to post questions if i can't figure them out on my own again. Both of you guys are the backbone of this community, Thanks-a-bunches! :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...