Blockland Forums > General Discussion

How do you indent when you code?

Pages: << < (4/5) > >>

TheBlackParrot:

oh

--- Code: ---function hex (a)

if a then

str = "0123456789ABCDEF"
done = ""

for remainder = 1, 16 do

remainder = a - math.floor(a/16)*16

if a > 0 then

done = string.sub(str,remainder+1,remainder+1) .. done

end

a = math.floor(a/16)

end

return(done)

elseif not a then error("Invalid value in hex.")

end

end
--- End code ---
is how i prefer formatting lua.

Port:

Spaces, spaces everywhere!

package show_items_on_click
{
   function player::activateStuff( %this )
   {
      parent::activateStuff( %this );

      if ( !isObject( %cl = %this.getControllingClient() ) )
      {
         return;
      }

      %start = %this.getEyePoint();
      %direction = %this.getEyeVector();

      %path = vectorScale( %direction, 5 );
      %stop = vectorAdd( %start, %path );

      %ray = containerRayCast( %start, %stop, $TypeMasks::All, %this );
      %col = firstWord( %ray );

      if ( !isObject( %col ) )
      {
         return;
      }

      if ( !( %col.getType() & $TypeMasks::PlayerObjectType ) )
      {
         return;
      }

      %max = %col.getDataBlock().maxTools;

      for ( %i = 0 ; %i < %max ; %i++ )
      {
         %name = %col.tool[ %i ].uiName;

         if ( !strLen( %name ) )
         {
            return;
         }

         %items = %items @ ( strLen( %items ) ? "\n" : "" ) @ "\c3" @ %name;
      }

      if ( strLen( %items ) )
      {
         %cl.centerPrint( %items, 3 );
      }
      else
      {
         %cl.centerPrint( "\c3This player has no items.", 3 );
      }
   }
};

activatePackage( "show_items_on_click" );

Blocki:


--- Quote from: Port on November 18, 2012, 04:51:38 AM ---Spaces, spaces everywhere!
sdg<sdhsjdyrjkty<hrtjedjr
activatePackage( "show_items_on_click" );[/tt]

--- End quote ---
What's the benefit of spaces everywhere?

Port:


--- Quote from: Blocki on November 18, 2012, 08:29:03 AM ---What's the benefit of spaces everywhere?

--- End quote ---

What's the benefit of "function _(%a){return (%a+getrandom(0,10))%10;}"?

Reinforcements:


--- Quote from: Sheath on November 18, 2012, 01:38:41 AM ---Yeah its really bad practice.

But I hate how wasteful it is adding indents and spaces. It just looks so big. Perhaps its a bit of a weird OCD thing, I can't stand doing anything other than making it as condensed as possible. RAWR.

--- End quote ---
Believe me, if your script gets really complex, it NEEDS to be spacey. XD

Pages: << < (4/5) > >>

Go to full version