This project is still a work in progress and needs some improvements:
- Use the CoreGameAPI.json file
- Change output file
core-games-api.def.lua
(currently using the one on Github) - Implements global
script
(not defined in CoreGameAPI) - Generate file structure with full implementation
- Namespaces
- Classes
- Enums
- Inheritance
- Better Event Type with use of Generics
- Optional function parameters
- Create daily release system
- Provide a better documentation
- Improve code structure
Type checking provide a good flexible autocomplete system and give you errors when you are trying to access undefined properties.
As the types are just from a simple Lua file it can be understand in any IDE, VSCode, Jetbrains, etc. I still encourage to use IntelliJ IDEA, it provides stronger understanding of types.
Get the official vscode-core extension which is based on the config file generated here.
In order to enjoy the power of LDoc you must use a plugin that understand it.
For that, install the Luanalysis plugin for JetBrains
First, you must retrieve the location of your project.
For that Right Click on a script in the Core Editor Project Content, click on Show in explorer
and copy the link of the directory.
Then open Jetbrains and click on File > Open...
and paste the path of your scripts folder.
In the Core editor, create a new Script called CoreGamesAPI
and delete it from the hierarchy.
Open the script in your IDE and paste the content of core-games-api.def.lua in it.
Done! You can now code and have full autocomplete for the Core Games API and also for your own scripts!
Whenever you code, typing what you write is always a good thing. For you, and for the others.
By typing your function parameters, you will be able to have full autocompletion inside your functions. And by typing the return, you will be able to call this function anywhere in your application and still enjoying the autocomplete and the type checking.
--- @param player Player
--- @return number
function GetMoney(player)
return player:GetResource("money")
end
By typing your locals you will be able to enjoy autocomplete and type checking even on your custom properties !
--- @type number
local customProperty = script.parent:GetCustomProperty("customProperty")
--- @type ScriptAsset
local myScript = script.parent:GetCustomProperty("myScript")
You create your own types by adding LDoc to your classes.
--- @class MyClass
MyClass = {}
return MyClass
Now you can use this type to enjoy autocompletion on your own modules.
local propMyScript = script.parent:GetCustomProperty("myScript")
--- @type MyClass
local MyClass = require(propMyScript)