19 Replies Latest reply on Aug 28, 2006 5:55 AM by Tård

    help me with repeat while

    Pelleyoo
      Hi!

      Shouldn't this work;

      repeat while J < 4

      t[J] = member("w3d").newTexture("B[J]",#fromCastMember,member("B[J]"))

      end repeat

      it doesn't

      thx
        • 1. Re: help me with repeat while
          tedalde2 Level 2
          you'd need to type your string (assuming B[J] is a string...) and increment your J:

          • 2. Re: help me with repeat while
            extol
            tedalde2's got it. By puting "B[J]", your making it look for a member named "B[J]" and make a texture from it called "B[J]". You want it to look for the actual contents of B[J]....So don't use the quotes.

            Also, you can replace your first line with:

            repeat with J = 1 to 4

            Then you don't have to increment J, it will do it automatically
            • 3. Re: help me with repeat while
              Tård
              I'm the same person as Pelleyoo, I'm kinda' scytzofrien.

              What I want to do is to add a new texture with the name "B1" from the castmember "B1" and then automaticly create a texture with the name "B2" from the castmember "B2". and then the same from "B3" and "B4".

              What you guys suggested didn't work for this.
              Do you have another suggestion for this.

              thanks!

              • 4. help me with repeat while
                Necromanthus Level 2
                quote:

                Originally posted by: Tård
                I'm the same person as Pelleyoo, I'm kinda' scytzofrien.


                Ha ha ha. This was a good one !

                p.s.

                • 5. Re: help me with repeat while
                  Pelleyoo Level 1
                  Now im Pelleyoo again. Thank god for that.

                  Im sorry I have to tell you, nectromantus, that it didn't work. A new texture aint created..for some reason, B1 becomes an floating number, and the debugger just says "Void". :/ whats wrong? Do I have to convert it to a string or something?

                  Thanks on beforehaqnd
                  • 6. Re: help me with repeat while
                    Necromanthus Level 2
                    quote:

                    Originally posted by: Pelleyoo
                    Im sorry I have to tell you, nectromantus, that it didn't work. A new texture aint created..for some reason, B1 becomes an floating number, and the debugger just says "Void". :/ whats wrong? Do I have to convert it to a string or something?


                    It works fine for me.
                    You have to launch it on beginSprite(me).
                    p.s.
                    Who is nectromantus ?
                    ha ha ha
                    • 7. Re: help me with repeat while
                      Pelleyoo Level 1
                      We did that. Please help, something is cp as we say in sweden...
                      • 8. Re: help me with repeat while
                        Necromanthus Level 2
                        quote:

                        Originally posted by: Pelleyoo
                        We did that. Please help, something is cp as we say in sweden...


                        on beginSprite(me)
                        t = []
                        repeat with j = 1 to 4
                        t[j] = member("w3d_name").newTexture("B"&j, #fromCastMember, member("B"&j))
                        end repeat
                        end

                        Put the above piece of LINGO in a frame script.
                        That frame must contain the W3D member (as sprite).
                        And finally, I hope you're a Director MX2004 user ...
                        • 9. Re: help me with repeat while
                          Pelleyoo Level 1
                          YES thats exactly what we did. Only sausages can talk, In a world were animals are running anarchy. Peace.
                          • 10. Re: help me with repeat while
                            Necromanthus Level 2
                            quote:

                            Originally posted by: Pelleyoo
                            YES thats exactly what we did. Only sausages can talk, In a world were animals are running anarchy. Peace.

                            I can't figure out what are you doing wrong there ...
                            If that place is damned or in case of paranormal activities, you have to work hard:

                            global t1,t2,t3,t4

                            on beginSprite(me)
                            t1 = member("w3d_name").newTexture("B1", #fromCastMember, member("B1"))
                            t2 = member("w3d_name").newTexture("B2", #fromCastMember, member("B2"))
                            t3 = member("w3d_name").newTexture("B3", #fromCastMember, member("B3"))
                            t4 = member("w3d_name").newTexture("B4", #fromCastMember, member("B4"))
                            end

                            I'm going now.
                            You may rest in peace because for you repeat doesn't exist.


                            • 12. Re: help me with repeat while
                              extol Level 1
                              Hejsan, Pellyoo. Vilken version om Direktor har du?
                              • 13. Re: help me with repeat while
                                Pelleyoo Level 1
                                Director MX 2004 såklart.

                                ***å jag blir så frustrerad..nåt är helt klart mel med necromathus förslag. Det skapas liksom ingen ny textur som heter B1, det enda som händer är att T1 till T4 blir variablar och B1 till B4 blir variablar, och det står bara "void" på dom i debuggern. B1 till B4 ska ju inte bli variablar, så nåt måste va fel.

                                Om du löser det här, så kan ja lova dig att du räddar min och tårds kommande vecka =) Vi har projektarbete i skolan nu och ska va klara med det här spelet på fredag. Alla smidiga lösningar behövs om vi ska klara det...
                                • 14. Re: help me with repeat while
                                  Roofy
                                  Pelleyoo,
                                  I did not understand your last post considering that I only know english, but did you resolve this problem yet? If not, then the reason why the code that was given to you from the other members is becuase part of the reason is from this line....

                                  repeat with j = 1 to 4

                                  when you do this, the varible j is an integer and not a string, and you cannot mix integers with a string. Therefore, when you call this...
                                  t[j] = member("w3d_name").newTexture("B"&j, #fromCastMember, member("B"&j))

                                  ... you are not getting the correct string because you are mixing a string with an integer varible j. To properly do this, you need to temporarlly convert j into a string like so....

                                  on beginSprite
                                  t = []
                                  repeat with j = 1 to 4
                                  t[j] = member("w3d_name").newTexture("B"&string(j), #fromCastMember, member("B"&string(j)))
                                  end repeat
                                  end beginSprite

                                  ... however, I am suppried you did not get a script error when you did it the way the others told you to do it, or did you get a script error?
                                  • 15. help me with repeat while
                                    Necromanthus Level 2
                                    quote:

                                    Originally posted by: Roofy
                                    when you do this, the varible j is an integer and not a string, and you cannot mix integers with a string. Therefore, when you call this...
                                    t[j] = member("w3d_name").newTexture("B"&j, #fromCastMember, member("B"&j))

                                    ... you are not getting the correct string because you are mixing a string with an integer varible j.


                                    False !
                                    ("B"&j) is always a string !
                                    It doesn't matter if j is an integer or a string.
                                    It's a matter of LINGO parser ...
                                    p.s.
                                    A new tutorial is on the way, and you'll see this method included.

                                    • 16. Re: help me with repeat while
                                      Necromanthus Level 2
                                      If Pelleyoo owns Director MX2004, i think his problem is bad names related.
                                      So ... replace the above script with this one:

                                      on beginSprite(me)
                                      t = []
                                      repeat with j = 1 to 4
                                      t[j] = member("w3d_name").newTexture("tx"&j, #fromCastMember, member("B"&j))
                                      end repeat
                                      end


                                      This method is used in Warcraft Reloaded and Quake 3 Forever ...
                                      • 17. Re: help me with repeat while
                                        extol Level 1
                                        Roofy - that makes sense. I know with Actionscript you can put "B" + j and it will automatically convert J to a string. So I had just assumed that Lingo did the conversion with "B" & j.

                                        Necromanthus, are you sure you don't have to use String(j)? Because I can't see any other reason that the code you supplied wouldn't work for Pelleyoo.
                                        • 18. Re: help me with repeat while
                                          Tård Level 1
                                          Hi!

                                          Now I'm Tård again!

                                          I think we finally found the error in the script.

                                          When we add the overlay, we use this code:

                                          sprite(5).camera.addOverlay(t1, point(220, 220), 0)

                                          But when we create the list it doesn't create the variabels t1, t2 etc.?

                                          What is it we should write instead of "t1" ?

                                          This wouldn't be to hard, right?

                                          • 19. Re: help me with repeat while
                                            Tård Level 1
                                            Guys. I wanna thank you with all my heart. it works.

                                            You saved my week