Skip to main content

Create your first script

NOT WORKING

Scripting is not available yet

Script file

Lets name ours MyScript, inside that folder create a new file called test.lua

ProjectGWN/mods/scripts/MyScript/test.lua
-- Get current character the player is controlling
local currentPlayer = _util.GetCurrentCharacter()

-- Get the customization component for this character
local customizationComponent = _util.GetCustomizationComponent(currentPlayer)

-- Get a list with all available eyes in-game
local eyesList = _customization.GetAvailableEyes(customizationComponent)

-- Create a thread
_thread.Create(function()

-- Change eyes each second
for i, eye in eyesList do
_customization.UpdateEyes(customizationComponent, eye)
_thread.Wait(1000)
end

end)

Script entrypoint

In order for the game to run files from MyScript the game looks & execute the _init.lua (entrypoint) file. Then it will load each file (in-order) from the files field.

ProjectGWN/mods/scripts/MyScript/_init.lua {6-6}
return {
-- Will appear in game
author = "Your creator name",

-- you can add more files
files = {"test"}
}

These are the basics you can explore the full Scripting API