Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    what is your favorite keyword or statement in fuze

    Coding
    7
    10
    570
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      petermeisenstein F last edited by

      I like loop and strcontains()

      1 Reply Last reply Reply Quote 0
      • vinicity
        vinicity F last edited by vinicity

        I found this in one of the programs from Nisse5, and thought it was incredibly neat. I have started using this myself in a number of places.

        var t = 0
        loop
          coords = [{1, 5}, {4, 2}, {9, 4}][t % 3]
          // do stuff
          t += 1
        repeat
        
        

        This way, you are defining your array and doing all the selecting stuff in just one line of code.
        So coords will have a new set of coordinates every loop, first {1, 5}, then {4, 2}, {9, 4}, {1, 5}, {4, 2}, etc.

        PickleCatStars 1 Reply Last reply Reply Quote 1
        • PickleCatStars
          PickleCatStars F @vinicity last edited by

          @vinicity said in what is your favorite keyword or statement in fuze:

          I found this in one of the programs from Nisse5, and thought it was incredibly neat. I have started using this myself in a number of places.

          var t
          loop
            t += 1
            coords = [{1, 5}, {4, 2}, {9, 4}][t % 3]
            // do stuff
          repeat
          
          

          This way, you are defining your array and doing all the selecting stuff in just one line of code.
          So coords will have a new set of coordinates every loop, first {1, 5}, then {4, 2}, {9, 4}, {1, 5}, {4, 2}, etc.

          So a line x = [1,2,3][0] just sets x to 1?

          vinicity 1 Reply Last reply Reply Quote 0
          • vinicity
            vinicity F @PickleCatStars last edited by

            @toxibunny said in what is your favorite keyword or statement in fuze:

            @vinicity said in what is your favorite keyword or statement in fuze:

            I found this in one of the programs from Nisse5, and thought it was incredibly neat. I have started using this myself in a number of places.

            var t
            loop
              t += 1
              coords = [{1, 5}, {4, 2}, {9, 4}][t % 3]
              // do stuff
            repeat
            
            

            This way, you are defining your array and doing all the selecting stuff in just one line of code.
            So coords will have a new set of coordinates every loop, first {1, 5}, then {4, 2}, {9, 4}, {1, 5}, {4, 2}, etc.

            So a line x = [1,2,3][0] just sets x to 1?

            Exactly. Neat, huh?

            1 Reply Last reply Reply Quote 1
            • Martin
              Martin Fuze Team last edited by Martin

              So does x = 1 :D

              (And yes, I know that's not what you're getting at)

              [EDIT] PS: There are times when it's better to be clear in code than clever. When something crosses the line is entirely down to personal taste but if anyone has to think too hard about what the above is doing then I'd strongly suggest that it's one of those times. If you glance at that and it's second nature that you immediately realise what it's doing then knock yourself out, but don't expect it to be readable to everyone.

              1 Reply Last reply Reply Quote 2
              • Martin
                Martin Fuze Team last edited by Martin

                I'm going to follow up on that so that my reply doesn't come across as too harsh! It's certainly great to hear about these kind of ways of working, or tricks if you will.

                Firstly, from a user point of view because it might simply be something you've not thought of before and it will very soon become second nature and advance your programming skills. I remember someone showed me something about 'malloc' in C about 20 years ago and I thought it was so neat and concise that I still use it to this day.

                Secondly, from a Fuze internal point of view, it might highlight that users are using something in a way that might not of been considered before and it could highlight potential issues, or indeed if something is really obscure it could help shed some light on why some issue is already happening and help us provide a workaround until a fix can be put in place.

                1 Reply Last reply Reply Quote 1
                • PickleCatStars
                  PickleCatStars F last edited by PickleCatStars

                  It was a bit hard to figure out - I thought it was just a % mod example at first..

                  Handy to know you can create a list and use it all in the same line though :) I’m thinking it might be useful for menus maybe? Save a bit of space or something..

                  Back on topic, my favourite So far is the terrain stuff. Especially since I found out you can have more than one. They’re user-creatable 3D Objects! Also I used reflect() the other day and it worked just as advertised. Really neat! Dot() and cross() are great too, though you need to google to find out what they’re really for...

                  1 Reply Last reply Reply Quote 2
                  • Gothon
                    Gothon F last edited by

                    I don't have one favorite keyword but several:

                    • createImage()
                    • setDrawTarget()
                    • drawQuad()or drawImage() / DrawImageEx()
                    • setBlend()
                    • simple drawing commands like: triangle()/ line() / plot() / circle()

                    I like these commands not because of how any of them work individually but rather because of the various ways I can combine them to do amazing things. That is how I believe programming is supposed to work; you have a small number of simple pieces that you can combine together in arbitrary ways to make incredible creations.

                    1 Reply Last reply Reply Quote 4
                    • PB____
                      PB____ last edited by PB____

                      I like to use a double not operator (!!) which basically converts to a boolean value:

                      !(false) == true
                      !true == false
                      0 == false
                      1 == true
                      !0 == true
                      !1 == false
                      !2 == false
                      !(!1) == true
                      !!2 == true
                      !!2 == 1
                      !!1 == 1
                      !!0 == 0
                      

                      I do think there are plenty of developers who are not aware this, so they might need to think thrice before they understand what's happening. So it one to use with care. But provided that you work with a loosely typed environment, I think it's an elegant and compact way to constrain a value as boolean.

                      1 Reply Last reply Reply Quote 2
                      • Ben 2.0
                        Ben 2.0 last edited by

                        I personally use gwidth() and gheight() a lot and they are very useful, but setdrawtarget() opens up a lot of fun possibilities.

                        1 Reply Last reply Reply Quote 2
                        • First post
                          Last post