2 Replies Latest reply on Feb 25, 2010 6:56 PM by downerxx

    script error : object with duplicate name already exists

    downerxx

      how can i name these differently to avoid getting this error


        repeat with x = 1 to 10
        wallMR = pMember.newModelResource("wall",#box)
        wallMR.height = 10
        wallMR.length = 50
        wallMR.width = 150
       
        pMember.newModel("wall",wallMR)
        pMember.model("wall").translate(-50,-20,25)
       
        brickTex = pMember.newTexture("brick",#fromCastMember, member"brickMap")
        pMember.model("wall").shader.texture = brickTex
        pMember.model("wall").shader.textureTransform.scale  = vector(0.25, 0.25, 0.25)
        end repeat

       

      i know that the objects will all be placed on the same spot, however once i understand how to make more than one that part will be easy

        • 1. Re: script error : object with duplicate name already exists
          James Newton, ACP Level 3

          Here's a revision of your script which should create a series of wall models spread out across your world.  I've left gaps of 10 world units between each model, so that you can see where they begin and end

           

             -- You can use the same name for all constant elements, so long as
          -- they are all of different types
          vName = "wall"

           

          -- You probably don't need to create the wall model resource more than once
          wallMR = pMember.newModelResource(vName,#box)
          wallMR.height = 10
          wallMR.length = 50
          wallMR.width = 150

           

          -- You don't need to create the texture more than once. Note that
          -- this texture will now be called "wall"
          brickTex = pMember.newTexture(vName)
          brickTex.member = member("brickMap")

           

          -- You should create a distinct shader for the wall, otherwise you
          -- will be modifying the default shader
          vShader = pMember.newShader(vName, #standard)
          vShader.texture = brickTex
          vShader.textureTransform.scale = vector(0.25, 0.25, 0.25)

           

          -- Now create a set of ten models, each with a distinct name
          repeat with x = 1 to 10
             vName = "wall_"&x -- "wall_1", "wall_2" ... "wall_10"
             vModel = pMember.newModel(vName,wallMR)
             vModel.shader = vShader

           

             vX = x * 200 -- use a different x co-ordinate for each model
             vModel.translate(-vX,-20, 25)
          end repeat

           

          Is this the sort of thing you are looking for?

          1 person found this helpful
          • 2. Re: script error : object with duplicate name already exists
            downerxx Level 1

            yea, thank you very much

            sorry didnt know i wasnt able to click both helpful and correct this was my first post, the walls texture didnt get applyed to them