HELP!!lua script and "open editor" problem。

Forums: HELP!!lua script and "open editor" problem。
Forum for OctaneRender Lua scripting examples, discussion and support.

HELP!!lua script and "open editor" problem。

Postby butterhuang » Fri Jul 03, 2015 2:28 pm

butterhuang Fri Jul 03, 2015 2:28 pm
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?
butterhuang
 
Posts: 11
Joined: Mon Jun 01, 2015 5:10 am

Re: HELP!!lua script and "open editor" problem。

Postby stratified » Tue Jul 07, 2015 9:04 pm

stratified Tue Jul 07, 2015 9:04 pm
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
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: HELP!!lua script and "open editor" problem。

Postby butterhuang » Wed Jul 08, 2015 9:00 am

butterhuang Wed Jul 08, 2015 9:00 am
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!
butterhuang
 
Posts: 11
Joined: Mon Jun 01, 2015 5:10 am

Re: HELP!!lua script and "open editor" problem。

Postby haze » Thu Aug 20, 2015 10:46 pm

haze Thu Aug 20, 2015 10:46 pm
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)
User avatar
haze
OctaneRender Team
OctaneRender Team
 
Posts: 969
Joined: Sun Feb 08, 2015 8:57 pm

Re: HELP!!lua script and "open editor" problem。

Postby butterhuang » Tue Aug 25, 2015 5:23 am

butterhuang Tue Aug 25, 2015 5:23 am
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)
butterhuang
 
Posts: 11
Joined: Mon Jun 01, 2015 5:10 am

Re: HELP!!lua script and "open editor" problem。

Postby haze » Tue Sep 01, 2015 1:21 am

haze Tue Sep 01, 2015 1:21 am
Use this line only:
Code: Select all
octane.gui.dispatchGuiEvents(3)
User avatar
haze
OctaneRender Team
OctaneRender Team
 
Posts: 969
Joined: Sun Feb 08, 2015 8:57 pm

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 6 guests

Tue Apr 16, 2024 11:55 am [ UTC ]