-
Notifications
You must be signed in to change notification settings - Fork 77
nut.char
Brian edited this page Mar 14, 2015
·
5 revisions
This library handles the way characters work in NutScript. The character library handles the loading/saving of characters, as well as its methods and properties.
nut.char.create(data, callback)
- A server-side function that inserts a character into the database from the CharacterCreateInfo data. The callback is called if provided which passes the new character's ID.
nut.char.restore(client, callback, noCache, id)
- A server-side function that loads all Character objects owned by client from the database. If callback is provided, then the callback will be called with a table of characters passed. If noCache is provided, then the function will always load from the database. If the numeric id is passed, then the function will only load a character with the given ID.
nut.char.new(data, id, client, steamID)
- A shared function to create a new Character object with the given data table, which sets all of the character variables registered by
nut.char.registerVar()
. If the numeric ID is passed, then the character's ID property is set to the ID. The third argument, client, is the owner of the character. In the case that the owner is not valid, the fourth argument steamID can be used. Note that the steamID is the 64-bit SteamID, or the communityID. nut.char.hookVar(variable, name, callback)
- A shared function to provide a callback when the variable variable for a character is changed. name is the unique identifier for this hook. callback is called and has the character, old value and new value passed.
nut.char.registerVar(variable, data)
- Creates a new character variable with data, a CharVar structure. The function extends the character by adding accessor functions, with the set* method being server-side and get* being shared.. For example, if variable was "bar", then the function creates the
character:setBar()
andcharacter:getBar()
methods.
client:getChar()
- Returns the player's current character.
client:Name()
- Overwrites the old name function to return the character's name instead if applicable.