Fab a city... fabulous

Discussion in 'CraftScripts' started by echurchill, Jul 10, 2011.

  1. echurchill

    echurchill New Member

    A while back the kids wanted me to auto generated a building for them in Minecraft... things got a little out of hand and I ended up with a 100k WorldEdit script that create city blocks, parks, farms, sewers, cisterns, houses, and even parking garages. What you see below took about 10 minutes to make and most of that was walking to the next block before running the script again. :)
    [​IMG]
    If you are interested the script is up at https://github.com/echurchill/WorldEdit_City
    Remember to read the readme, but then again you knew that already :)
    One word of warning though, the script usually takes longer to execute than the default WorldEdit script timeout. If you get a timeout error when running this script, open "plugins/worldedit/config.yml" and change "timeout" value (should be under "Scripting") to 10000 (10 seconds?) or larger.
    Even with that change if you tried to do this the straight forward way this script would be very slow. If you look through the code you will notice two techniques I have found that speed things up. First I don't actually do the majority of the block manipulation using the get/setblock APIs, instead I use a Javascript cube array and then transpose it once everything is built. The second technique is during transcription I found that getting the block is much faster than setting it. So what I do is check to see if I really need to set the block before doing so (no sense setting the block to air if the block is already air). Finally, after the blocks have been placed I go back and place the special blocks (ladders, doors, trap_doors, flowers, etc.) since the physic engine sometimes gets confused if those blocks are placed before the block they are anchored against.​
    The code is pretty messy but mostly commented, but then again it is free :)
    One more warning... this is a very complicated script so make sure you use the Rhino script engine that sk89 refers to on this page http://wiki.sk89q.com/wiki/WorldEdit/Scripting the script will likely never end :)
  2. echurchill

    echurchill New Member

    From the readme at https://github.com/echurchill/WorldEdit_City
  3. echurchill

    echurchill New Member

    Well a video is worth a thousand pictures and a picture is worth a thousand words... so here are millions of words as a video
    http://www.youtube.com/watch?v=c79Djkb2-XQ
    (full disclosure: the video is running at 2x to speed things along)
  4. Sendao

    Sendao New Member

    That is seriously epic. Awesome job... I particularly like the sewers :)
  5. Kilrane

    Kilrane New Member

    My 2 cents: THIS IS SIMPLY AMAZ-ZA-ZING!
  6. magestickown

    magestickown New Member

    i cannot describe my feelings.

    this is amazing.
  7. mrvertigo27

    mrvertigo27 Member

    this looks absoloutly awesome!!!!!!!

    (havnt tried this in game yet but) I'm currious if pre flattened terain is needed or if it would just help
  8. echurchill

    echurchill New Member

    It will flatten things out as it goes. Actually the script does a rather interesting thing if the world isn't flattened. Climb on top of a hill or build a thing to stand on (say up to y=80) and generate the city. The city will actually have support columns reaching down from its underside of the cityblocks to "support" the city on top of the preexisting terrain. :) It adds a whole new area to explore.
    [​IMG]
  9. almostroot

    almostroot New Member

    This looks fantastically awesome, but I wasn't able to run the script. Using CraftBkkit build 1317 (1.8.1) and WorldEdit version 4.7.

    Here's the relevant output from server.log: http://pastebin.com/egLWCByC
  10. echurchill

    echurchill New Member

    Odd, I haven't see that before. A quick glance of the error message indicates that the problem "might" be located at line 2855. Which is odd as fab.js only has 2561 lines in it. I assume you are able to run the sample scripts that came with WorldEdit and installed the latest javascript engine (http://wiki.sk89q.com/wiki/WorldEdit/Installation/Bukkit). I will take a look at the problem this weekend.
  11. almostroot

    almostroot New Member

    Created a ridiculous maze with a fresh copy of Rhino just before trying.

    The version I grabbed from GitHub has 3272 lines according to wc -l. Line 2855 is the line that has a huge wall of code on it and contains the license etc. I tried running it through jslint, but it halts at line 50. Sadly, my Javascript-fu is non-existant.
  12. echurchill

    echurchill New Member

    Well that is odd too, when I click on fab.js up on github it comes up with the line numbers i mentioned. When I download the source file from github (via download zip on this page https://github.com/echurchill/WorldEdit_City/downloads) is also has the line number I mentioned.
  13. almostroot

    almostroot New Member

  14. RoyalBank

    RoyalBank New Member

    Worked Great Thanks. /undo didn't really do much, so I /restored anything that was out of place.
  15. nickbbeezy

    nickbbeezy New Member

    Doesn't let me undo.
  16. ryvix

    ryvix New Member

    This thing is awesome. People love it!

    I also cannot undo. But obviously you already know that.

    Also, I am wondering how I can change the size of lots to 16x16 rather than 22x22, for houses especially. But it would be nice to be able to change the city block sizes, and building dimensions, etc. I tried modifying the numbers in the code but then it crashes the server for some reason.
  17. Sajan

    Sajan New Member

    Brilliant Job And It's Working My Only Problem Was Timeout But Got That Fixed :)
  18. Da Frog on Wheels

    Da Frog on Wheels New Member

    Great stuff! A lot of fun. I've forked it and made a couple of minor improvements:
    * added carrots, potatoes (no version check)
    * fixed up undo (thanks sk89q for the pointer) ( added 'NOUNDO' option to run without ability to undo)
    * added chance of having 4 wheat to a row. (I need to tidy up that commit).

    https://github.com/frogonwheels/WorldEdit_City
  19. echurchill

    echurchill New Member

    Glad you are having fun with it. I will take a look at your changes.
  20. TNTCreeperKing

    TNTCreeperKing New Member

    When I use this I get a error that says:
    Failed to execute:
    illegally formed XML syntax
    (plugins\worldedit\craftscripts\fab.js#3076 in plugins\worldedit\craftscripts\fab.js at line number 3076

    Any idea someone please help me??!!
  21. Connor McCaffrey

    Connor McCaffrey New Member

    I get an error message saying:
    Failed to execute: missing ; before statement (C:\Users\MyName\AppData\Roaming\.minecraft\mods\spc\craftscripts\fab.js#1) in C:\Users\MyName\AppData\Roaming\.minecraft\mods\spc\craftscripts\fab.js at line number 1
    Please help me!!! it does it with every craftscript i have tried!!
  22. larry

    larry New Member

    I'm getting an error on line 3085. Here's the screenshot:

    [​IMG]

    Can you suggest a fix? I really want to try this out!

    --larry
  23. larry

    larry New Member

    I ran JSlint on that line and got "Unexpected <" error on line 3085. The line is so long though that there was no way for me to locate it!
  24. PseudoKnight

    PseudoKnight Well-Known Member Developer

  25. larry

    larry New Member

    I opened it a text editor and found that line 3085 is not only there but it is 781196 characters long! Here's a screen shot of the file:
    [​IMG]

    I will dl the file from the link you posted and compare. Perhaps there is a bogus copy floating around.
  26. larry

    larry New Member

    I just checked and yep, it is identical to the version I have, mystery line 3085 and all.
  27. PseudoKnight

    PseudoKnight Well-Known Member Developer

  28. larry

    larry New Member

    DOH! It all makes sense now, many thanks!
  29. larry

    larry New Member

    Installed and running. It's absolutely as awesome as everyone says!

    [​IMG]
  30. PseudoKnight

    PseudoKnight Well-Known Member Developer

    Neat. It's rather old, though. The same guy went on to turn it into a world generator, which has more features and was last updated in September:
    http://dev.bukkit.org/bukkit-plugins/cityworld/

    I used it once for an event on our server.
  31. larry

    larry New Member

    Wow, I have a lot to learn! Many thanks for the tip. I just brought up my first multiplayer server five days ago but luckily the learning curve is not really too bad so everything is running smoothly. Now the tasks are mostly creative - and fun.