CasperLet/API: Difference between revisions
m (→Script Samples) |
|||
Line 264: | Line 264: | ||
} | } | ||
} | } | ||
= '''<span style="color:#00528c">Finding Rental Unit Keys/UUID</span>''' = | |||
In Firestorm viewer, right-click > edit > "Copy Keys" | |||
= '''<span style="color:#00528c">FAQ / Troubleshooting</span>''' = | = '''<span style="color:#00528c">FAQ / Troubleshooting</span>''' = |
Revision as of 22:10, 21 April 2016
API Documentation
API Works Only For System Owner
Please note: The API commands will only work from scripted objects owned by the same avatar that owns the copy of CasperLet they are being used on.
As most of you already know, it would be a security risk to allow the API commands to be used by anyone who's not the system owner.
V1 API
Here's the V1 API. This is supported by all CasperLET versions.
Our linked message is as follows:
<lsl>llMessageLinked(LINK_SET, (integer)timeLeft, "RTIME", rentedBy);</lsl>
rentedBy is the key of the current renter, timeLeft is the amount of time left in seconds.
If rentedBy == NULL_KEY then it means there is no renter, and the unit is available.
You can detect rental events by storing the last message. If the last message was NULL_KEY, and then the next one isn't, it means that someone rented the unit, and vice versa.
V2 API
The V2 API adds several new messages to provide extended information.
The first is REXTR:
REXTR|<time left>|<renter key or NULL_KEY if not rented>|<locked? 0 or 1>|<reserved key or NULL_KEY if not reserved>|<price per week>|<number of prims>|<is tenant over limit? 0 or 1>|<Unix timestamp on which the unit was rezzed>
We also provide some additional messages which provide useful information (both linked messages and broadcast on channel 77777.)
The "string" value of the linked message will identify the message type, as described below.
ADDTNTS@userkey1#username1#userkey2#username2#userkey3#username3#userke.. (etc)
MANAGERS@managerkey1#managerkey2#managerkey3#managerkey4.. (etc)
Note the use of different delimiters on these messages, this is due to technical limitations.
All of the above information is also broadcasted on channel 77777. The following messages are only provided in linked messages:
String: BUTTONS Key: pricebox|paybutton1|paybutton2|paybutton3|paybutton4
(to correspond with llSetPayPrice)
String: TEXT Key: the floating text that is shown on the unit
As before, THERE IS NO GUARANTEE WHEN THE INFORMATION WILL BE SENT - So check for changes, rather than just reacting to the message.
In addition to this, the unit also accepts certain linked messages, as well as chat messages on channel -77777.
You can use these as follows:
UPDATE
<lsl> llMessageLinked( LINK_THIS, 0, "CLAPI-UPDATE", NULL_KEY ); </lsl>
.. or ..
<lsl> llRegionSayTo( KEY_OF_UNIT, -77777, "CLAPI"+KEY_OF_UNIT+"-UPDATE|UPDATE|0" ); // where KEY_OF_UNIT is the uuid of the rental box/meter </lsl> This triggers the unit to spit out the linked messages and data on channel 77777. The integer can be any number.
PAY
This command is handled by the CasperTech servers. Do not make unreasonably frequent or repeated requests. |
<lsl> llMessageLinked( LINK_THIS, AMOUNT_PAID, "CLAPI-PAY", PAYER_KEY ); </lsl>
.. or ..
<lsl> llRegionSayTo( KEY_OF_UNIT, -77777, "CLAPI"+KEY_OF_UNIT+"-PAY|"+(string)PAYER_KEY+"|"+(string)AMOUNT_PAID); // where KEY_OF_UNIT is the uuid of the rental box/meter </lsl> This provides a way to simulate payment to the unit.
BE WARNED: This WILL SIMULATE PAYMENT. Which means, if the payment is rejected, money will be REFUNDED.
SAFEPAY
This command is handled by the CasperTech servers. Do not make unreasonably frequent or repeated requests. |
<lsl> llMessageLinked( LINK_THIS, AMOUNT_PAID, "CLAPI-SAFEPAY", PAYER_KEY ); </lsl>
.. or ..
<lsl> llRegionSayTo( KEY_OF_UNIT, -77777, "CLAPI"+KEY_OF_UNIT+"-SAFEPAY|"+(string)PAYER_KEY+"|"+(string)AMOUNT_PAID); // where KEY_OF_UNIT is the uuid of the rental box/meter </lsl> This provides a way to simulate payment to the unit, but WITHOUT any refunds, profit shares, or messages to the user.
TOUCH
This command is handled by the CasperTech servers. Do not make unreasonably frequent or repeated requests. |
<lsl> llMessageLinked( LINK_THIS, 0, "CLAPI-TOUCH", TOUCHER_KEY ); </lsl>
.. or ..
<lsl> llRegionSayTo( KEY_OF_UNIT, -77777, "CLAPI"+KEY_OF_UNIT+"-TOUCH|"+TOUCHER_KEY+"|0" ); // where KEY_OF_UNIT is the uuid of the rental box/meter </lsl> This triggers the unit to give the user indicated by TOUCHER_KEY the standard dialog menu.
INFO
This command is handled by the CasperTech servers. Do not make unreasonably frequent or repeated requests. |
If you're using this command to retrieve information from the rental unit, you're doing it wrong - use "UPDATE" instead, or contact us for help. |
<lsl> llMessageLinked( LINK_THIS, 0, "CLAPI-Info", USER_KEY); </lsl>
.. or ..
<lsl> llRegionSayTo( KEY_OF_UNIT, -77777, "CLAPI"+KEY_OF_UNIT+"-Info|"+USER_KEY+"|0" ); // where KEY_OF_UNIT is the uuid of the rental box/meter </lsl>
Please pay attention to the case of the command above.
This command is synonymous to the user indicated by USER_KEY pressing the Info button, except it won't deliver the notecard.
TIMELEFT
This command is handled by the CasperTech servers. Do not make unreasonably frequent or repeated requests. |
<lsl> llMessageLinked( LINK_THIS, 0, "CLAPI-TimeLeft", USER_KEY); </lsl>
.. or ..
<lsl> llRegionSayTo( KEY_OF_UNIT, -77777, "CLAPI"+KEY_OF_UNIT+"-TimeLeft|"+USER_KEY+"|0" ); // where KEY_OF_UNIT is the uuid of the rental box/meter </lsl> Please pay attention to the case of the command above.
This command is synonymous to the user indicated by USER_KEY pressing the TimeLeft button
EVICT
This command is handled by the CasperTech servers. Do not make unreasonably frequent or repeated requests. |
<lsl> llMessageLinked( LINK_THIS, 0, "CLAPI-Evict", USER_KEY); </lsl>
.. or ..
<lsl> llRegionSayTo( KEY_OF_UNIT, -77777, "CLAPI"+KEY_OF_UNIT+"-Evict|"+USER_KEY+"|0" ); // where KEY_OF_UNIT is the uuid of the rental box/meter </lsl> Please pay attention to the case of the command above.
This command is synonymous to the user indicated by USER_KEY pressing the Evict button
REFUND
This command is handled by the CasperTech servers. Do not make unreasonably frequent or repeated requests. |
<lsl> llMessageLinked( LINK_THIS, 0, "CLAPI-Refund", USER_KEY); </lsl>
.. or ..
<lsl> llRegionSayTo( KEY_OF_UNIT, -77777, "CLAPI"+KEY_OF_UNIT+"-Refund|"+USER_KEY+"|0" ); // where KEY_OF_UNIT is the uuid of the rental box/meter </lsl> Please pay attention to the case of the command above.
This command is synonymous to the user indicated by USER_KEY pressing the Refund button
PRIM COUNT
This command is handled by the CasperTech servers. Do not make unreasonably frequent or repeated requests. |
<lsl> llMessageLinked( LINK_THIS, 0, "CLAPI-Prim Count", USER_KEY); </lsl>
.. or ..
<lsl> llRegionSayTo( KEY_OF_UNIT, -77777, "CLAPI"+KEY_OF_UNIT+"-Prim Count|"+USER_KEY+"|"+ id +"|0" ); // where KEY_OF_UNIT is the uuid of the rental box/meter </lsl> Please pay attention to the case of the command above.
This command is synonymous to the user indicated by USER_KEY pressing the Prim Count button
WON'T RENEW
This command is handled by the CasperTech servers. Do not make unreasonably frequent or repeated requests. |
<lsl> llMessageLinked( LINK_THIS, 0, "CLAPI-Won't Renew", USER_KEY); </lsl>
.. or ..
<lsl> llRegionSayTo( KEY_OF_UNIT, -77777, "CLAPI"+KEY_OF_UNIT+"-Won't Renew|"+USER_KEY+"|0" ); // where KEY_OF_UNIT is the uuid of the rental box/meter </lsl> Please pay attention to the case of the command above.
This command is synonymous to the user indicated by USER_KEY pressing the Won't Renew button
REMINDERS
This command is handled by the CasperTech servers. Do not make unreasonably frequent or repeated requests. |
<lsl> llMessageLinked( LINK_THIS, 0, "CLAPI-Reminders", USER_KEY); </lsl>
.. or ..
<lsl> llRegionSayTo( KEY_OF_UNIT, -77777, "CLAPI"+KEY_OF_UNIT+"-Reminders|"+USER_KEY+"|0" ); // where KEY_OF_UNIT is the uuid of the rental box/meter </lsl> Please pay attention to the case of the command above.
This command is synonymous to the user indicated by USER_KEY pressing the Reminders button
LOCK / UNLOCK
This command is handled by the CasperTech servers. Do not make unreasonably frequent or repeated requests. |
<lsl> llMessageLinked( LINK_THIS, 0, "CLAPI-Lock/Unlock", USER_KEY); </lsl>
.. or ..
<lsl> llRegionSayTo( KEY_OF_UNIT, -77777, "CLAPI"+KEY_OF_UNIT+"-Lock/Unlock|"+USER_KEY+"|0"); // where KEY_OF_UNIT is the uuid of the rental box/meter </lsl>
Please pay attention to the case of the command above.
This command is synonymous to the user indicated by USER_KEY pressing the Lock/Unlock button
RESET
<lsl> llMessageLinked( LINK_THIS, 0, "CLAPI-Reset", NULL_KEY ); </lsl>
.. or ..
<lsl> llRegionSayTo( KEY_OF_UNIT, -77777, "CLAPI"+KEY_OF_UNIT+"-Reset|"+NULL_KEY+"|0" ); // where KEY_OF_UNIT is the uuid of the rental box/meter </lsl> This triggers the unit to reset. Please use this ONLY when absolutely necessary - if a unit restarts too often, it will be blocked from the network.
Script Samples
Script to change hovertext color
default { link_message( integer sender_num, integer num, string str, key id ) { if (str=="TEXT") { list tmp = llParseStringKeepNulls((string)id, ["|"],[]); llSetText(llList2String(tmp,1),<0.0,0.0,0.0>,1.0); // This script changes text to black } } }
Finding Rental Unit Keys/UUID
In Firestorm viewer, right-click > edit > "Copy Keys"
FAQ / Troubleshooting
- Q. Is there a way to get the unit to spit out any data on additional subtenants?
- A. This information is sent when there are additional tenants added or removed, and when the unit is reset. You can request that the rental unit is reset by using CLAPI-Reset, as detailed above, however you must only do this ONCE. Any further updates will be transmitted when they happen.
- Q. The API documentation says:
llRegionSay( -77777, "CLAPI-UPDATE"+KEY_OF_UNIT+"|UPDATE|0" ); // where KEY_OF_UNIT is the uuid of the rental box/meter
- but when I stand next to the box and say this in local chat, nothing happens:
-77777 CLAPI-UPDATE|5194ac0b-4a9f-5c4b-d24e-e0a374533f1d|UPDATE|123
- A. Rental units do NOT respond to avatars. The command will need to be coming from a scripted object.
- Q. I'm trying to get help with a script using the API, but I'm worried that someone else will use the script to get free rent...
- A. The rental units will only respond to a scripted API command from an object that is owned by the same avatar that owns the rental units. So no, a third party cannot get free rent, or otherwise abuse the API for YOUR rental units.