<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Maratis forum - How to bind custom lua functions?]]></title>
	<link rel="self" href="http://forum.maratis3d.com/extern.php?action=feed&amp;tid=771&amp;type=atom"/>
	<updated>2013-09-11T18:43:12Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.maratis3d.com/viewtopic.php?id=771</id>
		<entry>
			<title type="html"><![CDATA[Re: How to bind custom lua functions?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=4949#p4949"/>
			<content type="html"><![CDATA[<p>this works like a charm thanks anael&nbsp; <img src="http://forum.maratis3d.com/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /> .</p>]]></content>
			<author>
				<name><![CDATA[Crucio777]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1176</uri>
			</author>
			<updated>2013-09-11T18:43:12Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=4949#p4949</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to bind custom lua functions?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=4947#p4947"/>
			<content type="html"><![CDATA[<p>the function needs to return an int,<br />0 if the lua function doesn&#039;t return anything,<br />1 if the function returns 1 value, 2 for 2 values etc.</p><p>You can send values to lua using MScriptContext pushInt, pushString...<br />And get arguments from the lua call using getInteger, getString...</p><p>exemple :</p><div class="codebox"><pre><code>#include &lt;MEngine.h&gt;
#include &quot;MyPlugin.h&quot;

int myFunction(void)
{
    MEngine * engine = MEngine::getInstance();
    MScriptContext * script = engine-&gt;getScriptContext();
    script-&gt;pushString(&quot;Hello World !&quot;);
    return 1;
}

void StartPlugin(void)
{
    MEngine * engine = MEngine::getInstance();
    MScriptContext* script = engine-&gt;getScriptContext();

    script-&gt;addFunction(&quot;myFunction&quot;, myFunction);
}</code></pre></div><p>In lua the function will be used like this :</p><div class="codebox"><pre><code>text = myFunction() -- &quot;Hello World !&quot;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2013-09-11T09:44:38Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=4947#p4947</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to bind custom lua functions?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=4946#p4946"/>
			<content type="html"><![CDATA[<p>hey thanks for that just another small question how should the&nbsp; c++ function for lua script&nbsp; should be?<br />can you give me&nbsp; an small example of the function it will be really helpful. i seem to cannot get it right <br />thank you for help.</p>]]></content>
			<author>
				<name><![CDATA[Crucio777]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1176</uri>
			</author>
			<updated>2013-09-11T03:43:35Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=4946#p4946</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to bind custom lua functions?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=4939#p4939"/>
			<content type="html"><![CDATA[<p>Hi,<br />yes you can add custom function using a game plugin with MScriptContext :</p><p>MEngine* engine = MEngine::getInstance();<br />MScriptContext* script = engine-&gt;getScriptContext();<br />if(script)<br />&nbsp; &nbsp; script-&gt;addFunction(&quot;myFunction&quot;, myFunction);</p>]]></content>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2013-09-10T18:27:58Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=4939#p4939</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[How to bind custom lua functions?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=4938#p4938"/>
			<content type="html"><![CDATA[<p>Hello there ,<br />as the topic subject&nbsp; suggests how would one bind custom/new functions for lua scripting . is it possible through game plugin ?.<br />I hope this is the right section for the topic .</p>]]></content>
			<author>
				<name><![CDATA[Crucio777]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1176</uri>
			</author>
			<updated>2013-09-10T16:19:40Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=4938#p4938</id>
		</entry>
</feed>
