Jump to content

s3229002

Resident
  • Posts

    3
  • Joined

  • Last visited

Posts posted by s3229002

  1. For some reason my prim detected the end position fine but then later on it doesn't work anymore. Here is my code:

     

    integer on = TRUE;
    vector pos;
    vector startpos = <81.287,87.940,30.251>;
    vector endpos = <81.787,84.690,30.451>;
    key ToucherID;
    integer channel_dialog;
    integer listen_id;
    list choice = ["1V", "3V", "5V"];
    string msg = "Please choose a voltage value for battery:";

    default
    {
        state_entry()
        {
            llSetText("Touch to move voltage source",<0,1,0>,1);
            llListen(-20, "", "", "");
            channel_dialog = ( -1 *
    (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) );
        }

        listen(integer channel, string name, key id, string choice)
        {
            if(channel == -20)
            {
                llSetText("Reset!",<0,1,0>,1);
                llSetPos(startpos);
                llResetScript();
            }
            else if (choice == "1V")
            {
                llShout(30, "");
                llListenRemove(listen_id); //HERE WE ARE BEING RESPONSIBLE
            }
            else if (choice == "3V")
            {
                llShout(31, "");
                llListenRemove(listen_id); //HERE WE ARE BEING RESPONSIBLE
            }
            else if (choice == "5V")
            {
                llShout(32, "");
                llListenRemove(listen_id); //HERE WE ARE BEING RESPONSIBLE
            }
            else
            {
                llShout(33, "");
                llListenRemove(listen_id); //HERE WE ARE BEING RESPONSIBLE
            }
        }
       
        touch_start(integer x)
        {
            pos = llGetLocalPos();
           
            if (on == TRUE)
            {
               listen_id = llListen( channel_dialog, "", ToucherID, "");
               llSetPos(llGetLocalPos() + <0,0,0.2>);
               llRequestPermissions(llDetectedKey(0), PERMISSION_TAKE_CONTROLS);
               on = FALSE;
            }   
            else if(pos == endpos)
            {
                llSetText("Correct placement!",<0,1,0>,1);
                llSleep(3.0);
                llReleaseControls();
                llSetText(msg, <1,1,1>,1);
                llSleep(3.0);
                ToucherID = llDetectedKey(0);
            llDialog(ToucherID, msg, choice, channel_dialog);
            listen_id = llListen( channel_dialog, "", ToucherID, "");
            llSetTimerEvent(60); //HERE WE SET A TIME LIMIT
            }
            else if (on == FALSE)
            {
                llSetText("Wrong spot...",<0,1,0>,1);
                llSetPos(pos);
                llRequestPermissions(llDetectedKey(0), PERMISSION_TAKE_CONTROLS);
                llReleaseControls();
                on = FALSE;
            }
        }
       
        run_time_permissions(integer perm)
        {
            integer controls = CONTROL_FWD | CONTROL_BACK |
                 CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT;
            if(perm & PERMISSION_TAKE_CONTROLS)
            {
                llTakeControls(controls, TRUE, FALSE);
            }
        }
       
        control(key id, integer level, integer edge)
        {
            integer button = level;
            if(button & CONTROL_FWD)
            {
                llSetPos(llGetLocalPos()+<0,-0.25,0>);
            }
            if(button & CONTROL_BACK)
            {
                llSetPos(llGetLocalPos()+<0,0.25,0>);
            }
            if(button & CONTROL_ROT_LEFT)
            {
                llSetPos(llGetLocalPos()+<0.25,0,0>);
            }
            if(button & CONTROL_ROT_RIGHT)
            {
                llSetPos(llGetLocalPos()+<-0.25,0,0>);
            }
        }
       
        timer()
        { //TIME?S UP!
            llListenRemove(listen_id);
            //llWhisper(0, "Times up.");
            llSetTimerEvent(0.0); //Stop the timer from being called repeatedly
        }
    }

  2. I would like to know how to make avatar move a prim by carrying it and place that prim on top of another prim. I would like to make a circuit board and have these prims (components) placed on the circuit board (another prim). Also how would I make the circuit board prim detect the location of the prim placed on top so that the avatar can get a message saying the prim (component - ie. resistor) is placed in the wrong part of the board? Thanks

×
×
  • Create New...