Jump to content

Rez a random object


scriptina
 Share

Recommended Posts

I want to mod the following rezer script in that way, that it rezes random objects instead of the same one all the time. Will that be possible somehow? Do I need to change only this script or the script in one of the 5 target objects I want to be rezed too? 

default
{
    touch_start(integer total_number)
    {
        vector Pos = llDetectedPos(0);
        if (llVecDist(Pos,llGetPos()) < 10.0)
        {
             rotation Rot = llDetectedRot(0);
             vector NewPos = Pos + <-0.5,0,0>*Rot;
                     llRezAtRoot("object",NewPos,ZERO_VECTOR, Rot,1);
             llInstantMessage(llDetectedKey(0),"Please sit down.");
        }
        else
        {
             llInstantMessage(llDetectedKey(0),"Sorry you are too far away.");
        }
    }
}
Link to comment
Share on other sites

An alternative way to choose random objects -- not a better way, just an alternative -- is to build a list of inventory objects in state_entry() and then, at run time, say something like 

string whichObject = llList2String(llListRandomize(ObjectList,1),0);

 That is, tell LSL to randomise the order of the elements in your list each time you want to rez something, and then pick the first one of the new, randomised, list.

Link to comment
Share on other sites

That worked fine! I am so happy:) I get all my objects in random order now. Now I just need to know where in the script I can change the postition of the rezed object because it always rezes sideways and a little bit to high. I want it to be rezed on ground and with 90° rotation compared to now. Do I need to set this position in rezzer script or in the object itself or in both?

You'd make my day and weekend even if I could work this out ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...