Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

I Got It Working, But Found A Potential Freeze With Invalid Lua #6

Open
ghost opened this issue Oct 27, 2019 · 2 comments
Open

I Got It Working, But Found A Potential Freeze With Invalid Lua #6

ghost opened this issue Oct 27, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Oct 27, 2019

I don't know what I did to get the module to work (probably the part where I renamed the gdns file to LuaScript.gdns instead of just Lua.gdns). This is aside from my merging the latest commit of Godot 3.2-dev with my copy of Godot (which fixed a freeze on all GDNativeLibraries).

However, I noticed loading an invalid Lua file freezes the game as a whole.

Trying to load this file causes the freeze.

local class = require 'lua.class' -- Import the system class library
godot.Node = require 'godot.Node' -- Make sure to import the base class


local NewScript = class.extends(godot.Node) -- Create the user subclass

function NewScript:_ready()
	print("Hello Lua")
end

function NewScript:_process(delta)

end

function NewScript:command(variable)
	return "Variable: %s" % variable
end

function NewScript:get_class()
	return "Test Lua"
end

return NewScript

This file works fine.

function sum(...)
    result = 0
    local arg = {...}
    for i,v in ipairs(arg) do
       result = result + v
    end
    return result
end
@ghost
Copy link
Author

ghost commented Oct 27, 2019

The original file was from a lua module to be compiled into Godot.

This matters as I plan on sandboxing the Lua programs and letting players write lua for automation in their game. Also, the code would run server-side, so it is not good if the server freezes due to invalid lua.

@ghost ghost changed the title I Got It Working I Got It Working, But Found A Potential Freeze With Invalid Lua Oct 27, 2019
@ghost
Copy link
Author

ghost commented Oct 27, 2019

With a valid lua script, if changes are made rapidly for testing, it can freeze the main thread of the game.

I managed to pull an error with Error: script not loaded (test_sandbox) where I am testing cSum(1, 3) with a sandboxed lua function I am working on. I am going to try to put this on a separate thread and lower its priority so it doesn't make my game run at 90% cpu when the script freezes up. I'll report if this workaround works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants