Example #1
0
    public LuaWTBObject Duplicate()
    {
        List <WTBObject> dupeObjects = new List <WTBObject>()
        {
            WTBObject
        };

        dupeObjects.AddRange(WTBObject.GetChildrenAll());

        DuplicateTargetCommand cmd = new DuplicateTargetCommand(dupeObjects);

        // list also contains the children
        List <WTBObject> duplicatedWTBOs = cmd.LuaDuplicate();

        foreach (WTBObject wtbo in duplicatedWTBOs)
        {
            wtbo.Sync();
            LuaHandler scriptHandler = wtbo.GetComponent <LuaHandler>();
            if (scriptHandler != null)
            {
                scriptHandler.Run();
            }
        }

        duplicatedWTBOs[0].transform.position = WTBObject.transform.position;
        duplicatedWTBOs[0].transform.rotation = WTBObject.transform.rotation;

        duplicatedWTBOs[0].ComponentByName("Transform").PropertyByName("HasPhysics").Refresh();

        return(Task.GetOrMakeLuaPart(duplicatedWTBOs[0]));
    }
Example #2
0
File: Lua.cs Project: ItsKaa/Ditto
        public static bool ExecuteMethod(LuaScript luaScript, LuaScriptMethods scriptMethods)
        {
            var scriptResult = LuaHandler.Run(luaScript);

            if (scriptResult != null)
            {
                var func = GetMethodFromScript(luaScript, scriptMethods);
                if (func != null)
                {
                    var funcResult = luaScript.Script.Call(func);
                    return(true);
                }
            }
            return(false);
        }