Author Topic: How do you indent when you code?  (Read 1699 times)

oh
Code: [Select]
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
is how i prefer formatting lua.

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" );

Spaces, spaces everywhere!
sdg<sdhsjdyrjkty<hrtjedjr
activatePackage( "show_items_on_click" );[/tt]
What's the benefit of spaces everywhere?

What's the benefit of spaces everywhere?

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

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.
Believe me, if your script gets really complex, it NEEDS to be spacey. XD

i dont indent
sublime indents for me

but it turns out to be like
function blah()
{
   echo("blah");
}


but when i have to format myself...
}
   ;("hlab")oche

{
()halb noitcunf


IT AINT PRETTEH

allman style

Code: [Select]
void takeoutthegarbage()
{
cout << "look there's garbage i'm going to take it out\n";
}