Closed cenullum closed 2 years ago
I was actually testing another bug on array and dictionary. even you can see
func test_w_dict(lua,file_name):
lua_cores_dict[file_name]=lua
lua_cores_dict[file_name].kill_all()
lua_cores_dict.clear()
func test_w_array(lua):
lua_cores_array.append(lua)
for lua in lua_cores_array:
lua.kill_all()
lua_cores_array.clear()
I couldn't find any related part about table on the project but I get these errors sometimes with the same lua file. I thought it was about array or dictionary. maybe because of memory leak
So at least with the first issue, destroying the lua object while code is still running without running kill_all first will probably always result in a crash. If possible I would try to avoid destroying the lua object at all while code is being executed. Instead of having modders write infinite loops maybe just have update functions that get called. I will still be looking into the issue further.
yes though you're right no one will need an infinite loop if it never blocks or sleeps. I also tried it with process func, the program closes after 10 seconds as expectly. I was expecting the same thing on infinite loop
value=0
floored_value=0
function process(delta)
value=value+delta
if floored_value ~= math.floor(value) then
floored_value= math.floor(value)
log(floored_value)
end
end
extends Node
var lua_cores_dict={}
func _ready():
get_tree().connect("files_dropped", self, "_files_dropped")
func destroy_lua_dict():
output("started to destroy luas")
for key in lua_cores_dict.keys():
output(key)
lua_cores_dict[key].kill_all()
lua_cores_dict.clear()
output("finished the destroying luas")
func _files_dropped(files, screen):
#burdaki files string array
output(files)
if files[0].get_extension() =="lua":
output("this is a lua file")
var lua = Lua.new()
lua_cores_dict[files[0]]=lua
lua.set_threaded(true)
lua.expose_function(self, "output", "log")
lua.do_file(files[0],true , self,"output")
yield(get_tree().create_timer(10.0), "timeout")
destroy_lua_dict()
#test_w_array(lua)
func _process(delta):
for key in lua_cores_dict.keys():
if( lua_cores_dict[key].lua_function_exists("process") ):
lua_cores_dict[key].call_function( "process", [delta])
func output(_log):
get_node("CanvasLayer/Control/output").text+="\n"+str(_log)
print(_log)
Threading will no longer be done by the module but will be done by the user them selfs if the wish. If this is till a issue using GDScript threads feel free to re open the issue.
the example project here: Test.zip drag and drop test5.lua in the project files