Cylindrian's Tip/Info/Vending Sign (Part 2)
This is part two in a series of howto entries.
Investigating The Money() Event
Each object is composed of one or more prims. Each prim of an object can have its own scripts stored and running in its contents. Each scripts run independently of the others. One thing I was curious about verifying was how Money events would work in the object that we've been tasked with building. We want to have a tip jar that takes donations via a scripted money() event, but we will also have linked child prims that are, themselves, vendor objects (in our case secondTUNES objects).
In this section we will do a bit of research. We'll observe the behavior of scripts with money events and how they interact, if at all, when in multiple linked prims.
First let's just create a nice new prim to work with.

Once it's available we'll give it a smart name like "Root Prim". In the new edit window that opened when you created the prim change the Name: field (in the general tab) to give that prim a name. This will allow out prim to identify itself when it sends messages to text chat.

Now let's remove the default wood texture and add some color. This way we'll eventually be able to visually tell our prims apart.

Stupid Simple Tip Script
Let's add a quick test script to the root prim and observe how a single prim tip jar might behave. Click on the Content tab in the edit window, click the New Script button, then rename the script to something useful like "TipTest" or whatever.

Open the TipTest file and replace the default script with the following one. Then pay the prim 1L$ and observe the object's behavior.
default
{
state_entry()
{
llOwnerSay("Loaded and ready to go!");
}
money( key id, integer payment )
{
llInstantMessage(id, "Thank you for paying me " + (string)payment + "L!");
}
}
When the script compiles and becomes available your chat window will have something like:
Root Prim: Loaded and ready to go!
When you pay the object some amount (you're really paying yourself since you own the object) you'll see something like the following in your chat window:
Root Prim: Thank you for paying me 1L!
Great job! We've just made a basic tip jar together. Now what we want to do is find out how the root prim tip jar behaves when a child prim also has a money event.
Child Prim With Money Event
To do so we'll first make a copy of the root prim - hold the shift key and drag one of the arrows on the prim to drag a copy out. Then rename the new prim, I chose "Child Prim".

Modify the Child Prim color as well. I chose to use red.

OK, now we need to actually link them together. To do so first ensure that the edit window is open. Now click one prim to select it. Next hold the shift key down and click the other prim to add it to your selection.

After you have all your objects selected you'll choose "Link" from the Tools menu (or hit the cmd-L shortcut). Remember that the LAST prim or object that you add to your selection will become the root prim for a newly linked object.
When your prims have been linked together the edit window will default to showing settings for the root prim. For instance the general window will reflect the name of the root prim itself and the contents tab will show the inventory of the root prim only. Once prims are linked together you would need to check the box to "Edit linked parts" and click a specific prim in order to edit that single prim's contents, texture or general settings such as name.

With the whole linked object selected click on "Reset scripts in selection". You should see a window popup with text similar to this:
"Starting reset of 2 items
Resetting "TipTest"
Resetting "TipTest"
Done."
That just restarted the scripts in the contents of each prim of our object. You should see your chat window fill up with text similar to this:
" Root Prim: Loaded and ready to go!
Child Prim: Loaded and ready to go!"
This chat demonstrates that we have the root prim AND the child prim talking to us separately. That's right, as stated above, the name of the prim where the script is located is the name shown in chat when that script sends a message, not the name of the root prim.
Go ahead and pay the root prim again - what happens?
My chat window says something like:
Root Prim: Thank you for paying me 1L!
Same as before, no change is observed in the behavior of the root prim. Good. Now pay the child prim. What happens?
Child Prim: Thank you for paying me 1L!
This is what I would expect from the event system in LSL. We have a child prim with a script that handles the money() event, and a root prim that handles the same event. When the root prim is paid the child prim is not alerted and does not react. When the child prim is paid it handles the event on its own and does not pass it along for the root prim to react - the root prim is oblivious to the fact that money just exchanged hands.
Child Prim With -NO- Money Event
Let's continue this experiment by creating a second child prim. For this one you can simply rez a new block of wood, name the block something like "Child2", shift click the main object and then link them all together.
What do you think will happen when you pay the block of wood - the Child2 prim - once everything is linked together?
Hopefully you guessed that your chat window will display something like:
Root Prim: Thank you for paying me 1L!
Why? Because the new Child2 prim has no script inside it at all. It has no way to intercept the money() event - so it passes it along to the root prim. The root prim does have a means of handling the money() event so it handles the task admirably.
Lessons Learned
All of this research is/was to conceptualize whether or not adding a vendor into our linked objects would cause a conflict. If the vendor is handling money() events what happens to the tip jar script, etc? I figured that I had the concept down and that I should be able to put a tip jar script in the root prim which would accept tips from any child prims that didn't handle a money() event, while a linked vendor object would handle its own money() events and vend normally. That seems to make sense, right?
If you're creating your own object this should in fact hold true. All of my early work on Cylindrian's sign made this assumption and moved along in that direction.
In the next installment we will complicate things a tiny bit. What happens when you have an object that allows you to modify it - to the extent that you can link it into another object - but the scripts it contains cannot be modified? In our case it will be Bobby Fairweather's secondTUNES vendor but you can think "any unknown code in an object you do not have complete control over" instead.