<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Maratis forum - Scripting]]></title>
	<link rel="self" href="http://forum.maratis3d.com/extern.php?action=feed&amp;fid=7&amp;type=atom"/>
	<updated>2017-01-02T02:45:12Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.maratis3d.com/index.php</id>
		<entry>
			<title type="html"><![CDATA[Set object position to mouse x and y position]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=1224&amp;action=new"/>
			<summary type="html"><![CDATA[<p>so heres my simple code:</p><div class="codebox"><pre><code>Camera =getObject(&quot;Camera0&quot;)
player = getObject(&quot;Entity0&quot;) 



function onSceneUpdate()
colorr=math.random(0, 2)
colorg=math.random(0, 2)
colorb=math.random(0, 2)




getX = getAxis(&quot;MOUSE_X&quot;)
getY = getAxis(&quot;MOUSE_Y&quot;)

var1 = updateMatrix(getX)
print (var1)



Camera = getCurrentCamera()
setCameraClearColor(Camera, {colorr, colorg, colorb})




end</code></pre></div><p>i&#039;m trying to set the position of player to mouse position but when i use &quot;getAxis(&quot;MOUSE_X&quot;) it throws out a strange float, what can i do with this data?</p>]]></summary>
			<author>
				<name><![CDATA[blend]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1343</uri>
			</author>
			<updated>2017-01-02T02:45:12Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=1224&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Play sound once]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=443&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Hi,<br />I am having problems getting a sound to play once in my script.<br />At the start:<br />soundplay = 0<br />&nbsp; &nbsp;function playsound()<br />&nbsp; &nbsp; &nbsp; &nbsp;if soundplay == 0 then playSound(Sound0) end<br />&nbsp; &nbsp; &nbsp; &nbsp;soundplay = 1<br />&nbsp; &nbsp;end<br />Then:<br />function onSceneUpdate()<br />if isCollisionBetween(Car, Ground)<br />if soundplay == 0 then playsound()<br />else<br />soundplay = 0<br />end<br />end</p><p>It loops repeatedly, but I&#039;m not sure why, could anyone help?</p>]]></summary>
			<author>
				<name><![CDATA[Vegas]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1037</uri>
			</author>
			<updated>2014-12-19T22:45:56Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=443&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[A few questions]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=1106&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Hey guys,</p><p>So, I created a game in which the graphics were made entirely separate from the scripts. All of the basic scripts were created inside of a test environment. They work in that area.<br />Now, however, when I have applied the scripts to the larger level (which has roughly 400 objects), there are certain areas that nonsensically just don&#039;t work. I&#039;m thinking it has something&nbsp; to do with the amount objects inside of the level. If it is necessary to&nbsp; split the area up into different levels, then it is fine to do so.<br />Although, is there something I should be doing differently as far as object properties/code?</p><p>&nbsp; &nbsp; if (isKeyPressed(&#039;UP&#039;)) then<br />&nbsp; &nbsp; &nbsp; &nbsp; offset = offset &lt; 3 and offset + 0.2 or offset<br />&nbsp; &nbsp; &nbsp; &nbsp; setBehaviorVariable(camera, 1, &#039;offset&#039;, {0, 7, 2 + offset})<br />&nbsp; &nbsp; end<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; if (isKeyPressed(&#039;DOWN&#039;)) then<br />&nbsp; &nbsp; &nbsp; &nbsp; offset = offset &gt; -3 and offset - 0.2 or offset<br />&nbsp; &nbsp; &nbsp; &nbsp; setBehaviorVariable(camera, 1, &#039;offset&#039;, {0, 7, 2 + offset})<br />&nbsp; &nbsp; end</p><p>this area used to work fine, but for some reason it hates the down key now. When I press the down key, Maratis freezes, returns errors of certain objects not existing (as a result of it freezing), and forces me to exit the program.<br />I can even comment out the up key section entirely and it simply just hates the down key</p><p>Another area:<br />&nbsp; &nbsp; if (isKeyPressed(&#039;SPACE&#039;)) then<br />&nbsp; &nbsp; &nbsp; &nbsp; if (coll &gt; 1) then<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addCentralForce(player, {0, 0, 20})<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; changeAnimation(playerMesh, 2)<br />&nbsp; &nbsp; &nbsp; &nbsp; end<br />&nbsp; &nbsp; end</p><p>this makes the program not be able to present any kind of recognition to pressing keys and freezes, but i can still hit esc.<br />the game throws the error for the line if(coll &gt;1)then</p>]]></summary>
			<author>
				<name><![CDATA[cygorx]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2837</uri>
			</author>
			<updated>2014-12-13T20:40:50Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=1106&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Combining LuaSocket and Maratis?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=1079&amp;action=new"/>
			<summary type="html"><![CDATA[<p>I discovered this engine a few days ago and it looked pretty neat, but as far as I know it does not have any networking capability.</p><p>Would it be easy to add this to Maratis? If so, how would I go about doing it?</p>]]></summary>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2865</uri>
			</author>
			<updated>2014-10-31T10:45:32Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=1079&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[How to get the position of a clone?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=1075&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Hi, everyone!<br />I have a question. Is it possible to get the position of a clone object?<br />Let&#039;s say I have simple script like this:</p><div class="codebox"><pre><code>Sphere = getObject(&quot;Sphere&quot;)

function onSceneUpdate()

    bullet = getClone(Sphere)
    translate(bullet, {0, 1, 0}, &quot;local&quot;)

end</code></pre></div><p>Now, I can get the position of the Sphere using <strong>getPosition(Sphere)</strong>. But how can I get the position of the bullet? I tried using the same getPosition function, but it doesn&#039;t seem to work. Anyone can help?</p>]]></summary>
			<author>
				<name><![CDATA[Xone]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=289</uri>
			</author>
			<updated>2014-10-02T04:40:31Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=1075&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Sound Scripts]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=1066&amp;action=new"/>
			<summary type="html"><![CDATA[<p>I will update this post with a collection of sound scripts I am working on. </p><p>The first one I made was a script that plays a sound after a number of seconds. This script scared me, because you can&#039;t really anticipate the sound. </p><p>SoundOnTimer:<br /></p><div class="codebox"><pre><code>--TIME--

knock = getObject(&quot;Knock&quot;)
 i = 0

function soundOnTimer(seconds,sound)
    i = i + 1
    t = i/60
    
    if t &gt; seconds then
        playSound(sound)
         i = 0
    end
end

function onSceneUpdate()
        soundOnTimer(10,knock)
end</code></pre></div>]]></summary>
			<author>
				<name><![CDATA[Tutorial Doctor]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2493</uri>
			</author>
			<updated>2014-08-21T23:30:01Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=1066&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[1st Person Camera Made Easier]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=1065&amp;action=new"/>
			<summary type="html"><![CDATA[<p>I wanted to adjust the Sponza 1st person script so that it can be used in other projects easier. Here is the code:</p><div class="codebox"><pre><code>-----------------------------------------------------------------------------------
-- Maratis
-- Jules script test
-----------------------------------------------------------------------------------

Head = getObject(&quot;Head&quot;)

function Initialize()
    dx = 0.0
    dy = 0.0

    centerCursor()
    mx = getAxis(&quot;MOUSE_X&quot;)
    my = getAxis(&quot;MOUSE_Y&quot;)
end

Initialize()

function LookWith(object)

    -- rotate object (X mouse)
    rotate(object, {0, 0, -1}, dx*100)
    
    -- rotate object (Y mouse)
    rotate(object, {-1, 0, 0}, dy*100, &quot;local&quot;)    
    rotation = getRotation(object)
        
    if rotation[1] &gt; 90 then
        rotation[1] = 90
    elseif rotation[1] &lt; -90 then
        rotation[1] = -90
    end

    setRotation(object, rotation)
    
    -- get mouse direction
    dx = getAxis(&quot;MOUSE_X&quot;) - mx
    dy = getAxis(&quot;MOUSE_Y&quot;) - my

    -- center cursor
    centerCursor()
    
    mx = getAxis(&quot;MOUSE_X&quot;)
    my = getAxis(&quot;MOUSE_Y&quot;)
end

-- scene update
function onSceneUpdate()
        LookWith(Head)
end</code></pre></div>]]></summary>
			<author>
				<name><![CDATA[Tutorial Doctor]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2493</uri>
			</author>
			<updated>2014-08-21T19:39:04Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=1065&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Why getClone, but no deleting of created object?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=1039&amp;action=new"/>
			<summary type="html"><![CDATA[<p>There is a getClone(object), but no destroyClone() or deleteClone(). What if i want to delete the clone object? The idea is first you make a clone for the bullet or etc.. And then after you hit the target the clone gets deleted from memory.</p>]]></summary>
			<author>
				<name><![CDATA[Akira_san]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2764</uri>
			</author>
			<updated>2014-08-20T19:50:44Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=1039&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[onSceneUpdate() ?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=1043&amp;action=new"/>
			<summary type="html"><![CDATA[<p>The scripts have the function - onSceneUpdate(). I understand the meaning behind it, but why no info about it in the wiki lua docs?</p>]]></summary>
			<author>
				<name><![CDATA[Tutorial Doctor]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2764</uri>
			</author>
			<updated>2014-08-13T13:57:26Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=1043&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[How to make buttons in Maratis]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=1047&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Hi, everyone</p><p>I know that there are some discussions about how to make buttons in Maratis. Unfortunately, after doing some search and test, I still can&#039;t create buttons using <a href="http://wiki.maratis3d.org/index.php?title=RayHit">rayHit</a> (sorry for my noobiness <img src="http://forum.maratis3d.com/img/smilies/hmm.png" width="15" height="15" alt="hmm" />). So I tried to follow this tutorial about <a href="http://wiki.maratis3d.org/index.php?title=GetUnProjectedPoint">getUnProjectedPoint</a> but I got stuck again. <br />In my scene, I have three buttons: <strong>moveLeft, rotate,</strong> and <strong>moveRight</strong>. I want to use those buttons to move and rotate a <strong>cube</strong>.</p><p>Following the tutorial, I can make the rotation button to rotate the cube. However, when I moved the mouse cursor over the other buttons (moveLeft and moveRight), the cube also rotating. Can someone give me a hint of how to fix my script?</p><p>Here is the project file to download. <a href="https://www.dropbox.com/s/wzh0ioat20q8vgy/MouseOver_test.zip">https://www.dropbox.com/s/wzh0ioat20q8v &#133; r_test.zip</a><br />And here is the script based on the documentation:<br /></p><div class="codebox"><pre><code>moveRight = getObject(&quot;moveRight&quot;)
moveLeft = getObject(&quot;moveLeft&quot;)
Rotate = getObject(&quot;Rotate&quot;)
Cube = getObject(&quot;Cube&quot;)
Camera = getObject(&quot;Camera&quot;)

point = getUnProjectedPoint(Camera, vec3(x, y, z))

function onSceneUpdate()
  mx = getAxis(&quot;MOUSE_X&quot;)
  my = getAxis(&quot;MOUSE_Y&quot;)    
    
  V1 = getUnProjectedPoint(Camera, vec3(mx, my, 0))
  V2 = getUnProjectedPoint(Camera, vec3(mx, my, 1))
    
  point, Rotate = rayHit(V1, V2)

  if point then
    rotate(Cube, {0, 0, 1}, 4)
  end 

--[[
  if point then
    translate(Cube, {1, 0, 0}, 2)
  end 
  ]]--
  
end</code></pre></div><p>Thanks for any help.</p>]]></summary>
			<author>
				<name><![CDATA[Sponk]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=289</uri>
			</author>
			<updated>2014-08-04T10:22:43Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=1047&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Activate, Deactivate, IsVisible, IsActive?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=1038&amp;action=new"/>
			<summary type="html"><![CDATA[<p>What is the difference between Activate, Deactivate, IsVisible, IsActive?</p>]]></summary>
			<author>
				<name><![CDATA[Akira_san]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2764</uri>
			</author>
			<updated>2014-07-31T10:50:47Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=1038&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Functions request]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=152&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Please add here any suggestion about lua functions you are missing.</p><p>I&#039;m also using this thread to tell you that you can add custom script functions using c++ plugin (using the MScriptContext class)<br /><a href="http://www.maratis3d.org/engine_docs/class_m_script_context.html">http://www.maratis3d.org/engine_docs/cl &#133; ntext.html</a> (it&#039;s a basic lua wrapper)</p><p>If you used it and would like to share your additional functions to be added to the next Maratis release, please tell us <img src="http://forum.maratis3d.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></summary>
			<author>
				<name><![CDATA[Akira_san]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2014-07-29T20:28:07Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=152&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Why no LookAt() api?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=1035&amp;action=new"/>
			<summary type="html"><![CDATA[<p>In the scripting api, i dont see LookAt(target), whats the alternative?</p>]]></summary>
			<author>
				<name><![CDATA[Akira_san]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2764</uri>
			</author>
			<updated>2014-07-27T13:05:14Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=1035&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[enable physics on object in lua]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=1030&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Is it possible to enable physics on an object that does not have physics enabled or parents with physics in lua?<br />I have cloned objects that are unparented (setParent(object, 0)) so they can be transformed independently, <br />but it does not have collision because there is no physics enabled.</p><p>I&#039;m sure this is possible in C++, but I&#039;m curious if this is possible with the lua api.</p>]]></summary>
			<author>
				<name><![CDATA[bryce]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2839</uri>
			</author>
			<updated>2014-07-20T06:38:47Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=1030&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Passing variable value to shader question?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?id=1025&amp;action=new"/>
			<summary type="html"><![CDATA[<p>Hi. Is it possible by some way to pass variable to shader by script? For examle time.</p>]]></summary>
			<author>
				<name><![CDATA[Skywriter]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2629</uri>
			</author>
			<updated>2014-07-17T14:20:41Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?id=1025&amp;action=new</id>
		</entry>
</feed>
