Jump to content

Assigning a function on object


XbabylonX
 Share

You are about to reply to a thread that has been inactive for 3803 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello,

Im trying for many days to do this, after gatting a callback from a webserver to assign a function on an object, with few words, its a simple prim with no function called when clicking on it, but after the callback it should have a function. With the same logic, depending on the callback value I would like to remove the function. Someone who is familiar with jquery would understand that as:

$("#objectid").attr("onClick","newfunction()");

 One more thing Im trying to achieve after the callback is to create a global variable, but again with no success.

I would appreciate your help.
Thank you for your time

Link to comment
Share on other sites

There doesn't seems to be a native method available for this purpose. There is no such thing like injections or delegates in LSL. Some time ago scripts were able to do XML RPC calls but those got deprecated and the wiki sais: 

XML-RPC should not be used anymore. Use http-in instead 

http://wiki.secondlife.com/wiki/LlOpenRemoteDataChannel

So you would need to predefine those methods and variables first  in order to activate or initialize them through a http request.

Link to comment
Share on other sites

You might have two defaults, the usual default plus another state called, say. "active".  Inside your default event you would not have any touch*events at all. In your "active" state, you would have the touch* events. You would have the HTTP communications events in both states, so that you can learn when it is time to switch modes.

Link to comment
Share on other sites

Either that way or just within a single state which will avoid redundant code.

Would look something like this:

 

key requestid;string mode = "default";default{    state_entry()    {         requestid = llHTTPRequest("http://yourURL.com/interface.php?cmd=get_mode",[HTTP_METHOD,"GET"],"");    }    touch_start(integer num)    {        if(mode=="default")        {            // implement default behaviour        }        else if(mode=="mode_a")        {            // implement a custom behaviour        }        // implement more else if's if required    }    http_response(key request_id, integer status, list metadata, string body)    {        if(request_id==requestid)        {            mode = body;        }    }}

 

Link to comment
Share on other sites

Cerise,

I have to init my object having the touch trigger and only in some cases (depending the callbacks) I need to cancel the trigger. So isnt possible to use your scenario up side down?

Revochen, I didnt mean injecting a function from outside of sl, my server just sends 1 or 0, then the simple things happens:

if callback=1

everything fine

else if callback=0

remove the touch trigger of the object

Maybe that example can point you to the right idea of what Im trying to make.

But thanks again guys, I will read your responses tomorrow since I need to sleep :)

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3803 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...