<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://myst.dustbird.net/w/index.php?action=history&amp;feed=atom&amp;title=Dustin%27s_Sixth_Tutorial</id>
	<title>Dustin&#039;s Sixth Tutorial - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://myst.dustbird.net/w/index.php?action=history&amp;feed=atom&amp;title=Dustin%27s_Sixth_Tutorial"/>
	<link rel="alternate" type="text/html" href="http://myst.dustbird.net/w/index.php?title=Dustin%27s_Sixth_Tutorial&amp;action=history"/>
	<updated>2026-05-15T15:21:11Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>http://myst.dustbird.net/w/index.php?title=Dustin%27s_Sixth_Tutorial&amp;diff=400&amp;oldid=prev</id>
		<title>Dustin at 03:34, 20 October 2010</title>
		<link rel="alternate" type="text/html" href="http://myst.dustbird.net/w/index.php?title=Dustin%27s_Sixth_Tutorial&amp;diff=400&amp;oldid=prev"/>
		<updated>2010-10-20T03:34:58Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 03:34, 20 October 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{Deprecated}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Introduction=&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Introduction=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is an advanced topic, so don&amp;#039;t worry if you can&amp;#039;t follow it.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is an advanced topic, so don&amp;#039;t worry if you can&amp;#039;t follow it.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dustin</name></author>
		
	</entry>
	<entry>
		<id>http://myst.dustbird.net/w/index.php?title=Dustin%27s_Sixth_Tutorial&amp;diff=391&amp;oldid=prev</id>
		<title>Dustin: Created page with &#039;=Introduction= This is an advanced topic, so don&#039;t worry if you can&#039;t follow it.  The Python hook allows you to program things in your Age. It allows you to find out when the use…&#039;</title>
		<link rel="alternate" type="text/html" href="http://myst.dustbird.net/w/index.php?title=Dustin%27s_Sixth_Tutorial&amp;diff=391&amp;oldid=prev"/>
		<updated>2010-10-20T03:32:14Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;=Introduction= This is an advanced topic, so don&amp;#039;t worry if you can&amp;#039;t follow it.  The Python hook allows you to program things in your Age. It allows you to find out when the use…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Introduction=&lt;br /&gt;
This is an advanced topic, so don&amp;#039;t worry if you can&amp;#039;t follow it.&lt;br /&gt;
&lt;br /&gt;
The Python hook allows you to program things in your Age. It allows you to find out when the user presses a button, or clicks the mouse. It allows you to move objects, move your avatar, or Link to another Age. It allows you to open a book or journal. When clickables work, it will allow you to take an action, when the thing is clicked. There are plenty of other things it will allow you to do, as well.&lt;br /&gt;
&lt;br /&gt;
=Getting set up=&lt;br /&gt;
#Install the Python hook, as described in [[AgeScripting]].&lt;br /&gt;
#Install Python v2.2  It must be version 2.2.  you can install it to a different folder than v2.3 or v2.4 .&lt;br /&gt;
#Install something to decompile with.  There are several options, you can go to Cobbs to find one.  I use UruPython v1.2 .  You may want to try PlasmaShop.  If you can get UruPython v3.1 to work for you, that may be the easiest way to go.&lt;br /&gt;
#Decompile all the files to some folder(say src, in the Python folder).&lt;br /&gt;
#Create a text file called &amp;quot;agename.py&amp;quot; where agename is your Age&amp;#039;s filename.(e.g. for Dustin.age, use Dustin.py), and save it in the same folder.&lt;br /&gt;
#Here is a link to a template: [http://www.agebuilder.org/~dustin/uploads/tut.py http://www.agebuilder.org/~dustin/uploads/tut.py]&lt;br /&gt;
#It must have that huge &amp;quot;glue&amp;quot; section at the bottom; and don&amp;#039;t get excited, Cyan didn&amp;#039;t write that code, it is simply appended by the IDE.&lt;br /&gt;
#You must change the &lt;br /&gt;
 class tut(ptResponder,):&lt;br /&gt;
to&lt;br /&gt;
 class agename(ptResponder,):&lt;br /&gt;
and the&lt;br /&gt;
 print &amp;#039;Dustin whatever&amp;#039;&lt;br /&gt;
to&lt;br /&gt;
 print &amp;#039;YourName whatever&amp;#039;&lt;br /&gt;
