new lsl scripter - can I do it questions
|
|
Zaplok Riggles
Registered User
Join date: 25 Feb 2008
Posts: 119
|
02-25-2008 09:05
Hi. New scripter here. I've been reading all the guides and experimenting. A few things I just see no way to accomplish. Any help (or even a confirmation that it cannot be done) would be helpful. Thanks!
1. Get a UUID of an avatar not touching or in range of my script. I would like to have my script find the UUID of an avatar based on avatar name. I see no way to do this.
2. I would like to create a machine that can pass out a colored ball. The user selects the color and the machine gives them a ball of their chosen color. I know I can do this by having 5 different colored ball objects in the machines inventory but what I really want to do is when giving the ball to the person, set one of its properites or execute a script within it to do so.
3. Let's say me and a friend co-create a script. We put that script into a machine to dispense colored balls. I know how to get paid but how can I set it up so my friend AND I both get paid (take the total amount paid, send it to one avatar, then have that avatar send half of the received amount to the second avatar).
4. Finally, I would like the above machine to update a list of people it has sold balls to, or to notify another object which keeps the list. I suppose I would need another object to permanenty be in game and to receive emails and add to a list variable. However, is there a way to set this up so that if that object goes away, the list of purchasers is preserved somewhere? Or will the variables contain their existing values if I re-rezz the same object?
5. Also, I would like it if when you approached the machine, it could check the list stored on the other object to see if you had already purchased a ball. Allowing a discount on a second purchase. Sort of like inter process communication or invoke a remote procedure call within another object.
Thanks all!
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
02-25-2008 09:26
From: Zaplok Riggles 1. Get a UUID of an avatar not touching or in range of my script. I would like to have my script find the UUID of an avatar based on avatar name. I see no way to do this. you can almost do this by indirectly querying the new search web interface, and grabbing the uuid from the link. unfortunately you have to do this trough another server, because LL blocks (or more likely doesn't internally look up) local requests to it's own servers. it's also not 100% as some av's just don't show. there are a few name to key database services like w-hat (search the forums) but they also aren't 100% From: someone 2. I would like to create a machine that can pass out a colored ball. The user selects the color and the machine gives them a ball of their chosen color. I know I can do this by having 5 different colored ball objects in the machines inventory but what I really want to do is when giving the ball to the person, set one of its properites or execute a script within it to do so. it could be doable after the fact (let the user set it when they rez it) or by rezzing the object, setting the color, and then letting the person buy it. the second method isn't going to work with a pay split script sadly. From: someone 3. Let's say me and a friend co-create a script. We put that script into a machine to dispense colored balls. I know how to get paid but how can I set it up so my friend AND I both get paid (take the total amount paid, send it to one avatar, then have that avatar send half of the received amount to the second avatar). in the money event when the first Av is paid, trigger llGiveMoney to give a percentage to the other av. the first av will need to be the owner of the vendor, and grant debit permissions. (which need to be requested by the script) From: someone 4. Finally, I would like the above machine to update a list of people it has sold balls to, or to notify another object which keeps the list. I suppose I would need another object to permanenty be in game and to receive emails and add to a list variable. However, is there a way to set this up so that if that object goes away, the list of purchasers is preserved somewhere? Or will the variables contain their existing values if I re-rezz the same object? the only thing that should clear a variable in an lsl script is if you tell it to, or if the script is reset... taking it to inventory and rezzing it won't clear it (unless there's code that makes it clear in that circumstance)... some rare sim crashes/resets may reset the script, but generally don't. what does change if you re-rez is the object uuid, which would also be it's e-mail address... it's better to store this kind of thing off world using http if you can. From: someone 5. Also, I would like it if when you approached the machine, it could check the list stored on the other object to see if you had already purchased a ball. Allowing a discount on a second purchase. Sort of like inter process communication or invoke a remote procedure call within another object. this is doable, although detection time might be an issue. it might be better to store the last few users locally, and wait for a 'rebate' type response when they buy again, then refund a portion of their purchase. to do this with pay split requires a little finesse, in that you'd store half the value of the rebate and on the next purchase to come though, reduce the give money amount by the stored rebate (and don't forget to clear the stored amount)
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
02-25-2008 09:38
1. The short answer is that you can't directly from within LSL, though there are ways around it by, say, finding an object that the person owns. Have a search for "name2key", though, there are external databases to consult e.g. http://w-hat.com/name2key2. If you were rezzing the ball, you could do this by passing a parameter to the ball telling it which colour to become. However, if you are giving it, you can't, because it will go directly into the person's inventory and not run any scripts. I suppose you could tell the new owner to then rez the ball next to your machine, the machine tells the ball what colour to become, then the owner takes it back into inventory all nicely coloured, but that seems like a lot of effort compared to just putting in a few differently named balls. 3. The owner automatically receives all the money whenever an object is paid. What you have to do is have code in a money() event, which uses llGiveMoney to give half the amount to the friend whenever it is triggered. e.g. money(key id, integer amount) { llGiveMoney(KEY_OF_FRIEND, amount / 2); } It will need to have debit permission to do this of course. 4. & 5. Global variables are stored indefinitely unless you reset the script, but there is only a limited amount of space available for each script, and you never know when you might want to reset it. You can have multiple scripts to store the information, or even inworld databases which rez new storage prims when they are running out of space, but in general I would not say that it is not a good idea to try to dynamically store any real quantity of important information within LSL objects. If it's important to know the keys and not to overwrite them occasionally there are various ways to store them externally, the best probably being to use llHTTPRequest to inform an external database with a PHP (or other language) front-end - though you would of course have to have an external database and know PHP (or other language).
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Zaplok Riggles
Registered User
Join date: 25 Feb 2008
Posts: 119
|
02-25-2008 11:17
Thanks for all the good info. If I need to go the multiple object route (different colored balls in inventory), is there a way to create my machine to different scripts based on where on the machine I click? (Im a noob so pardon if this is simple). I am thinking of button type objects in Windows coding with onclick events. Each button could call a different script, giving a different colored ball. Thanks!
Does anyone know of a database type app that would allow me to offworld send/receive a key/value pair from a database? Is there some public domain or hosted app of this type? I am thinking you send an http request with some sort of ID, passing it a key and returning a value (or passing it a key/value pair and having it add the value to your database). If not, something like this might be very useful.
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
02-25-2008 11:34
From: Zaplok Riggles Thanks for all the good info. If I need to go the multiple object route (different colored balls in inventory), is there a way to create my machine to different scripts based on where on the machine I click? (Im a noob so pardon if this is simple). I am thinking of button type objects in Windows coding with onclick events. Each button could call a different script, giving a different colored ball. Thanks! If the machine has multiple prims, you can detect which of them was touched by using the llDetectedLinkNumber function in the touch_start() event. I usually find that the easiest thing is to give the "button" prims individual names, and check those - something along the lines of touch_start(integer n) { key id = llDetectedKey(0); string buttonName = llGetLinkName(llDetectedLinkNumber(0)); if (buttonName == "red"  llGiveInventory(id, "red ball"  ; else if (buttonName == "green"  ... etc etc } though even simpler would be touch_start(integer n) { string ballName = llGetLinkName(llDetectedLinkNumber(0)) + " ball"; if (llGetInventoryType(ballName) == INVENTORY_NONE) llSay(0, "Please press a button to receive a ball"  ; else llGiveInventory(llDetectedKey(0), ballName); } From: Zaplok Riggles Does anyone know of a database type app that would allow me to offworld send/receive a key/value pair from a database? Is there some public domain or hosted app of this type? I am thinking you send an http request with some sort of ID, passing it a key and returning a value (or passing it a key/value pair and having it add the value to your database). If not, something like this might be very useful. Er, I think there is, actually, but I can't remember what it's called for the life of me. It is on my list to build an open source "simple database" system (LSL, PHP and MySQL) to teach people how this works, but, erm, there are quite a few things on my list and I've never really gotten around to it.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
02-25-2008 11:55
From: Zaplok Riggles Does anyone know of a database type app that would allow me to offworld send/receive a key/value pair from a database? Is there some public domain or hosted app of this type? I am thinking you send an http request with some sort of ID, passing it a key and returning a value (or passing it a key/value pair and having it add the value to your database). If not, something like this might be very useful. There's a hosted application at http://w-hat.com/ so you might want to look around there. They have both a name2key database available for use and some storage space they offer to SL residents to use from their own scripts.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
02-25-2008 12:24
From: Zaplok Riggles 5. Also, I would like it if when you approached the machine, it could check the list stored on the other object to see if you had already purchased a ball. Allowing a discount on a second purchase. Sort of like inter process communication or invoke a remote procedure call within another object. The easiest way to do this might be to ask the customer to rez the ball they already have. That way you won't have to store anything on your end. Let the inventory system do it for you. Now if they lose their ball, this won't work. You can tell them to contact you for a rebate in this case (you can get transaction history from the SL website once logged in to see for yourself if they ever purchased from your object; the name of the object purchased or payed appears there), though I don't know how much to expect this scenario given your business. If have the resident rez the already purchased ball, you'll need to verify the authenticity of the object. The best way to do this is probably to use some kind of verifyable and non-repeatable (at least not easily) hash value. Something like taking a private passphrase, the key of the object being authenticated, the key of the owner, and some other verifyable data like the date, the name of the region, etc., concatenating them together in some fashion, and computing an MD5 hash from it ( http://www.lslwiki.net/lslwiki/wakka.php?wakka=llMD5String). The vedor/server has to be able to obtain or verify all that data without "taking the object's word for it," and then recompute the hash and compare this to the object's.
|