WORLD OF PHYSICS - Open Learning Resources


SCRIPTS

The scripts are txt files with LSL code, archived together in .rar files. For each one we provide a description with instructions and explanations on how they work. For more details about the LSL language visit the LSL Portal

PREVIEW DESCRIPTION LINK
Presetnation Board

Scripts to create a board that displays slides of a presentation. You need a linked set. Put the script inside the Root, along with the slides of the presentation. Use the scripts for the buttons in child roots and you will be able to use them to change language and navigate the slides.

For the slide images use a two letter prefix for the language and make sure that the names of the slides are in alphabetical order.

The script of the root object (screen), listens for messages (link_message event) from the child objects (buttons) and then loads the suitable slide in the designated plane with 'llSetTexture'.

The scripts for the buttons just use a 'touch_start' event and use 'llMessageLinked' to send messages to the root.

Quiz Activity

Script to implement a quiz activity. You need a linked set. Put the quiz script in the ROOT prim and the button scripts on the child prims.

The quiz script uses 'llDialog' to show dialogue messags to the user and prompt them to select the correct message. It waits for messages (listen event) when the user selects an answer and validates if the answer was correct to decide what the feedback and the next question should be. It also waits for messages from the buttons (link_message event).

The quiz script also keeps track how much time it took for the student to answer all qustions and how many mistakes they made and stores the data in list variables. It also generates a text response in html format that it projects as a page in one of the planes of the root object, using 'llSetPrimMediaParams' to change the 'PRIM_MEDIA_CURRENT_URL'. parameter

The scripts for the buttons just use a 'touch_start' event and use 'llMessageLinked' to send messages to the root.

NPC Character

You need a linked set. Use the main NPC control script in the ROOT prim and the button scripts in the child prims to be able to change the language.

Also put in the ROOT prim the necessary files (sounds , appearance, animations etc).

The NPC control script generates the NPC when it loads (state_entry event) using osNpcCreate. It waits for avatars to approach it (sensor event) and engages them using 'llDialog' to prompt them for replies. The script also keeps lists with characters that engage it to know when to ask them again. A 'timer' event clears a list when enough time has passed to engage an avatar again. The script can also control the NPC character by applying animations with 'osNpcPlayAnimation' or miving them with 'osNpcMoveToTarget' and can also play sounds with 'llPlaySound' or give items to the user with 'llGiveInventory'.

The scripts for the buttons just use a 'touch_start' event and use 'llMessageLinked' to send messages to the root.

Picture Frame

Use this script on button prims to open a browser with a specific webpage.

It uses 'llLoadURL' to load the webpage url, when the user touches/clicks the object (touch_start event).

You can have multiple flag buttons, one for each supported language. Put the script in each button and change the url and the message displayed.

Sorting Activity

You can use the scripts to implement a sorting activity. The user will see multiple cards on the board and will need to click them with the correct order. If the correct object is clicked according to the order, it moves to the next row where the correct order is presented step by step. There are three led prims that lighten up when the user makes mistakes and a reset button to restart the activity.

You need a linked set of items. When you link the various parts into a single linked object, the order you selected them will determine their Link Number.

The script in the ROOT object controls the activity. There are three lists in the begining of the script where you can use the Link Numbers of the child prims to specify which are the cards, what is their correct order, and which are the led prims. The script uses a 'link_message' event that is triggered by the child card prims when they are clicked. It uses 'llSetLinkPrimitiveParamsFast' to change the position of the cards.

The script you put in each of the child card prims, uses 'llMessageLinked' to send a message to the ROOT object when it is clicked. The message contains the object's link number (llGetLinkNumber).

The script in the led prims, changes their color with 'llSetColor' when they receive a message from the ROOT prim. The reset button script just sends a message to the ROOT prim with 'llMessageLinked'.

Info Box

The script gives a Notecard file (must be in the same object as the script) to the avatar that clicked the object. It uses 'llGiveInventory' to give the object after a 'touch_start' event.

