Page 1 of 1

Too Lazy for Indentating mah scripts

Posted: 08 Sep 2012, 19:43
by Cubex
Yes, there are alot of spring scripts, and probably you find that (hopefully not much) some of them have a very hard to read indentation (or none) and you will find yourself trying to decrypt that code while preparing your evil plan for killing the lazy programmer that didn't care his indentations

BUT NOW there is a partial solution for this problem, Cubex presents:

The Reindentator!

This Python written script will get a Source folder (yes a folder, for doing it automatically instead of one by one :D) and a Destination folder, then will proceed to walk across the files to find any lua script and will try to replace his indentation for a freshly automatic generated one :) saving you hours and hours of eye bleedings

Why? well, cause i tried to read PicassoCT made lua script's, they are with too badly indented and I am too lazy for reindenting all myself
My face while reading bad indented scripts
My face while reading bad indented scripts
oh-PCT-why.png (25.54 KiB) Viewed 1178 times
WARNING! This script is nowhere near safe, it can containg undiscovered bug and behaviors, I tested myself with some badly indented scripts and works almost all cases, if you got "[ERROR] Negative Depth! Line...blablabla" means that my script can't resolve it or there is some missing end (don't trust, sometimes fails even with good if - end pairs :/, in case of failure the original file is copied to Dest folder without any modification)

tl;dr

Program for Reindenting scripts, Don't try to reindent a corretly indented script. Ony for emergency cases

How to use:

Needs Python 3 (Tested with Python 3.2, not sure if works with 2.x, but is sould...)

open console, run program with Reindentator.py and see help text

Lua Disclamer:
Cubex not harmed any lua script in the creation of this script

Re: Too Lazy for Indentating mah scripts

Posted: 08 Sep 2012, 21:42
by PicassoCT
i started out with the best of indentions...

Re: Too Lazy for Indentating mah scripts

Posted: 08 Sep 2012, 21:48
by Cubex
PicassoCT wrote:i started out with the best of indentions...
If you can make those good 3d models im sure that you can put a little indention in make it more easily to read

(don't take meme too seriously)

=EDIT=

Here you can see the difference betwen your Original script and a Parsed one

http://pastebin.com/KPn9f8QE

Re: Too Lazy for Indentating mah scripts

Posted: 08 Sep 2012, 23:36
by PicassoCT
okay its better... but in a python-paralle-pimension Picasso punishes the Perpetrator to pulp

Re: Too Lazy for Indentating mah scripts

Posted: 09 Sep 2012, 15:50
by KDR_11k
I knew we should have used Python. Indent or die!

Re: Too Lazy for Indentating mah scripts

Posted: 09 Sep 2012, 17:08
by Cubex
They say that python isn't good idea for Spring due to its slowness :cry: but i would be happy to see some gadgets be able with classes or some python nice features

Re: Too Lazy for Indentating mah scripts

Posted: 09 Sep 2012, 21:29
by gajop
Cubex wrote:They say that python isn't good idea for Spring due to its slowness :cry: but i would be happy to see some gadgets be able with classes or some python nice features
classes: https://github.com/Yonaba/Lua-Class-System

Re: Too Lazy for Indentating mah scripts

Posted: 09 Sep 2012, 22:17
by smoth
Don't blame the language because a few users refuse to indent/properly format their code.

Re: Too Lazy for Indentating mah scripts

Posted: 10 Sep 2012, 01:39
by AF
smoth wrote:Don't blame the language because a few users refuse to indent/properly format their code.
+1

Re: Too Lazy for Indentating mah scripts

Posted: 10 Sep 2012, 02:02
by PicassoCT
Too lazy to texture my own modells? Summone certainly is..

http://springrts.com/phpbb/download/fil ... ew&id=7538

Too lazy to downseizure the BandwithBunkerBusters? Someone curtainly is..
Image

Well, there i was under the impression that - having each and everyone a own project at heart- you used the indention to skip reading into some other guys code.. but i was so wrong. Now after releas.. a endless queue has formed at the checkout of the journeywar repository.

Oh, wait no.. thats people leaving.. running.. strange phenomena. One even filed the newest phail of mine.. what have we here.
"Cant read code, if not presented in comic sans."
Guess that cant be helped.
One man project? One Man project!

Re: Too Lazy for Indentating mah scripts

Posted: 10 Sep 2012, 06:15
by Cubex
==About lua classes==
I can live with tables for now ...

==About model==
Good work :mrgreen: soon will appear in my game with connected nodes 8) but why you posted in a thread about lua :roll: someone invented PM's