Skip to content

Commit

Permalink
revert dostring,fix main.txt error
Browse files Browse the repository at this point in the history
  • Loading branch information
pangweiwei committed Jul 1, 2015
1 parent 0007313 commit fb3ac69
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
5 changes: 0 additions & 5 deletions Assets/Slua/Resources/main.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ function main()
print("using lua")
end

HelloWorld.depth= "a"
print(HelloWorld.depth)
HelloWorld.priority=1
print(HelloWorld.priority)

-- test custom component
local x=UnityEngine.GameObject("OoOo")
x:AddComponent(SLuaTest)
Expand Down
17 changes: 14 additions & 3 deletions Assets/Slua/Script/LuaState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,10 @@ static int init(IntPtr L)
return unpack(ret)
end
";
// overload resume function for report error
if (LuaDLL.lua_dostring(L, resumefunc) != 0)
LuaObject.lastError(L);

// overload resume function for report error
LuaState.get(L).doString(resumefunc);

LuaDLL.lua_pushcfunction(L, dofile);
LuaDLL.lua_setglobal(L, "dofile");

Expand Down Expand Up @@ -708,6 +708,17 @@ internal static int dofile(IntPtr L)
}
return 0;
}

public object doString(string str)
{
byte[] bytes = Encoding.UTF8.GetBytes(str);

object obj;
if (doBuffer(bytes, "temp buffer", out obj))
return obj;
return null; ;

}

[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
internal static int loader(IntPtr L)
Expand Down

0 comments on commit fb3ac69

Please sign in to comment.