Friction Activity

The scripts can implement an activity that allows you to select two objects and rub them against each other to observe the charge that is exchanged. There are different objects on the counter. There are two selection boxes. You click one of the section boxes and then you click one of the objects in order for it to appear in the selection boxes. When both boxes have an object, you click a button to make them rub. There are label prims above the selection boxes that display the charge of each object using '+' and '-' strings.

For the static objects on the counter, each one has a script that sends messages with their unique id using 'llSay' to specific channels to inform other objects like the selection boxes that the object was clicked.

The two selection Boxes, have scripts that allow them to check if one of the above objects was clicked and they can use 'llRezObject', to rez the object on top of the selection box. Make sure that you put the objects in the inventory of the selection objects so they can rez them. Before you do this however, you need to put suitable scripts in each one, that will allow the rezzed objects to wait for messages from the CONTROL object, so they animate to simulate that the objects rub against each other, or to dissapear (llDie command) when the user selects another object on the counter. The animation takes place with succesive 'llSetPos' commands to change the position along with 'llSleep' commands to delay between each move.

The label objects above the selection boxes wait for messages (listen event) and then change the displayed text with 'llSetText'.

The main control script, among others has tables with the information about the charge that exchanges between each possible pair of objects. You can see that many different objects that are part of this activity are independent prims (not linked), but they exchange information between them using specific channels and messages and as a result they coordinate to achieve the required logic.

Friction Activity - Sorting

The scripts can implement an activity, where you can place objects in the different select boxes and then validate that their order is correrct (based on their affinity for electrons).

The position objects have scripts that allow them to rezz objects on top of them (llRezObject command) but you need to put the objects in their inventory before. The rezzed objects have scripts that allow them to dissappear (llDie command) when they get some message (listen event).

The static objects on the counter send messages with their id in specific channels when they are clicked.

The validation button script, is informed about the content of the selection boxes, by listening (listen event) on specific channels, so when it is clicked (touch_start event), it just checks if their order is the correct one. You can see that many different objects that are part of this activity are independent prims (not linked), but they exchange information between them using specific channels and messages and as a result they coordinate to achieve the required logic.

Atom

The scripts can implement a representation of the model of the atom, with electrons revolving around the nucleus and the users can teleport in an isolated room with a larger version, appearing as if they have transfered inside the atom.

The nucles script just uses 'llTargetOmega' to rotate. The electrons of each orbit must be child prims on a root cylinder. Use the script in the cylinder to make it rotate with 'llTargetOmega', but there is also a 'listen' event that allows it to wait for control messages in order to stop or resume the rotation as instructed.

The teleportation button, uses 'llTeleportAgent' to teleport the user to the designated position, however make sure that you use 'llRequestPermissions' first and the 'run_time_permissions' event so the user can get a prompt and accept the teleportation.

Conduction Activity

These scripts can implement an activity where you select one of different objects with specific charge and then rub them on target object in order to achieve specific charge for it.

The static objects on the counter can be clicked (touch_start event) and they use 'llRezObject' to rezz an object (must be in their invenory) on the table below. This rezzed object must have a script that waits for messages (listen event) so it can dissapear when the user selects another one. It also has a 'touch_start' event that waits for the user to click it, so it moves next to the target object and the exchange of charge takes place (it transitions to another state at this point, so it adopts another behaviour).

The target disc on the table, uses script with 'listen' event to get informed about which object is on top of the table and when the user touches it so it emulates the exchange of charge that is necessary. It also uses a 'touch_start' event to discharge it by setting the charge to 0.

Magnets

The scripts implement an experiment with a magnet and a surface with iron fillings under a glass. When you click the magnet it moves over the iron fillings surface and the magnetic field affects the iron fillings causing a specific pattern.

The magnet uses 'llSetPos' to change between the two different positions when it is clicked (touch_start event) but it also sends a message with llSay to specific channel, in order to inform the iron fillings surface.

