Wednesday, January 28, 2009

Making Scripts Work With One Another






Written 21 January, 2009

Making Scripts Work With One Another

Despite the title of this post, it’s not a tutorial, but rather a description of some things I’ve been able to do with scripts at the robot sanitorium. Each of the scripts is relatively simple, but working together, they perform the task I set.

The top of Rosie the Robot’s giant head opens and closes on command. The movement is triggered by a lever on a panel in the sanitorium’s control room.

Touching the lever sends a linked message to another prim in the same prim set; the prim (a light) turns full bright, glows a bit, and makes red light. The lever then shouts a message on a private channel and the top of Rosie’s head, which has been listening, hears the yell and rotates slowly open. When the canopy has opened, the red light turns off. A second press of the button closes the canopy.

To make things interesting, I built a defect into the canopy opening mechanism. I made a strip of tape and laid across the control module, warning of a problem with the canopy controller. I placed a letter atop the controller in which Robot Salesmen Ltd. disavows any problems with its canopy controller mechanism:

Insofar as the problems you claim you are having, we have never had a canopy malfunction. Our openers are lab tested by the latest Model R2D320 robots and undergo thousands of operation cycles under simulated field conditions. Never has a canopy “spun off world” as you claim. We are not even sure this is possible.
The malfunction is building into the script via a random function. When the lever is touched, the script generates an integer between 1 and 8. If the integer is 1-7, the canopy opens normally. If the integer is 8, however, the canopy begins to spin crazily and finally disappears. The controller shouts “The canopy has gone off world!” A few second later the controller shouts “Canopy recovered and sent to Lost and Found” and the canopy reappears in its closed position.

The canopy doesn’t actually go off world, of course; the script merely turns it invisible, and visible after a few seconds.

Similar scripts turn a conveyor belt off and on (the belts move, the wheels turn), operate an electromagnet which travels 50 meters along a rail and drops robot parts into a bin, trigger an escape alert which turns on spotlights and closes down the open areas, and operate the fountain show on the main floor.

-----

An anthropomorphized (robopomorphized?) hydraulic press on the bottom floor of the sanitorium turns cubes of metal into finished robots. It uses listens to communicate between objects and link messages to communicate with linked sets. The conversion is started when an avatar sits on a poseball. The av sits on the edge of the bottom plate of the press and then moves to a lying position between the plates. The top plate begins to lower noisily and clanks to a stop on the bottom plate. There’s a hiss and the plates begin to glow. The top plate then rises, revealing a skeleton where the avatar had lately been. Then the top plate lowers again. When it rises a red-hot robot is lying there.

The process is complex, but has been fairly easy to script. The poseball, the top plate of the press, and the main body of the press (which contains signs monitoring the progress of the conversion) talk to one another via chat and to the prims in the various linksets via linked messages. A phantom sculpty skeleton hears a command, becomes visible, and, hearing another command, turns invisible again.

Meanwhile, the poseball has given a folder called “RS Robot” to the avatar and unseated the av in a changing room. A notecard pops open, instructing the avatar to find the folder in inventory, wear all the parts, and sit on another poseball. The second poseball (under construction) will then rise and send a message to the press, telling it to open. When the press rises, a red-hot glowing robot will be lying where until recently there was an avatar. The poseball will then move forward and unsit the avatar, and the conversion will be complete.

No comments: