Cannon

**Cannon** This set of scripts can be used to make a cannon. It will fire cannon balls that leave behind "tracers". Both the cannonball and the tracers record their position (x,y,z) and time (in seconds). This data can be copied to a spreadsheet for further manipulation.

To use the scripts…you’ll need to build yourself a cannon. As you can see from the photo of the cannon I made, it is made up of 5 prims. The cannon turret is a simple hollow cylinder. The ball on the end is purely cosmetic, but at least it lets you know which end the cannonball will come from. All 5 prims are linked together with the cannon turret cylinder as the root prim. You can copy/paste them into scripts in your SL/OpenSim space.
 * tracer.lsl – is the script for the tracers that the cannonball leaves behind as it flys. Make a sphere and name it “tracer” and put this script inside. The prim should NOT be a physical prim or it will fall out of the sky. You want these to stay up so you can see the parabolic shape of the flight of the cannonball.
 * CannonBall.lsl – is the CannonBall script. Make a cannonball (sphere) and add this script inside of it. Also add a copy of the “tracer” scripted prim inside. Make the prim physical and name it “CannonBall”. I found that I needed to lift it off the ground in Edit mode, and then reset the script (Tools->Reset Scripts in Selection) then take it into my inventory without exiting Edit mode.
 * Cannon.lsl – is the cannon script. It should be in the root prim (the cannon’s turret). Also place a copy of the CannonBall scripted prim inside of the root prim.
 * Get Trajectory.lsl, Get Velocity.lsl activate the llListen event in the Cannon script. Place each of these inside linked prims that you’ll touch to open the listen so that you can chat to the cannon what you want the trajectory or initial velocity to be.
 * Fire.lsl – is the script that activates the firing sequence. Place it inside another linked prim.

** Usage **: Touching the cannon should get you feedback on the chat channel that tells you the current initial velocity setting, trajectory setting, and position of the root prim. The position of the root prim is also the initial position of the cannonball when it is fired. Touching the trajectory or velocity prim opens listen events. For trajectory, you have to chat over channel 5 (ie /5 0,30,0). You need to give the script the x, y, and z rotation figures. These are the same x, y, and z rotation measurements that you’d see in the edit panel when editing a prim. I’ve found that since these are global values relative to the grid, that if you are aiming the cannon in a direction other then along the x or y axis of the grid, that these values are not as intuitive as you might think…takes a little 3D geometry to figure out what the values ought to be…so I tend to stick to firing along the x or y axis.

After firing, touching the cannonball will do two things. It will chat its description field data which is the x, y, z and time values for when it collided with another prim or the ground. Since the name of the cannonball is the x, y, z, and time values of the cannonball when it was rezzed (ie should be the same or really close to the position of the cannon), you’ll get both the start and end data in this chat…because the name of the object chatting is always listed anyway. This will also alter the prim from being a physical prim to a non-physical prim. I found that I had cannonballs rolling all over the place, and this helped keep them from rolling off and getting lost.

Touching the tracer prims will also get them to chat their position and time. In addition, for the next 10 seconds, if you chat “reset” over channel 99, the tracer will delete itself (ie /99 reset). I think that’s it…so now, the more interesting part, how would you use this pedagogically with students? I’m not a physics teacher, so I’m not sure how I would approach this with students, but if you have thoughts, please share them!

**Data** Here is a spreadsheet that allows you to copy and paste the chat history of the tracer and cannonball data into it. It will parse the data and give you different columns for x, y, z, and time. If you are curious about the time numbers, if I understood it right, it is the number of seconds since Midnight. So from that, you can get relative time between data points.

> Microsoft Excel format > Apple's Numbers (iWork format
 * [[file:DataExtractor.xls]]
 * [[file:DataExtractor.numbers]]