@@ -6,16 +6,12 @@ as a scripting language in [Godot](https://godotengine.org/).
66Being a GDNative library, recompiling the engine is not required, so anyone
77with a built release copied to their project can use it.
88Being a PluginScript language, Lua can seamlessly communicate with scripts
9- written in GDScript/C#/Visual Script and vice-versa.
9+ written in GDScript / C# / Visual Script and vice-versa.
10+ This way, one can use the language that best suits the implementation for each
11+ script and all of them can understand each other.
1012
11-
12- ## Documentation
13- The API is documented using [ LDoc] ( https://stevedonovan.github.io/ldoc/manual/doc.md.html )
14- and is available online at [ github pages] ( https://gilzoide.github.io/godot-lua-pluginscript/topics/README.md.html ) .
15-
16- Generate the documentation with the following command:
17-
18- # make docs
13+ Currently, only LuaJIT is supported, since the implementation is based on its
14+ [ FFI] ( https://luajit.org/ext_ffi.html ) library.
1915
2016
2117## Installing
@@ -25,14 +21,6 @@ Make sure the `lua_pluginscript.gdnlib` file is located at the
2521` res://addons/godot-lua-pluginscript ` folder.
2622
2723
28- ## Articles
29-
30- 1 . [ Designing Godot Lua PluginScript] ( blog/1-design-en.md )
31- 2 . [ Implementing the library's skeleton] ( blog/2-infrastructure-en.md )
32- 3 . [ Integrating LuaJIT and FFI] ( blog/3-luajit-callbacks-en.md )
33- 4 . Initializing and finalizing scripts (TODO)
34-
35-
3624## Goals
3725
3826- Provide support for Lua as a scripting language in Godot in a way that does
@@ -41,7 +29,7 @@ Make sure the `lua_pluginscript.gdnlib` file is located at the
4129 like GDScript, Visual Script and C#, in an idiomatic way
4230- Simple script description interface that doesn't need ` require ` ing anything
4331- Support for LuaJIT and Lua 5.2+
44- - Support paths relative to ` res://* ` and exported game executable path for
32+ - Support paths relative to ` res://* ` and exported game/app executable path for
4533 ` require ` ing Lua modules
4634- Have a simple build process, where anyone with the cloned source code and
4735 installed build system + toolchain can build the project in a single step
@@ -53,6 +41,23 @@ Make sure the `lua_pluginscript.gdnlib` file is located at the
5341- Support multithreading on the Lua side
5442
5543
44+ ## Documentation
45+ The API is documented using [ LDoc] ( https://stevedonovan.github.io/ldoc/manual/doc.md.html )
46+ and is available online at [ github pages] ( https://gilzoide.github.io/godot-lua-pluginscript/topics/README.md.html ) .
47+
48+ Documentation may be generated with the following command:
49+
50+ # make docs
51+
52+
53+ ## Articles
54+
55+ 1 . [ Designing Godot Lua PluginScript] ( https://github.com/gilzoide/godot-lua-pluginscript/blob/main/blog/1-design-en.md )
56+ 2 . [ Implementing the library's skeleton] ( https://github.com/gilzoide/godot-lua-pluginscript/blob/main/blog/2-infrastructure-en.md )
57+ 3 . [ Integrating LuaJIT and FFI] ( https://github.com/gilzoide/godot-lua-pluginscript/blob/main/blog/3-luajit-callbacks-en.md )
58+ 4 . Initializing and finalizing scripts (TODO)
59+
60+
5661## Script example
5762
5863This is an example of how a Lua script looks like. There are comments regarding
@@ -81,37 +86,32 @@ MyClass.some_prop = 42
8186-- The `property` function adds metadata to defined properties,
8287-- like setter and getter functions
8388MyClass .some_prop_with_details = property {
84- -- [1 ] or ["default"] or ["default_value" ] = property default value
89+ -- ["default_value" ] or ["default"] or [1 ] = property default value
8590 5 ,
86- -- [2 ] or ["type" ] = variant type, optional, inferred from default value
91+ -- ["type" ] or [2 ] = variant type, optional, inferred from default value
8792 -- All Godot variant type names are defined globally as written in
8893 -- GDScript, like bool, int, float, String, Array, Vector2, etc...
8994 -- Notice that Lua <= 5.2 does not differentiate integers from float
9095 -- numbers, so we should always specify `int` where appropriate
9196 -- or use `int(5)` in the default value instead
9297 type = int ,
93- -- ["set"] or ["setter"] = setter function, optional
94- set = function (self , value )
95- self .some_prop_with_details = value
96- -- Indexing `self` with keys undefined in script will search base
97- -- class for methods and properties
98- self :emit_signal (" something_happened_with_args" , " some_prop_with_details" , value )
99- end ,
100- -- ["get"] or ["getter"] = getter function, optional
98+ -- ["get"] or ["getter"] = getter function or method name, optional
10199 get = function (self )
102100 return self .some_prop_with_details
103101 end ,
104- -- ["usage"] = property usage, from enum godot_property_usage_flags
105- -- optional, default to GD.PROPERTY_USAGE_DEFAULT
106- usage = GD .PROPERTY_USAGE_DEFAULT ,
107- -- ["hint"] = property hint, from enum godot_property_hint
108- -- optional, default to GD.PROPERTY_HINT_NONE
109- hint = GD .PROPERTY_HINT_RANGE ,
102+ -- ["set"] or ["setter"] = setter function or method name, optional
103+ set = ' set_some_prop_with_details' ,
104+ -- ["usage"] = property usage, from `enum godot_property_usage_flags`
105+ -- optional, default to `PropertyUsage.DEFAULT`
106+ usage = PropertyUsage .DEFAULT ,
107+ -- ["hint"] = property hint, from `enum godot_property_hint`
108+ -- optional, default to `PropertyHint.NONE`
109+ hint = PropertyHint .RANGE ,
110110 -- ["hint_string"] = property hint text, only required for some hints
111111 hint_string = ' 1,10' ,
112- -- ["rset_mode"] = property remote set mode, from enum godot_method_rpc_mode
113- -- optional, default to GD.RPC_MODE_DISABLED
114- rset_mode = GD . RPC_MODE_MASTER ,
112+ -- ["rset_mode"] = property remote set mode, from ` enum godot_method_rpc_mode`
113+ -- optional, default to `RPCMode.DISABLED`
114+ rset_mode = RPCMode . MASTER ,
115115}
116116
117117-- Functions defined in table are public methods
@@ -121,7 +121,14 @@ function MyClass:_ready() -- `function t:f(...)` is an alias for `function t.f(
121121 print (" MyClass instance is ready! Running on a " .. os_name .. " system" )
122122end
123123
124- function MyClass :some_prop_doubled ()
124+ function MyClass :set_some_prop_with_details (value )
125+ self .some_prop_with_details = value
126+ -- Indexing `self` with keys undefined in script will search base
127+ -- class for methods and properties
128+ self :emit_signal (" something_happened_with_args" , " some_prop_with_details" , value )
129+ end
130+
131+ function MyClass :get_some_prop_doubled ()
125132 return self .some_prop * 2
126133end
127134
0 commit comments