|
From: klaas.holwerda <ng...@kl...> - 2014-03-30 22:10:34
|
Hi,
Recursive calls to RunBuffer() is a problem, gives an assert.
int wxLuaState::RunBuffer(const char buf[], size_t size, const wxString &name, int nresults)
{
wxCHECK_MSG(Ok(), LUA_ERRRUN, wxT("Invalid wxLuaState"));
wxCHECK_MSG(!M_WXLSTATEDATA->m_wxlStateData->m_is_running, LUA_ERRRUN, wxT("Lua interpreter is
already running"));
Maybe a solution could be to make m_running an integer, which is incremented and decremented, as
long as > 1, interpreter is running.
But maybe it should be done different, still I would like to use the same wxlua state.
Recursive happens in lua scripts which define functions to be used inside canvas objects, and are
run there using:
wxLuaState lst = a2dLuaWP->GetLuaState();
lua_State* L = lst.GetLuaState();
if ( 0 != lst.RunString( m_script ) )
The function is defined like this in the wxLua script.
TheObjectAddScript_2 =
[[
function XoverX( canobj, x, y, args )
fill = wx.a2dFill( args.Colour )
local childs = canobj:CreateChildObjectList()
canobjcirc2 = wx.a2dCircle( 0, 0, 20 )
childs:push_back( canobjcirc2 )
for i = -args.maxX, args.maxX do
local y2
if i ~= 0 then
y2 = -args.maxY*math.sin(i/16)/(i/16)
else
y2 = -args.maxY; --sin(x)/x goes to one at zero
end
-- all relative
line = wx.a2dRect( i, 0, 0.1, y2 )
line:SetFill( fill )
childs:push_back( line )
end
end
]]
-- add the object using the above string as input script
canobjAddScript2 = wx.a2dCanvasObjectLua( 350, -450, TheObjectAddScript_2, "XoverX" )
Regards,
Klaas
|