Category:Character

From Nutscript Developer Wiki
Jump to navigation Jump to search

Summary[edit]

Character is a class that represent another identity of the player. It can be created in the character's menu, which is the first menu you will see when you joined the server.

Most of player's value will be stored in the character class. Because, Character is another individual. So, If you're going to store some data, You need to tie that data on the character not the player.

If you ties your data to the player, the data will be shared to the characters that is under the player's control. If that is intentional, That's fine. But if it isn't, You need to reconsider to remake your data storing method.

Development Tips[edit]

Referencing the Character with characterID[edit]

All of loaded character data are stored in the nut.char.loaded. If the characterID is active, (Mostly, You get the data from the active user.) You can reference the character class from the table of the loaded characters.

Loading the character looks like this:

local char = nut.char.loaded[CHARACTER]

After retriving the character, you need to verify the character class to make less error halts.

if (!char) then return end

So, just with 2 lines of code, You can do whatever you want with the character.