The iron fillings surface, waits for messages (listen event) from the magnet and then uses 'llSetTexture' to change the texture between two images (the images must be insife the surface object along with the script).

The help button just gives instructions when clicked using a 'llDialog' command to display a dialogue box.

Lorrentz Activity

These scripts implement the Lorrentz experiment. The user can close the circuit with a switch, rotate the battery and also move and rotate the horseshoe magnet. A wire that hangs, rotates to specific positions, accordings to the magnetic field of the magnet, when the circuit is closed.

There are many different and independent objects in this activity. They all use messages in specific channels to inform one another about the change of the state of each part (battery orientation, mangnet position, magnet orientation, switch position).

The switch object uses script to rotate with 'llSetRot' when clicked (touch_start event) or when it receives a message (listen event) to do so.

The battery uses successive lSetRot, llSetPos and llSleep commands to emulate the move for being picked up and rotated by the user.

The horseshoe magnet uses scripts to wait for messages from the three buttons above it in order to do the corresponding actions: move forwards (lSetPos), move backwards (lSetPos) and rotate (lSetPos and llSetRot).

The wire object uses scripts to wait for messages in different channels to inform about the status of each part of the circuit and the magnet. It then checks weather it needs to rotate and uses 'llSetRot' accordingly.

There is also an object that uses script to generate particles with 'llParticleSystem' when the circuit is closed to show the direction of the current. Another object that represents the magnetic field around the wire, uses 'llSetLinkAlpha' to appear and disappear when the circuit is closed and open respectively. It also uses llTargetOmega to rotate.

Compass Activity

These scripts implement an experiment with a compass that is affected by the magnetic field generated when a circuit is closed.

The switch object uses script to rotate with 'llSetRot' when clicked (touch_start event) or when it receives a message (listen event) to do so.

The lamp object uses 'llSetPrimitiveParams' to modify the 'PRIM_GLOW' parameter and appear like it is glowing when the circuit is closed.

The compass needle uses 'llSetRot' to rotate between two positions the circuit is closed or open.

There are two objects that generate particles (one for each direction) to show the flow of the current and the opposite flow of the electrons. There are objects that show the magnetic fields around the wire and around a singe electron that appear on demand.

There are four buttons that can be clicked to affect the information that is displayd. They send one of the following messages to a channel informing the affected objects:
- "hide_fields" will hide all fields
- "show_fields" will show the fields
- "show_electrons" will show the electrons direction instead of the electric current direction
- "focus_electron" will focus on a single electron and the fields that it generates around it

Water Molecule

The scripts can implement an activity, where the user is teleported between isolated rooms that zoom in to the water molecules and the atoms of oxygen and hydrogen.

Teleportation takes place with 'llTeleportAgent' commands.

The water molecule animates by slightly changing the position with 'llSetPos' every 3 seconds.

Photoelectric Effect

The scripts implement an activity that allows the user to receive and equip a photon gun and use it to shoot photons of different frequencies to the electrons of an atom, potentialy causing them to change state. When an electron changes state it moves to a higher orbit, where it stays for a couple of seconds and then returnsm while emmiting a photon.

A crate object is used to give (llGiveInventory) the photon gun to users that click it (touch_start event).

The Photon gun, when clicked (touch_start event) changes the color of the photons and also its color with 'llSetColor'. Using a 'control' event the script can check when the left mouse button is clicked and then rezzes a photon with specific velocity using 'llRezAtRoot', also passing a parameter with the currently selected color/frequency of the gun. The rezzed photon uses a script to change its color with 'llSetColor' when it is created (on_rez) and also uses a 'collision_start' event to check if it hits something in order to dissapear with 'llDie'.

