Upcoming Events

Collapse

There are no results that meet this criteria.

Announcement

Collapse
No announcement yet.

Door Scripting

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

  • Door Scripting

    For an area I'm making, I need to assign each door in the area to a "number" (I have over 35 doors). Now I need to script it so when say door one opens, every second door closes. I'm making sort of a maze type of thing. Any help would be appreciated.

  • #2
    Easiest way would be to make an onopen script that would first get the door tag and use findsubstring to seperate the last half of the tag, increment it, and use that to get the next door in sequence. After that it's just a matter of executing the doorclose function.
    The very existence of flame-throwers proves that some time, somewhere, someone said to themselves, You know, I want to set those people over there on fire, but I'm just not close enough to get the job done.

    George Carlin

    Comment


    • #3
      *eye twitches* Okay, uhmm.... there is also a way to open every door in the current area when a certain lever is activated correct?

      Comment


      • #4
        Offhand without double checking you could just loop through the doors if there is a function for that. Otherwise you could just increment through the tags using GetObject and assigning a door open action.
        The very existence of flame-throwers proves that some time, somewhere, someone said to themselves, You know, I want to set those people over there on fire, but I'm just not close enough to get the job done.

        George Carlin

        Comment


        • #5
          Pseudo code for possible solution

          I can think of a few Coding methods this could be done, this one seems more appropriate:

          Pseudocode (more VB script style)


          ASSUMPTIONS:
          - It is possible to retrieve a container object that refers to all objects.
          - The scripting / programming functionality has an ewffective String search function that can return a value if one string is found within another.

          openDoors(connectDoors as string)
          {
          Variable Object
          Variable doorArray = ObjectContainer
          For Each Object in DoorObjects
          if Object.type = "Door Type" then
          if Object.Name is in the string connectDoors then
          call doAction_openDoor(Object)
          end if
          end if
          Next Object
          }

          calling connectDoors("Door1Door2Door4") will have the "doAction_openDoor" method called for and Object thats name appears in the provided string. This way, the function is very portable (in C++, it will work well with VOID object types) because you can simply build the string with what you want done. I'm not sure the entire power of the NWN2 toolset, but I'm pretty sure it has a strong C++ element in it.
          Calini Anna'Des - Resentful of the Law's values and troubled with her Past.

          "The life of the creative person is lead, directed and controlled by boredom. Avoiding boredom is one of our most important purposes." - Saul Steinberg

          "Opportunity is missed by most people because it comes dressed in overalls and looks like work" - Thomas Edison

          Comment


          • #6
            You do realize that nwscript doesn't support arrays and nothing about that code is valid?
            The very existence of flame-throwers proves that some time, somewhere, someone said to themselves, You know, I want to set those people over there on fire, but I'm just not close enough to get the job done.

            George Carlin

            Comment


            • #7
              And you do realize this was posted in March and the original poster isn't even active anymore?

              Comment


              • #8
                *Ouroboros ducks his head in shame and retreats to his little hole. Looks over his old programming books and mutters to himself about how awesome arrays are*
                Calini Anna'Des - Resentful of the Law's values and troubled with her Past.

                "The life of the creative person is lead, directed and controlled by boredom. Avoiding boredom is one of our most important purposes." - Saul Steinberg

                "Opportunity is missed by most people because it comes dressed in overalls and looks like work" - Thomas Edison

                Comment


                • #9
                  Well, going off the assumption that you want to make a puzzle that's a little like Lights Out (although it's hard to say from your description :P), what I'd do is make a pattern for the doors. Let's say you have a 9 by 9 grid of doors, the top left door will be 11, the bottom left, 91, the top right, 19, the bottom right, 99 and the middle, 55.

                  In other words:
                  11 21 31 41 51 61 71 81 91
                  12 22 32 42 52 62 72 82 92
                  13 23 33 43 53 63 73 83 93
                  14 24 34 44 54 64 74 84 94
                  15 25 35 45 55 65 75 85 95
                  16 26 36 46 56 66 76 86 96
                  17 27 37 47 57 67 77 87 97
                  18 28 38 48 58 68 78 88 98
                  19 29 39 49 59 69 79 89 99

                  That's enough for 81 doors, so you won't need that many. You'll probably use 35 that look like this:

                  11 21 31 41 51
                  12 22 32 42 52
                  13 23 33 43 53
                  14 24 34 44 54
                  15 25 35 45 55
                  16 26 36 46 56
                  17 27 37 47 57

                  So set your door tags up as shown above, just like coordinates. You can then get these tags and use string manipulation to get the last two digits and assign them to x and y integers. From there you can use simple maths (+1, -1, to each integer) and each time get a new door according to the grid (using more string manipulation to recreate a door tag). If the x integer is over 5 or under 1, ignore it, if the y is over 7 or under 1, ignore it.

                  Each time you'll need to get the status of the door and open / close as required, but that's easy to do. If you know anything about coding you should be able to work this idea out, but I admit it is complex, which is why I'm just giving the theory :P
                  Last edited by Dustiness; 06-07-2008, 09:39 AM. Reason: "And you do realize this was posted in March and the original poster isn't even active anymore?" DAMNIT!
                  "Gentlemen, you can't fight in here! This is the War Room!"

                  Comment

                  Working...
                  X