Releases: WeaselGames/godot_luaAPI
v2.0-beta4
Whats changed
- Improved error handling
- New method
(LuaAPI/LuaCoroutine).set_hook
this allows you to set a Callable as a lua hook. See example below. - New method
LuaAPI.get_running_thread
. As the name implies this method returns the coroutine which is currently running. Intended to be called from a hook. - New method
LuaCoroutine.yield_state
As the name implies this method yields the coroutine state. Intended to be called from a hook. - LuaJIT support for gdExtension (only Linux, Windows and MacOS for now)
Hook code example:
extends Node2D
var lua: LuaAPI
var coroutine: LuaCoroutine
func _lua_hook(lua: LuaAPI, event: int, line: int):
var co: LuaCoroutine = lua.get_running_coroutine()
co.yield_state([1])
func _ready():
lua = LuaAPI.new()
# Despite the name, this is not like a OS coroutine. It is a coroutine.
coroutine = lua.new_coroutine()
coroutine.set_hook(_lua_hook, LuaAPI.HOOK_MASK_COUNT, 4)
coroutine.load_string("
while true do
print('Hello world!')
end
")
var yieldTime = 0
var timeSince = 0
var goodBye = false
func _process(delta):
timeSince += delta
# If the coroutine has finished executing or if not enough time has passed, do not resume the coroutine.
if coroutine.is_done() || timeSince <= yieldTime:
if !goodBye:
lua.do_string("""
for i = 0,10,1 do
print('Good Bye World!')
end
""")
goodBye=true
return
goodBye=false
# coroutine.resume will either return a LuaError or an Array.
var ret = coroutine.resume()
if ret is LuaError:
print("ERROR %d: " % ret.type + ret.message)
return
# Assumes the user will always pass the number of seconds to pause the coroutine for.
yieldTime = ret[0]
timeSince = 0
v2.0-beta3
v2.0-beta2
Small update that breaks API compat with a LuaThread rename. Hopefully this will be the only time. But again that is not a guarantee.
Changes
- Fixed bug with CallableExtra caused by the LuaJIT update.
- Renamed the LuaThread class to LuaCoroutine in favor of being less confusing.
- Couroutines created via the coroutine library can now be pulled to GDScript as a LuaCoroutine
- new_thread method removed from LuaThread/LuaCoroutine Replaced by new_coruotine on the LuaAPI class
v2.0-beta1
v2.0 for godot 4 is over a year in the making so far. This update brings many additions.
New:
- Support for Lua Coroutines via the LuaThread type
- Support for interacting with tuples via the LuaTuple and LuaCallableExtra types
- Support for getting lua functions as a callable via the LuaCallable type.
- Support for LuaJIT and lua 5.1 on top of 5.4
- Support for GDExtension
- Lots of code cleanup and improvement.
Removed:
- Threading is no longer supported.
Special thanks to @martimmatias for helping with the documentation.
While the version is being bumped to beta, this is by no means a feature freeze. A best effort will be made to maintain the current API. But there are no guarantees.
v1.1-stable
Added pull_variant function.
Fixed bug caused by not popping the stack after reading values from Lua.
Build from godot 3.5
Version 1.0 Stable Release
This version of the module should support any platform and use case as well as have minimal errors. No compatibility breaking changes will be made in v1. Below I included export templates for Windows and Webassembly.
Version 0.1 Beta release 1
This build should be stable. I am adding pre built binary's for windows and linux. Please note that export templates will still need to be manually compiled.