Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualsatsujin

Posted 24 November 2013 - 06:57 AM

Hi folks,

 

I'm having trouble creating a C#.NET object in Lua. I can do this no problem with the System.Console type but this object has another object in it's constructor so that may be the issue. I hope you guys can help.

 

Here is my c# code:

 

public class GameController : DrawableGameComponent
    {
        public string gcname;
 
        public GameController(Game game)
            : base(game)
        {
            this.gcname = "Pulled from gc";
        }

 

    }

 

Here is my lua code:

luanet.load_assembly ("PointClick.GameController");
luanet.load_assembly ("Microsoft.Xna.Framework.Game");
luanet.load_assembly ("Microsoft.Xna.Framework");
 
game = luanet.import_type("Microsoft.Xna.Framework.Game");
gObj2 = luanet.import_type("PointClick.GameController");
 
  Console.WriteLine(gObj.gcname);
 
  --gObj2=gOb2:GameController(game);
  gObj2.gcname=" to this";
  gObj= gObj2;

 

 

I get the error "attempt to index global 'gOb2' (a nil value)" on the line "gObj2.gcname=to this"

Thanks in advance.


#1satsujin

Posted 24 November 2013 - 06:35 AM

Hi folks,

 

I'm having trouble creating a C#.NET object in Lua. I can do this no problem with the System.Console type but this object has another object in it's constructor so that may be the issue. I hope you guys can help.

 

Here is my c# code:

 

public class GameController : DrawableGameComponent
    {
        public string gcname;
 
        public GameController(Game game)
            : base(game)
        {
            this.gcname = "Pulled from gc";
        }

 

    }

 

Here is my lua code:

luanet.load_assembly ("PointClick.GameController");
luanet.load_assembly ("Microsoft.Xna.Framework.Game");
luanet.load_assembly ("Microsoft.Xna.Framework");
 
game = luanet.import_type("Microsoft.Xna.Framework.Game");
gObj2 = luanet.import_type("PointClick.GameController");
 
 
 
  Console.WriteLine(gObj.gcname);
 
  --gObj2=gOb2:GameController(game);
  gObj2.gcname=" to this";
  gObj= gObj2;

 

 

I get the error "attempt to index global 'gOb2' (a nil value)" on the line "gObj2.gcname=to this"

Thanks in advance.


PARTNERS