Lukkit
  • Home
  • Getting Started
    • Installing Lukkit
    • Your First Plugin
    • Packing and Publishing
  • Storage
    • The StorageObject
    • Example
  • Commands
    • Command Options
    • Command Event
    • Examples
  • Gui
    • Create a simple inv
    • Create an advanced inv
    • Run function if an inventory item has been clicked
  • Events
    • Examples
    • Event List
      • Block
      • Enchantment
      • Entity
      • Hanging
      • Inventory
      • Player
      • Server
      • Vehicle
      • Weather
      • World
  • Globals
    • Global Functions
    • Global Variables
      • Plugin
      • Logging
      • Utilities
  • Wrappers
  • Examples
    • Discord Webhooks (http)
    • Toggle Fly
    • Hello, world!
Powered by GitBook
On this page
  1. Storage

Example

PreviousThe StorageObjectNextCommands

Last updated 6 years ago

In this example, a storage object is created for the config.yml file and sets the default value join-message. Then when the PlayerJoinEvent is called it gets the storage value from the , replaces %s with the player name and sets it to the join message.

-- Create a storage object with the file "config.yml"
pluginConfig = plugin.getStorageObject("config.yml")

-- Set the default to join message and save the config if it is not already in there
if pluginConfig:setDefaultValue("join-message", "%s joined the game!") then
    pluginConfig:save()
end

-- Make event for when players join
plugin.registerEvent("PlayerJoinEvent", function(event)
    -- Set the join message based on the config value
    event:setJoinMessage(string.format(pluginConfig:getValue("join-message"), event:getPlayer():getDisplayName()))
end)
player event
storage object