How To Create a Networked Vending Machine

Well, I so far haven’t gotten anybody to take me up on my earlier request to help me build the vending machine I described in my earlier posting, so it looks like I am going to have to try and do it myself. If anyone wants to collaborate with me, send me an email.

This posting describes my progress so far. What I’ve created and described below is a demo of a vending machine where the purchase is made at one vending machine and the item is delivered to the purchaser from a different central vending machine server. All the remote server has is a notecard which describes the item in the central server.

There are two scripts used in this demo: RemoteVendor.lsl and VendorServer.lsl. I’ll describe each of them here.

RemoteVendor.TXT This script does the following: 1. Starts up and reads the notecard SaleItem1 nonsense forex. I’ve hard coded this demo for one sales item for simplicity. A real version would obviously have multiple items. 2. Based on the data in the SaleItem1 notecard it puts a short description of the item for sale above the vending machine in red hover text and puts the price just below it. It also sets the pay price for the item. 3. When a purchaser pays the vending machine an email is sent to the central server. The email contains the key of the person who paid and the name of the purchased item.

VendorServer.TXT This script does the following: 1. Starts up and says the key of the vendor server object. (This is required so that you can fill out the notecard for the item you want to sell with the original vendor of the item for sale.) 2. Starts up a timer that regularly checks email. 3. Up receipt of an email, it parses the email, determines who bought what and gives it to them.

To duplicate my results, here are the steps: 1. Create to cubes. Name one of the VendorServer and one RemoteVendor. 2. Create an item that you want to sell. In my case I just created a cone. Name this object SaleItem1. 3. Place the SaleItem1 object in the VendorServer content folder 4. Create a new script in the VendorServer object. Cut and paste the VendorServer.lsl script mentioned above into the newly created script. 5. Create a new notecard named SaleItem1. (I probably should have named it different so no one gets confused versus the SaleItem1 object, but it doesn’t matter that they are the same name.) The card should give a short description of the object for sale on the first line, the price of the sale on the second line, the key of the VendorServer on the third line, and the name of the item for sale on the forth line. The lines must be exactly in this order. The following lines are what I used. Your vendor server key will obviously be different. Place this notecard in RemoteVendor

6. Create a new script in the RemoteVendor object. Cut and paste the RemoteVendor.lsl script mentioned above into the newly created script. (If you do this out of order and create the script before you add in the notecard you might have to reset the script or something, because it will look for the notecard on startup.) 7. Now pay the remote vendor object. You should see the pop up that says you paid yourself and then in a moment you should get the purchased item handed to you.