Jump to content
  • Advertisement
  • entries
    437
  • comments
    1000
  • views
    337277

GmDotNet

Sign in to follow this  
evolutional

130 views

Awww yeah. Check this out...


A custom class declaration:-

[GameMonkeyType("Test")]
public class Test
{
public Test()
{
testMember = 100;
stringData = "";
floatMember = 14.2f;
}

[GameMonkeyMethod("DoSomething")]
public void DoSomething()
{
Console.WriteLine(testMember.ToString());
}

[GameMonkeyProperty("testMember")]
public int testMember;
[GameMonkeyProperty("stringData")]
public string stringData;
[GameMonkeyProperty("floatMember")]
public float floatMember;
}



And then to bind it:


using GMDotNet;

static void Main(string[] args)
{
Machine m = new Machine();
int ret = 0;
m.BindType(typeof(Test));
ret = m.ExecuteString("global a = Test();");

ret = m.ExecuteString("a.testMember = 50;");
ret = m.ExecuteString("print( a.testMember );");

ret = m.ExecuteString("a.stringData = \"Hello there\";");
ret = m.ExecuteString("print( a.stringData );");

ret = m.ExecuteString("print( a.floatMember );");
ret = m.ExecuteString("a.floatMember = 50.6f;");
ret = m.ExecuteString("print( a.floatMember );");
}



And hey presto, simple GM class binding...

Now for the more 'complex' examples :(
Sign in to follow this  


2 Comments


Recommended Comments

OMG GM!!!!! You've made some progress with that.

Would it be possible to add a "Type" to GM? It would be really cool if we could expose full .NET Assemblies to GM [wink].

Share this comment


Link to comment
That looks really nice. I've been looking into nekovm binding and have dispatched SHilbert to write a nicer version of SHilScript for possible research and use.

But GameMonkey intrigues me, particularly if I can bind objects and use it across platforms.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!