<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Maratis forum - Programming Like you Speak.]]></title>
	<link rel="self" href="http://forum.maratis3d.com/extern.php?action=feed&amp;tid=830&amp;type=atom"/>
	<updated>2013-10-13T04:30:26Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.maratis3d.com/viewtopic.php?id=830</id>
		<entry>
			<title type="html"><![CDATA[Programming Like you Speak.]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=5484#p5484"/>
			<content type="html"><![CDATA[<p>I posted a link to a tutorial I made on how to understand computer programming. And to deduce the idea down even further I want to post on how to PROGRAM LIKE YOU SPEAK. </p><p>In the tutorial I said a program is like a RECIPE. A recipe has ingredients and instructions on how to use those ingredients to make a meal. The ingredients of programming are VARIABLES. The instructions of programming are called STATEMENTS. And a FUNCTION is a collection of STATEMENTS. For example, when you say &quot;BAKE&quot; you are saying, &quot;Press Bake on the stove.&quot; And when you say &quot;PRESS,&quot; you are really saying, &#039;&#039;Take your finger and apply force to a button that reads &quot;Press.&quot;</p><p>Variables are named like NOUNS(person,place,thing, or idea) and functions are named like VERBS(Action words)</p><p>This is just how programming works. In LUA (the scripting language for Maratis) a function looks like this:<br /></p><div class="codebox"><pre><code>Bake()</code></pre></div><p>And a variable looks like this<br /></p><div class="codebox"><pre><code>button =</code></pre></div><p>But you have to MAKE THE INSTRUCTIONS for the Bake() function. When you type Bake() you want something to happen. </p><p>So how do you program like you speak? Just think about what parts of your sentence are nouns, and which are verbs.</p><p>Hmm, let&#039;s think of a game scenario:</p><p>--SCENARIO<br />Joey is locked inside of a room. There is a small window above him that lets in a bit of light, and an old chair leaning against a table on a wall. Is there a key in the room? Is there anything else that could help him escape this dark room?<br />--END SCENARIO</p><p>Well, we have a lot of information in this scenario. And in fact, this could be a complete (however small it may be) game. <br />Let&#039;s see what NOUNS we have:<br /></p><div class="codebox"><pre><code>joey =
room =
door =
light =
window =
chair =
table =
wall =
key =</code></pre></div><p>Let&#039;s figure out some actions Joey either has taken, is taking, or could take:</p><div class="codebox"><pre><code>Search()
Escape()
LookAtWindow()
GrabChair()
TurnOnLight()</code></pre></div><p>That&#039;s good enough so far. We can use BOOLEANS to give objects STATES. For example we could set the light to OFF or ON. We could set the door to OPEN or CLOSED. It&#039;s done like this:</p><div class="codebox"><pre><code>closed = true
on = false
scared = false</code></pre></div><p>Later on, if something happens, we could then change the &#039;&#039;on&quot; variable to true. And if the on variable is true, we can cause another function to happen. The way this is done is with CONDITIONAL STATEMENTS.</p><p>Conditional statements help control the FLOW of actions so that things don&#039;t happen at the same time. Example:</p><div class="codebox"><pre><code>if closed = false then
     Escape()
end</code></pre></div><p>So if we later set closed to false, then Joey can escape. </p><p>Conditional statements control the GAMEPLAY of the game. </p><p>Here is another use:</p><div class="codebox"><pre><code>if scared=true then
     LookAtWindow()
end</code></pre></div><p>--More to come when I think of it...</p>]]></content>
			<author>
				<name><![CDATA[Tutorial Doctor]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2493</uri>
			</author>
			<updated>2013-10-13T04:30:26Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=5484#p5484</id>
		</entry>
</feed>
