Efficiency
Over in the Second Life discussion forum, some good questions were raised about the efficiency of FUNK encoding. Registration is required. What, you don’t have a Second Life account?! Get one free and help support FUNK in Second Life. As a general rule, I will not be cross-posting but in cases where there’s something someone new to FUNK might find valuable I will. Here is my response:
Thanks for the feedback! It, patience and time will hopefully allow me to clarify some things. If it were intended primarily for LSL<->LSL comms, I would agree with your “overkill” observation. However, RAP is part of a broader framework for interoperability that provides non-expert users the ability to script the meshverse - including Second Life objects. As with all environments, there will be solutions which require experienced coders to choose or even invent more efficient approaches. GVScript - http://www.gvscript.com/2007/02/20/second-life-version/ uses RAP to provide coders with the ability to use a consistent messaging format across environmental and language boundries. For beginning and intermediate LSL coders this can mean the difference between a problem being approachable with tools and concepts they are familar with or intractable because there are too many nuances and details for them to wade through. Yes poor performing solutions will result in some cases but taking a glass-half-full type of person, experienced developers can benefit from a working specification of what someone wants to accomplish. With GVScript all of the means of LSL<->LSL communication are available to a developer and I am very interested in seeing more powerful approaches integrated. The web is inefficient at a bit level, but on a macro, planetary scale it has proven very efficient at empowering non-experts and seasoned professionals to create solutions that matter. RAP is attempting to be efficient on a broader scale.
Including Components of FUNK
Because LSL has no generic “include”, each bundle of capablility must be included in your scripts or accessed via link_message. The latter is preferable as it is easier to maintain. However, for the examples, RAP scripts contain the FUNK Encoding scripts in line where appropriate to make it easier to see how things work.
Upcoming Changes to RAP
- list length fix
- FUNK encoding of receiver
- receiver treated as URI
- http support
- default scheme
- autogeneration of transmitters
How To RAP In Second Life
- Extract the three lsl scripts from this RAP zip file. I’ll be providing these in a nice in-world package soon.
- Create two objects one to send messages the other to receive messages.
- In the sending object, create a script for the contents of RAPKernel.lsl.
- In the sending object, create one or more scripts for the contents of RAPTransmitter.lsl.
- These transmitter scripts MUST be named sequentially with a negative integer eg. -1, -2, -3 etc.
- The number of transmitter scripts will determine how quickly the sender script can send messages using email. For http based messages this won’t matter. However, http is still in test so email is currently is the only option for the next few days.
- In the receiver object, create a script for the contents of RAPReceiver.lsl. After that script is saved, a copy of the object’s key will be in your chat history.
- Edit the RAP Kernel script and in the touch_start function, replace the phrase PUT A VALID EMAIL ADDRESS HERE with the key for the receiver object followed by @lsl.secondlife.com.
- Click the object and examine the chat messages it sends.
Given the example code touch_start code:
rap(”PUT A VALID EMAIL ADDRESS HERE”,”one”,[1, <0,0,0>,”something, fast and “,”loud”],[”intOne”,”vectOne”,”strOne”,”strTwo”]);
rap(”PUT A VALID EMAIL ADDRESS HERE”,”do”,[”it”,”slow”],[]);
rap(”PUT A VALID EMAIL ADDRESS HERE”,”two”,[”the result”,”and say something fast”],[]);
Clicking the object should produce the following output:
[1:24] Object: action is: one
[1:24] Object: directions are: stageDirections0intOne11vectOne5<0.000000, 0.000000, 0.000000>strOne3something, fast and strTwo3loud
[1:24] Object: number of directions is: 4
[1:24] Object: integer intOne = 1
[1:24] Object: vector vectOne = <0.000000, 0.000000, 0.000000>
[1:24] Object: string strOne = something, fast and
[1:24] Object: string strTwo = loud
[1:24] Object: GOT one with - 0stageDirections,1intOne, 1, 5vectOne, %3C0%2E000000%2C%200%2E000000%2C%200%2E000000%3E, 3strOne, something%2C%20fast%20and%20, 3strTwo, loud
[1:24] Object: action is: do
[1:24] Object: directions are: stageDirections0l03itl13slow
[1:24] Object: number of directions is: 2
[1:24] Object: string l0 = it
[1:24] Object: string l1 = slow
[1:24] Object: do not handled
[1:24] Object: action is: two
[1:24] Object: directions are: stageDirections0l03the resultl13and say something fast
[1:24] Object: number of directions is: 2
[1:24] Object: string l0 = the result
[1:24] Object: string l1 = and say something fast
[1:24] Object: GOT two with - 0stageDirections,3l0, the%20result, 3l1, and%20say%20something%20fast
FUNK Encoding and Decoding
This FUNK Encoding and Decoding zip file contains scripts that implement the FUNK Encoding specifications for LSL. In addition to their use in FUNK, in LSL these scripts are also good for passing parameters, untyped variables, lists containing lists and associative arrays.