#Save, and compile the file, using the compile_all.py file that will have been decompiled with the others.&lt;br /&gt;
#Now you should have an &amp;quot;agename.pyc&amp;quot;.  You will need to place it inside of &amp;quot;agename.pak&amp;quot; using the tool.&lt;br /&gt;
#Copy &amp;quot;agename.pak&amp;quot; to the Python folder, and run Uru, and link to the Age, then quit Uru.&lt;br /&gt;
#All &amp;quot;print&amp;quot; commands are output to a log file.&lt;br /&gt;
#You can use the ELF Viewer tool, available at [http://huru.aegura.com http://huru.aegura.com] to view the log files.  In particular, the output from the last time Uru was run can be found in Python.0.elf .  The output from the previous time that Uru ran, can be found in Python.1.elf .  The time before that, in Python.2.elf; and before that in Python.3.elf .&lt;br /&gt;
#Apparently, you can use PtPrintToScreen(&amp;quot;string&amp;quot;) to print directly to the screen, but I haven&amp;#039;t tried it.&lt;br /&gt;
#Your entries should be at or near the bottom.&lt;br /&gt;
&lt;br /&gt;
=Things you can do=&lt;br /&gt;
==Getting notified of keystrokes==&lt;br /&gt;
[[PlasmaInterface#Getting_notified_if_the_user_presses_a_key |You can use this to tell when the user has pressed a key.&lt;br /&gt;
]]&amp;lt;br&amp;gt;&lt;br /&gt;
==Linking to an Age==&lt;br /&gt;
[[PlasmaInterface#Linking_To_An_Age |You can use this to link to an Age.&lt;br /&gt;
]]&amp;lt;br&amp;gt;&lt;br /&gt;
==Moving an Object==&lt;br /&gt;
[[PlasmaInterface#Moving_an_object_with_mass | Moving an object]]&amp;lt;br&amp;gt;&lt;br /&gt;
==Using the timer==&lt;br /&gt;
[[PlasmaInterface#Using_a_Timer| Using a timer]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Neat things that you can do with these.=&lt;br /&gt;
==Cause an object to orbit==&lt;br /&gt;
 from math import *&lt;br /&gt;
 curStep = 0&lt;br /&gt;
 numSteps = 0&lt;br /&gt;
In the OnServerInit section, you can:&lt;br /&gt;
 global curStep&lt;br /&gt;
 global numSteps&lt;br /&gt;
 #set the timer for, say, 1/30 of a second.&lt;br /&gt;
 curStep = 0&lt;br /&gt;
 numSteps = 1000&lt;br /&gt;
In the OnTimer section, you can:&lt;br /&gt;
 global curStep&lt;br /&gt;
 curStep = curStep + 1&lt;br /&gt;
 x = cos(2*pi*curStep/numSteps)&lt;br /&gt;
 y = sin(2*pi*curStep/numSteps)&lt;br /&gt;
 #then move the object to the position (x,y,z), where z is its (constant) z position.&lt;br /&gt;
 #set the timer for, say, 1/30 of a second.&lt;br /&gt;
&lt;br /&gt;
Note that the object may move faster or slower, depending on how hard your computer is working!  If you want its speed to be independent of your computer&amp;#039;s load, use the clock() function in the &amp;quot;time&amp;quot; module.  It returns a float that allows you to measure time in seconds(the fractional part measures partial seconds).&lt;br /&gt;
 from math import *&lt;br /&gt;
 from time import *&lt;br /&gt;
 period = 0.0&lt;br /&gt;
 startTime = 0.0&lt;br /&gt;
 objHeight = 0.0&lt;br /&gt;
 t = None&lt;br /&gt;
In the OnServerInit section, you can:&lt;br /&gt;
 global curStep&lt;br /&gt;
 global numSteps&lt;br /&gt;
 global startTime&lt;br /&gt;
 global t&lt;br /&gt;
 global objHeight&lt;br /&gt;
 startTime = clock()&lt;br /&gt;
 period = 60.0&lt;br /&gt;
 t = PtFindSceneobject(&amp;quot;DustinSphere1&amp;quot;, &amp;quot;Dustin&amp;quot;)&lt;br /&gt;
 t.physics.suppress(true) #turns off physics for the object(so that it doesn&amp;#039;t fall, for example)&lt;br /&gt;
 pos = t.position()&lt;br /&gt;
 objHeight = pos.getX()&lt;br /&gt;
 PtAtTimeCallback(self.key, 0.03, 1)&lt;br /&gt;
In the OnTimer section, you can:&lt;br /&gt;
 curTime = clock()&lt;br /&gt;
 x = cos(2*pi*(curTime-startTime)/period)&lt;br /&gt;
 y = sin(2*pi*(curTime-startTime)/period)&lt;br /&gt;
 #then move the object to the position (x,y,z), where z is its (constant) z position.&lt;br /&gt;
 p = ptPoint3(x, y, objHeight) #names a coordinate point. x=0.0, y=1.0, z=2.3&lt;br /&gt;
 t.physics.warp(p) #Moves the object t to position p.&lt;br /&gt;
 PtAtTimeCallback(self.key, 0.03, 1)&lt;br /&gt;
==More things you can do.==&lt;br /&gt;
More things are available in the API: [[UruAgeManager API]].&amp;lt;br&amp;gt;&lt;br /&gt;
For a tutorial on using them, see [[Dustin&amp;#039;s Seventh Tutorial]].&lt;/div&gt;</summary>
		<author><name>Dustin</name></author>
		
	</entry>
</feed>