Announcement

Collapse
No announcement yet.

NWN Scripting Question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Code:
    //Created by Jamski
    //Put this OnUsed for each lever 
    //(leverone, levertwo leverthree, leverfour)
    //Make four copies, one for each lever
    //Change the text in bold for each lever
    //Call the door to be opened DOOR_TO_OPEN
    
    void main()
    object oTarget;
    {
    object oPC = GetLastUsedBy();
    if (!GetIsPC(oPC)) return;
    int nInt;
    nInt=GetLocalInt(oPC, "leverone");
    if (nInt == 1)
    {
    nInt=GetLocalInt(oPC, "levertwo");
    if (nInt == 1)
    {
    nInt=GetLocalInt(oPC, "leverthree");
    if (nInt == 1)
    {
    nInt=GetLocalInt(oPC, "leverfour");
    if (nInt == 1)
    {
    oTarget = GetObjectByTag("DOOR_TO_OPEN");
    SetLocked(oTarget, FALSE);
    AssignCommand(oTarget, ActionOpenDoor(oTarget));
    }
    }
    }
    }
    }
    {
    object oPC = GetLastUsedBy();
    if (!GetIsPC(oPC)) return;
    SetLocalString(oPC, "[b]leverone[/b]", "1");
    }
    This checks each time you pull a lever if all 4 have been pulled, and if so opens and unlocks the door called DOOR_To_OPEN. If not, it sets that lever to "pulled".

    Clear?

    -Jam
    1) The crappy metaspam is an affront to the true manner of the artform. - Dauphin
    That's like trying to overninja a ninja when you aren't a mammal. CAN'T BE DONE. - Kassi on doublecrossing Ljube-ljcvetko
    Check out the ALL NEW Galactic Overlord Website for v2.0 and the Napoleonic Overlord Website or even the Galactic Captians Website Thanks Geocities!
    Taht 'ventisular link be woo to clyck.

    Comment


    • #32
      Whoops. Change the last block to :

      Code:
      object oPC = GetLastUsedBy();
      if (!GetIsPC(oPC)) return;
      SetLocalInt(oPC, "[b]leverone[/b]", 1);
      Its an Int, not a sString
      1) The crappy metaspam is an affront to the true manner of the artform. - Dauphin
      That's like trying to overninja a ninja when you aren't a mammal. CAN'T BE DONE. - Kassi on doublecrossing Ljube-ljcvetko
      Check out the ALL NEW Galactic Overlord Website for v2.0 and the Napoleonic Overlord Website or even the Galactic Captians Website Thanks Geocities!
      Taht 'ventisular link be woo to clyck.

      Comment


      • #33
        Bleh, sorry, forget all that. This one is better :

        Code:
        //Created by Jamski
        //Put this OnUsed for each lever
        //(leverone, levertwo leverthree, leverfour)
        //Make four copies, one for each lever
        //Change the text in bold for each lever
        //Call the door to be opened DOOR_TO_OPEN
        //Best Version
        
        void main()
        
        {
        object oPC = GetLastUsedBy();
        if (!GetIsPC(oPC)) return;
        SetLocalInt(oPC, "[b]leverone[/b]", 1);
        if (!GetIsPC(oPC)) return;
        int nInt;
        nInt=GetLocalInt(oPC, "leverone");
        if (nInt == 1)
        {
        nInt=GetLocalInt(oPC, "levertwo");
        if (nInt == 1)
        {
        nInt=GetLocalInt(oPC, "leverthree");
        if (nInt == 1)
        {
        nInt=GetLocalInt(oPC, "leverfour");
        if (nInt == 1)
        {
        object oTarget = GetObjectByTag("DOOR_TO_OPEN");
        SetLocked(oTarget, FALSE);
        AssignCommand(oTarget, ActionOpenDoor(oTarget));
        }
        }
        }
        }
        }
        -Jam
        1) The crappy metaspam is an affront to the true manner of the artform. - Dauphin
        That's like trying to overninja a ninja when you aren't a mammal. CAN'T BE DONE. - Kassi on doublecrossing Ljube-ljcvetko
        Check out the ALL NEW Galactic Overlord Website for v2.0 and the Napoleonic Overlord Website or even the Galactic Captians Website Thanks Geocities!
        Taht 'ventisular link be woo to clyck.

        Comment


        • #34
          Just tested this last one - it works PERFECTLY. Ok, the levers don't animate, but that's not my problem. Use buttons instead or add an animation

          -Jam
          1) The crappy metaspam is an affront to the true manner of the artform. - Dauphin
          That's like trying to overninja a ninja when you aren't a mammal. CAN'T BE DONE. - Kassi on doublecrossing Ljube-ljcvetko
          Check out the ALL NEW Galactic Overlord Website for v2.0 and the Napoleonic Overlord Website or even the Galactic Captians Website Thanks Geocities!
          Taht 'ventisular link be woo to clyck.

          Comment


          • #35
            I couldn't get that one to work either.

            Here is the script I've been using:

            Code:
            void main()
            {
            
              object oPC=GetLastUsedBy();
              int nUsed1 = GetLocalInt(OBJECT_SELF, "LEVER_STATE");
            
              int nUsed2;
              int nUsed3;
              int nUsed4;
              //
              // nUsed1 and nUsed2 are used to temporarily hold the states of the two levers.
              // 0 is off, 1 is on
              // LEVER_STATE is the permanent holding spot for the variables.
              // Each lever stores its own LEVER_STATE
              //
              if(nUsed1 == 0)
              {
                ActionPlayAnimation(ANIMATION_PLACEABLE_ACTIVATE);
                SetLocalInt(OBJECT_SELF, "LEVER_STATE", 1);
                ActionSpeakString("You hear the sound of a metal pin being released.");
                PlaySound("as_sw_metalop1");
                nUsed1 = 1;
              }
              else
              {
                PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE);
                SetLocalInt(OBJECT_SELF, "LEVER_STATE", 0);
                ActionSpeakString("You hear the sound of a metal pin being reset.");
                PlaySound("as_sw_metalcl1");
                nUsed1 = 0;
              }
            
            object oLever1=GetNearestObjectByTag("DLEVER1");
            object oLever2=GetNearestObjectByTag("DLEVER2");
            object oLever3=GetNearestObjectByTag("DLEVER3");
            object oLever4=GetNearestObjectByTag("DLEVER4");
            
            
              nUsed1 = GetLocalInt(oLever1, "LEVER_STATE");
              nUsed2 = GetLocalInt(oLever2, "LEVER_STATE");
              nUsed3 = GetLocalInt(oLever3, "LEVER_STATE");
              nUsed4 = GetLocalInt(oLever4, "LEVER_STATE");
            
              string sUsed1=IntToString(nUsed1);
              string sUsed2=IntToString(nUsed2);
              string sUsed3=IntToString(nUsed3);
              string sUsed4=IntToString(nUsed4);
            
              SendMessageToPC(oPC, "Use1 is "+sUsed1);
              SendMessageToPC(oPC, "Use2 is "+sUsed2);
              SendMessageToPC(oPC, "Use3 is "+sUsed3);
              SendMessageToPC(oPC, "Use4 is "+sUsed4);
            
              if ((nUsed1 == 1) && (nUsed2 == 1) && (nUsed3 == 1) && (nUsed4 == 1))  // Are all levers on?
              {
                AssignCommand(oPC, ActionSpeakString("That should be all of them."));
                object oDoor=GetNearestObjectByTag("VCD_DOOR2");
                SetLocked(oDoor, FALSE);
              }
            }
            When I pull lever 1, all the numbers read 0. When I pull lever 2; lever 1 reads 1, but lever 2 reads 0. If I then pull lever 1 again; lever 1 reads 0, and lever 2 reads 1. So each lever activates the previous lever pulled at the same time reseting itself to 0. Pulling the same lever twice does nothing.
            “As a lifelong member of the Columbia Business School community, I adhere to the principles of truth, integrity, and respect. I will not lie, cheat, steal, or tolerate those who do.”
            "Capitalism ho!"

            Comment


            • #36
              I got help from the Bioware boards. It seems that you can't use GetNearestObjectByTag() to refer to the object running the script. By just changing them all to GetObjectByTag(), it worked.
              “As a lifelong member of the Columbia Business School community, I adhere to the principles of truth, integrity, and respect. I will not lie, cheat, steal, or tolerate those who do.”
              "Capitalism ho!"

              Comment


              • #37
                Mine works for me. I've used it in the DoA with you wondering how the door opens Perhaps you mixed up the renaming when you made your four copies?

                I see you wanted each lever to have an on-off state. Mine are off until used and then stay used forever. When the fourth one is used, the door opens. Yours is more of a puzzle. I may steal it, if that's ok

                -Jam
                1) The crappy metaspam is an affront to the true manner of the artform. - Dauphin
                That's like trying to overninja a ninja when you aren't a mammal. CAN'T BE DONE. - Kassi on doublecrossing Ljube-ljcvetko
                Check out the ALL NEW Galactic Overlord Website for v2.0 and the Napoleonic Overlord Website or even the Galactic Captians Website Thanks Geocities!
                Taht 'ventisular link be woo to clyck.

                Comment


                • #38
                  Heh, just saw you on the bioware boards

                  -Jam
                  1) The crappy metaspam is an affront to the true manner of the artform. - Dauphin
                  That's like trying to overninja a ninja when you aren't a mammal. CAN'T BE DONE. - Kassi on doublecrossing Ljube-ljcvetko
                  Check out the ALL NEW Galactic Overlord Website for v2.0 and the Napoleonic Overlord Website or even the Galactic Captians Website Thanks Geocities!
                  Taht 'ventisular link be woo to clyck.

                  Comment

                  Working...