I tried this myself. I created a hooks.editor_script in the project root with this content:
local M = {}
local function write(filename, data)
local file = io.open(filename, "a")
file:write(data .. "\n")
file:flush()
file:close()
end
function M.on_build_started(opts)
write("build.txt", "on_build_started")
end
function M.on_build_finished(opts)
write("build.txt", "on_build_finished")
end
function M.on_bundle_started(opts)
write("build.txt", "on_bundle_started")
end
function M.on_bundle_finished(opts)
write("build.txt", "on_bundle_finished")
end
function M.on_target_launched(opts)
write("build.txt", "on_target_launched")
end
function M.on_target_terminated(opts)
write("build.txt", "on_target_terminated")
end
return M
I then chose Project->Reload Editor Scripts and did Project->Build. After the project was started and then shut down I inspected the created build.txt:
So this is odd. I started up the editor this morning, pasted in your script and it worked! huzzah! Then I pasted in the sample code from the docs, and it also worked.
I think the error I was seeing was a stale error message related to an earlier experiment with the on_build_started method where I was incorrectly calling editor.get with a single parameter.