コード例 #1
0
ファイル: LuaComponent.cs プロジェクト: kpalosaa/gwen-net-lua
        public LuaComponent(Gwen.Control.ControlBase parent, DynValue constructor, Gwen.Xml.IXmlSource xmlSource, Script script)
            : base(parent, xmlSource)
        {
            this.script = script;

            DynValue result = script.Call(constructor, View);

            switch (result.Type)
            {
            case DataType.Table:
                self = result;
                break;

            case DataType.Tuple:
                if (result.Tuple.Length >= 1)
                {
                    self = result.Tuple[0];
                }
                if (result.Tuple.Length >= 2)
                {
                    if (result.Tuple[1].Type == DataType.Function)
                    {
                        onCreated = result.Tuple[1];
                    }
                }
                break;
            }

            if (self == null)
            {
                throw new ScriptRuntimeException("Component must be implemented as a lua table.");
            }
        }
コード例 #2
0
ファイル: LuaComponent.cs プロジェクト: kpalosaa/gwen-net-lua
 public static void RegisterComponent(string name, DynValue constructor, Gwen.Xml.IXmlSource xmlSource, Script script)
 {
     if (!Gwen.Xml.Component.Register <LuaComponent>(name, constructor, xmlSource, script))
     {
         throw new ScriptRuntimeException("Failed to register component. Name already exists.");
     }
 }