<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Maratis forum - MScript::getInteger]]></title>
	<link rel="self" href="http://forum.maratis3d.com/extern.php?action=feed&amp;tid=411&amp;type=atom"/>
	<updated>2012-08-05T21:13:04Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.maratis3d.com/viewtopic.php?id=411</id>
		<entry>
			<title type="html"><![CDATA[Re: MScript::getInteger]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=2279#p2279"/>
			<content type="html"><![CDATA[<p>Normally, the -1 is used to parse arrays and special messages,<br />so it depends what you want to do ?</p><p>Are you making a custom function or something different ?</p>]]></content>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2012-08-05T21:13:04Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=2279#p2279</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MScript::getInteger]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=2278#p2278"/>
			<content type="html"><![CDATA[<p>I&#039;ve just done a quick test</p><p>&nbsp; &nbsp; const char* params[10];<br />&nbsp; &nbsp; for(int i = 0; i &lt; 10; ++i)<br />&nbsp; &nbsp; &nbsp; &nbsp; params\[i\] = script-&gt;getString((unsigned int)(i - 5));</p><p>Wow. lua is weird. Both positive and negative work :S Weird. I wonder why all lua docs I&#039;ve read would take negative numbers</p>]]></content>
			<author>
				<name><![CDATA[Nistur]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=500</uri>
			</author>
			<updated>2012-08-05T21:12:51Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=2278#p2278</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MScript::getInteger]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=2277#p2277"/>
			<content type="html"><![CDATA[<p>Ok then, I have no idea how lua works internally, but I am seeing negative indices in things inside MScript.cpp.</p><p>Doesn&#039;t matter if it doesn&#039;t make the build, I guess, I can always hack it for now <img src="http://forum.maratis3d.com/img/smilies/wink.png" width="15" height="15" alt="wink" /> </p><p>script-&gt;getInteger((unsigned int)-1);</p>]]></content>
			<author>
				<name><![CDATA[Nistur]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=500</uri>
			</author>
			<updated>2012-08-05T20:50:54Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=2277#p2277</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MScript::getInteger]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=2276#p2276"/>
			<content type="html"><![CDATA[<p>I&#039;ve used that to create custom function from c++, it was a long time ago so it&#039;s not fresh in my mind,<br />but I think it was something like :</p><div class="codebox"><pre><code>int myCustomFunction(void)
{
    if(script-&gt;getArgsNumber() == 2)
    {
        int firstArgument = script-&gt;getInteger(0);
        int secondArgument = script-&gt;getInteger(1);

        // do a simple addition
        script-&gt;pushInteger(firstArgument+secondArgument);
        return 1; 
    }

    return 0;
}

script-&gt;addFunction(&quot;myCustomFunction&quot;, myCustomFunction);</code></pre></div><p>I just finished the builds, so lets wait the first debug pass...</p>]]></content>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2012-08-05T20:38:39Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=2276#p2276</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[MScript::getInteger]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=2275#p2275"/>
			<content type="html"><![CDATA[<p>I&#039;ve been running through my code, trying to expose some helpful things to lua (like messages in my message system) and I was trying to sort one thing, and something felt a bit wrong, so I checked it up. MScript::getInteger (and other get functions) take unsigned int.</p><p>Checking a previous project, indices are usually negative... I just checked the actual code and you&#039;re doing arg+1, which I assume was meant to be, as a C programmer, people would be used to asking for 0 .. n-1 rather than 1 .. n. I think it&#039;s possible to hack it by casting the sign off... but I think the &quot;nicer&quot; way to do it might be to do something like lua_tointeger(m_state, arg - getArgsNumber());</p><p>Wondering if I am still early enough to submit this &quot;fix&quot; in time for the builds... or if it was done like that for a reason I can&#039;t see?</p>]]></content>
			<author>
				<name><![CDATA[Nistur]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=500</uri>
			</author>
			<updated>2012-08-05T20:23:33Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=2275#p2275</id>
		</entry>
</feed>