The electron targets use script to wait for messages (listen event) and be informed when the user changes the color of their photon gun. It uses a 'collision_start' event to check if a photon collided with it and then if the currently selected color is the correct one it may get excited and transition to another state. At the excited state, the electron will initaily change position with 'llSetLinkPrimitiveParamsFast' which modifies the 'PRIM_POSITION' parameter and then waits for 4 seconds with 'llSetTimerEvent'. This command triggers a 'timer' event that causes the electron to rezz a photon of its own (must be inside the inventory along with the script) and then moves back to the original position (it transitions to the default state).

Electron

The scripts implement an activity that allows the user to receive and equip a photon gun and use it to shoot photons of different frequencies to the electrons of an atom, potentialy causing them to leave the atom.

This activity works similarly with the above one, with slight adjustments to change the behaviour accordingly.

Geiger

These scripts implement an activity where the user receives a Geiger Device HUD element that can equip on his screen and use to locate different radioactive material and learn about them.

A crate object is used to give (llGiveInventory) the Geiger HUD to users that click it (touch_start event).

The Geiger HUD is a linked set. The root object has a 'timer' event that will check periodically how close its current position is to the positions where the radioactive material has been placed. According to the proximity it sends a message 'llMessageLinked' to the child prims 'LINK_ALL_CHILDREN' that causes specific number of led prims to turn on. It also uses 'llLoopSound' to play different sounds according to the proximity.

The collectible radioactive objects, when located and clicked send a message to the HUD (they send the ID of the user that touched them, so the HUD can compare with the ID of their owener) and the HUD displays that the object is found, sending a message 'llMessageLinked' to child prim led that can be clicked (touch_start event) to display information to the user with 'llDialog'.

Newton First

The scripts can implement a experiment for the 1st law of motion. There is a cup and a card placed on top of it. A coin is on top of the card. When a force applies to the card, it is flicked away but the coin drops inside the cup.

The scripts take advantage of the Physics engine of Opensim. When the card object is clicked (touch_start) the command 'llApplyImpulse' is used to apply specific force to it.

You have to set both the coin and the card as PHYSICAL objects.

The two objects will return to their original positions with llSetPos after some seconds so the experiment can be repeated.

Newton Third

The scripts can implement a experiment for the 3rd law of motion. The objects of different mass on top of the table are held together by a rubber band. When the rubber band is cut, they move with oppisite forces but the heavier one will cover a shorter distance.

The scripts take advantage of the Physics engine of Opensim. When the button is clicked for the experiment to start 'llApplyImpulse' is used on both items to apply specific force to them. The script also changes the status of the objects to 'STATUS_PHYSICS' with 'llSetStatus' before applying the force.

The two objects will return to their original positions with llSetPos after some seconds so the experiment can be repeated.

Gravity

The scripts implement an activity where the user can add multiple objects on the right side of a scale until the scale is balanced. Then the user can add the mass of the weights to find what was the mass of the crate on the left side of the scale, and calculate the Weight which must be given as an answer to complete the activity succesfully.

The scale is a linked set of prims. The ROOT Prim must be a cylinder around which the scale will rotate. The weights on the right side of the scale are always there as child prims, but they appear and dissapear on demand (llSetAlpha command). The ROOT object uses scripts to communicate with the child prims so it can control when they appear or not.

The remove and add weight buttons use 'llDialog' to ask the user what weight they want to remove or add respectively.

There are two led objects that turn on by setting the PRIM_GLOW and PRIM_COLOR parameters with 'llSetPrimitiveParams' when the ROOT object sends a message.

The ROOT prim uses script to rotate the scale with 'llSetRot' based on the number and types of weights added by the user.



THE EUROPEAN COMMISSION SUPPORT FOR THE PRODUCTION OF THIS PUBLICATION DOES NOT CONSTITUTE AN ENDORSEMENT OF THE CONTENTS WHICH REFLECTS THE VIEWS ONLY OF THE AUTHORS, AND THE NATIONAL AGENCY AND COMMISSION CANNOT BE HELD RESPONSI¬BLE FOR ANY USE WHICH MAY BE MADE OF THE INFORMATION CONTAINED THEREIN