Tutorial:Storing Custom Data on Pokémon: Difference between revisions

From PMDOWiki
Shitpost Sunkern (talk | contribs)
Created page with "Each <code> Character</code> has a <code> LuaData</code> property that can be used to store custom data. This can be useful as an alternative to a raw Script Variable since the data will follow a Pokémon specifically, and won't need to be indexed in some other way. A <code>Character</code>'s <code>LuaData</code> can be accessed by calling it in a Lua script: [char].LuaData <code>LuaData</code> is just..."
 
Imbion (talk | contribs)
 
(No difference)

Latest revision as of 15:45, 16 October 2025

Each Character has a LuaData property that can be used to store custom data. This can be useful as an alternative to a raw Script Variable since the data will follow a Pokémon specifically, and won't need to be indexed in some other way.

A Character's LuaData can be accessed by calling it in a Lua script:

   [char].LuaData

LuaData is just a Lua table, so any function or index into it works like any other Lua table. For example, you can set and check values like so:

   [char].LuaData.nature = "adamant"
   if [char].LuaData.pointsEarned > 100 then
       -- do something
   end

To delete a variable in LuaData, set it to nil, just like any other variable:

   [char].LuaData.temp = nil