game = luanet.import_type("Microsoft.Xna.Framework.Game");
gObj2 = luanet.import_type("PointClick.GameController");
Here, you create an object named gObj2
But here, you try to print out the gcname
member of an object called gObj
which, unless it's created somewhere else, doesn't exist at this point (note the missing '2' in the name), so it's probably just writing nil to the console if it's not erroring.
For clarity, if this line in your actual source is actually commented out, it should be omitted from the post. Because if it's not actually commented out in your working source, then it looks like you are trying to call a function on an object called gOb2
, which again does not exist. (Remember, to this point you have created an object called gObj2
only, whereas this is trying to access gOb2
without the 'j'.
gObj2.gcname=" to this";
This line, where you indicate the error occurs, actually should work as long as the above call gObj2 = luanet.import_type("PointClick.GameController");
succeeds. After that call, you should test to see if gObj2==nil
which would indicate that there is a problem with the import_type method call. It's entirely possible there is a problem here, but you report that the error is from trying to access the global gOb2
(note the missing 'j'), which you are not trying to access on this line, so the error kind of makes no sense to be on this line.
Finally, you get around to assigning gObj
a value, but it's too late for the earlier attempts to access it to succeed.
The chief problem you have for debugging purposes is your poor naming. You have gObj, gOb2 and gObj2 all floating around in there, and those similar-but-different names just make it harder for you to spot problems. So I'd say, fix your naming first and see if it works; and if not, take a look at whatever is going on inside the call luanet.import_type("PointClick.GameController");
(of which I have no idea, not being a .NET kind of guy.)
First step? Fix your naming.