nut.char.validateInfo - brianhang/nutscript2 GitHub Wiki

Description

valid, fault = nut.char.validateInfo(info, context)

This shared function checks the validity of all the values within info.

Parameters

Name Description
info The table of character information to check.
context A table containing arbitrary information passed from nut.char.create. This may be an empty table.

Side Effects

Returns

Name Description
valid Whether or not the values are valid.
fault A string containing the reason why info is not valid.

Example

-- Create a function that creates characters with checking for realistic values.
function createCharacter(info)
    -- Make sure this character has legitimate values.
    if (nut.char.validateInfo(info)) then
        -- Create the character.
        nut.char.create(info, function(character)
            print("Created character #"..character:getID())
        end)
    else
        print("Can't make this character!")
    end
end