Page 1 of 1
HELP!!lua script and "open editor" problem。
Posted: Fri Jul 03, 2015 2:28 pm
by butterhuang
When I excute script in editor, the output will be blocking。
During excuting, I can't see only output log which I use octane.common.print or print function to print in the script。
If the script exit, the all output log can display in the Output pannel together。
My script will excute with a long time。 Even I output the log to a log file,the output content still be blocked unitl the script exit。
How can I avoid this?
Re: HELP!!lua script and "open editor" problem。
Posted: Tue Jul 07, 2015 9:04 pm
by stratified
Yes, when a script is executing, the user interface is disable. This is by design, we don't want users fiddling around with the nodes while a script is executing because this can lead to unexpected behaviour.
You cannot avoid this. Some users work around this by displaying a progress bar.
cheers,
Thomas
Re: HELP!!lua script and "open editor" problem。
Posted: Wed Jul 08, 2015 9:00 am
by butterhuang
stratified wrote:Yes, when a script is executing, the user interface is disable. This is by design, we don't want users fiddling around with the nodes while a script is executing because this can lead to unexpected behaviour.
You cannot avoid this. Some users work around this by displaying a progress bar.
cheers,
Thomas
yeah, you can just block the editor toolbar and input area, but now the output area is blocked. it is not writable!
Re: HELP!!lua script and "open editor" problem。
Posted: Thu Aug 20, 2015 10:46 pm
by haze
butterhuang wrote:When I excute script in editor, the output will be blocking。
During excuting, I can't see only output log which I use octane.common.print or print function to print in the script。
If the script exit, the all output log can display in the Output pannel together。
My script will excute with a long time。 Even I output the log to a log file,the output content still be blocked unitl the script exit。
How can I avoid this?
You might want to consider using
octane.gui.dispatchGuiEvents(1)
to flush output to the output window of the script editor. Something like the following:
Code: Select all
local ffi = require("ffi")
if ffi.os ~= "Windows" then
print("This script is only for windows")
return
end
ffi.cdef [[
void Sleep(int ms);
int poll(struct pollfd *fds, unsigned long nfds, int timeout);
]]
function sleep(t)
ffi.C.Sleep(t*1000)
end
co = coroutine.create(function()
for i=0,100 do
if i == 50 then
coroutine.yield()
end
print(i)
io.flush()
end
end)
coroutine.resume(co)
octane.gui.dispatchGuiEvents(3)
sleep(5)
coroutine.resume(co)
Re: HELP!!lua script and "open editor" problem。
Posted: Tue Aug 25, 2015 5:23 am
by butterhuang
such an ugly solution.
mist wrote:butterhuang wrote:When I excute script in editor, the output will be blocking。
During excuting, I can't see only output log which I use octane.common.print or print function to print in the script。
If the script exit, the all output log can display in the Output pannel together。
My script will excute with a long time。 Even I output the log to a log file,the output content still be blocked unitl the script exit。
How can I avoid this?
You might want to consider using
octane.gui.dispatchGuiEvents(1)
to flush output to the output window of the script editor. Something like the following:
Code: Select all
local ffi = require("ffi")
if ffi.os ~= "Windows" then
print("This script is only for windows")
return
end
ffi.cdef [[
void Sleep(int ms);
int poll(struct pollfd *fds, unsigned long nfds, int timeout);
]]
function sleep(t)
ffi.C.Sleep(t*1000)
end
co = coroutine.create(function()
for i=0,100 do
if i == 50 then
coroutine.yield()
end
print(i)
io.flush()
end
end)
coroutine.resume(co)
octane.gui.dispatchGuiEvents(3)
sleep(5)
coroutine.resume(co)
Re: HELP!!lua script and "open editor" problem。
Posted: Tue Sep 01, 2015 1:21 am
by haze