Too Lazy for Indentating mah scripts

Too Lazy for Indentating mah scripts

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
Cubex
Posts: 56
Joined: 11 Jul 2012, 00:07

Too Lazy for Indentating mah scripts

Post 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 960 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
Attachments
Reindentator.zip
The program, extract and run py
(2.3 KiB) Downloaded 31 times
Last edited by Cubex on 10 Sep 2012, 06:18, edited 3 times in total.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Too Lazy for Indentating mah scripts

Post by PicassoCT »

i started out with the best of indentions...
User avatar
Cubex
Posts: 56
Joined: 11 Jul 2012, 00:07

Re: Too Lazy for Indentating mah scripts

Post 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
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Too Lazy for Indentating mah scripts

Post by PicassoCT »

okay its better... but in a python-paralle-pimension Picasso punishes the Perpetrator to pulp
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Too Lazy for Indentating mah scripts

Post by KDR_11k »

I knew we should have used Python. Indent or die!
User avatar
Cubex
Posts: 56
Joined: 11 Jul 2012, 00:07

Re: Too Lazy for Indentating mah scripts

Post 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
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Too Lazy for Indentating mah scripts

Post 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
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Too Lazy for Indentating mah scripts

Post by smoth »

Don't blame the language because a few users refuse to indent/properly format their code.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Too Lazy for Indentating mah scripts

Post by AF »

smoth wrote:Don't blame the language because a few users refuse to indent/properly format their code.
+1
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Too Lazy for Indentating mah scripts

Post 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!
Attachments
cubExed.7z
(855.24 KiB) Downloaded 68 times
screen00455.png
(1.82 MiB) Downloaded 2 times
User avatar
Cubex
Posts: 56
Joined: 11 Jul 2012, 00:07

Re: Too Lazy for Indentating mah scripts

Post 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
Post Reply

Return to “Game Development”