Nut.char.registerVar

From Nutscript Developer Wiki
    nut.char.registerVar(key, data)

This function registers the default variables of the character. Unless you're trying to change Nutscript's Fundamental, You're not going to use this function . Because, If you add new variable with this function, You need to change the database to save your data properly. If you're very good programmer, You can go with this function. Because you won't need our support. If you can manage using this function, I'll give you hard and big applause.

Arguments[edit]

  • String key
  • Table Data

Return Values[edit]

Examples[edit]

Example from Nutscript 1.1 Framework: sh_character.lua

	nut.char.registerVar("desc", {
		field = "_desc",
		default = "",
		index = 2,
		onValidate = function(value, data)
			if (noDesc) then return true end

			local minLength = nut.config.get("minDescLen", 16)

			if (!value or #value:gsub("%s", "") < minLength) then
				return false, "descMinLen", minLength
			end
		end
	})