This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
moomoomoo3O9's profile picture

WorldEdit - Now with NBT support for command computers!

Started by moomoomoo3O9, 25 January 2014 - 12:16 PM
moomoomoo3O9 #1
Posted 25 January 2014 - 01:16 PM
Anyone who has used WorldEdit in the past should know what this program does. It selects the two opposite corners in a 3d (or 2d) area and can use that selection to fill, replace, or perform other operations on it.

This program requires The Adventure Map Interface from Immibis's Peripherals, or a Command Computer.

This program has also been uploaded to the CCSystems App Store called "WorldEdit".

To use it, simply run the program, and type commands into chat, enter them on the computer, or download the rednet companion on a pocket computer, connect a wireless modem to the command computer and run the rednet companion (You will need to allow the ID on the computer itself first!) and type them on the pocket computer.

Some of the supported commands are: (from WorldEdit/Reference)

Commands
  • hpos1 and hpos2 (select the block you're looking at, it's functionally identical to the wand)
  • pos1 and pos2 (select the block you're standing on, not above like WorldEdit's)
  • set (sets the block(s) in the selection to the block(s) specified.)
  • replace (replaces the block(s) in the first argument with the block(s) in the second argument.)
  • expand (expands the selection in the direction you're looking)
  • contract (shrinks the selection in the direction you're looking)
  • outset (expands the selection in all directions by the specified amount)
  • inset (shrinks the selection in all directions by the specified amount)
  • sel (clears selection)
  • chunk (selects the chunk you're in)
  • shift (shifts the selection in the direction you're looking)
  • copy (copies the selection into your clipboard)
  • rotate (rotates what's in your clipboard 90, 180, or 270 degrees on any axis)
  • paste (puts your clipboard into the world)
  • save (saves your clipboard to a file in WE/Schematics/[filename])
  • load (loads a clipboard from WE/Schematics/[filename])
  • move (moves your selection)
  • stack (duplicates your selection in the direction you're looking in)
  • help (lists commands and gives a description of each command)
  • refresh (updates WE_Sel, WE_Clipboard, WE_Cuboid, and GeneralAPI)
  • reboot (reboots the computer)
  • terminate (ends the program)
  • endchatspam (turns off command block output)
  • distr (gets the distribution of the blocks in the selection)
  • count (counts the instances of a block in the selection)
  • size (prints the size of the selection)

MediaWorldEdit setup video (How to set up the command computer and rednet companion)
[media]http://www.youtube.com/watch?v=tr30Tmo4L3E[/media]
The resource pack is my custom pack based on Dokucraft High, with ComputerCraft support added in. My apologies for my model M being ungodly loud.

How to install: pastebin run ku1FHyEW

Note:

Don't put "//" before the commands, just say them in chat or on the computer, or on a pocket computer. Saying "pos1" will select the first position at your feet, for example.

TODO:
  • Add support for the schematic format (and Worldporter's format, if requested?)
  • Make the region operations in sel work with concave polygons –IN PROGRESS
  • Implement Polygon selection –Some day, I will get exlted to make a functional build of this…
  • Implement ellipsoid selection –And then this…
Program downloads:
Installer Pastebin ID: ku1FHyEW
Core Program
Cuboid Operations
Selection Operations
Clipboard Operations
GeneralAPI
ConfigAPI
Rednet Companion Pastebin ID: BEAfiM52

If anyone wants to help me in this program, PM me and I'll gladly collaborate. Any ideas or suggestions would be appreciated.

Special thanks to exlted for rewriting half of my messy code with me and doing most of the WIP work on polygon selection, to Lyqyd for lsh, Wergat for his amazing code to get the player's looking vector, and bwhodle for his config API.


Changelog(1.6) May 17th, 2017: Moved to a plugin-based system, migrated to GitHub. See commit history for more details.
(1.5.1) July 24th, 2016: Sped up all scanning of blocks, added list, rotate, exportVar, deepCopy, deepCut. Changed copy/cut to not include NBT data.
(1.5) May 31st, 2016: Added NBT support to the command computer, implemented hpos on command computers. Sped up set and replace further.
(1.4.1) May 29th, 2016: Added rednet and direct command input, removing chat box requirement, sped up set
(1.4) December 31, 2015: Re-enabled NBT support for the Adventure Map Interface, Added configs. Paths can be changed for all files properly.
(1.3.1) July 31, 2015: Added hacky support to change paths for other programs. Will be implemented better later.
(1.3.0) July 15, 2015: Ported to command computers in a stable manner. hpos1 and hpos2 do not work on command computers. Requires some type of chat box.
(1.2.1) June 29, 2015: Added help.
(1.2.0) May 24, 2015: WE_Clipboard finally released. reboot, refresh, and terminate added. There is always hope.
(1.1.2) May 18, 2015: Quality of life changes. No major changes. First release dependent upon GeneralAPI.
(1.1.1) March 4, 2015: Program will wait until it finds an adventure map interface. First version uploaded to the app store.
February 21, 2015: Did all the things. Fixed everything but WE_Clipboard, because it's a lost cause.
May 30, 2014: Added //shift.
May 30, 2014: Added chat feedback for all commands and implemented //chunk.
May 29, 2014: Ninja edit 2 because I derped and made it say the coordinates for the first position when doing pos2.
May 29, 2014: Ninja edit fixing replace because I forgot tonumber() (First completely functional release?)
May 29, 2014: First completely functional release!
Edited on 06 July 2018 - 09:25 PM
andyoc #2
Posted 27 January 2014 - 05:11 PM
been playing about with this add-on recently currently working on a quarry ("for learning purposes") interested in this script mate will have a proper look tommorrow and would be happy to help if i can make any adjustments to your code :)/>
moomoomoo3O9 #3
Posted 27 January 2014 - 09:14 PM
been playing about with this add-on recently currently working on a quarry ("for learning purposes") interested in this script mate will have a proper look tommorrow and would be happy to help if i can make any adjustments to your code :)/>
Sounds great! I've got the percentage handler written, so implementing it shouldn't be too bad, and I've got pretty good progress on implementation so far, so you don't need to worry about the percentages too badly.
I'm just worried about the implementation of the copy/pasting as the files created from it could get massive very quickly, whereas moving or stacking could just use relative coordinates to copy the blocks without that problem
Selection operations shouldn't be too bad to implement, I just haven't gotten around to them.
In case you're curious about the Percentage handler:
[Defunct link]
Note: This handler is designed to be usable in the Online Lua Interpreter.
Beta Versions of programs: (These have NEVER been tested in-game)
[Defunct links]
Edited on 29 May 2014 - 07:15 PM
andyoc #4
Posted 28 January 2014 - 03:46 PM
just looked through pretty solid code could not get to load 1 miner adjustment at line 114 in your world_edit master file "dend" instead of end still cannot get it to work though i can get it to see 2 points but when I come to set which I presume has only 1 argument example set 1 it crashes with this error message :-
(WorldEdit_Master:103: attempt to perform arithmetic__sub on nil and number)

hows about after selecting the second slot an information message to help people use the set/replace programs

also when I use replace example replace 1 2 I get don't add extra arguments or spaces
moomoomoo3O9 #5
Posted 28 January 2014 - 03:59 PM
just looked through pretty solid code could not get to load 1 miner adjustment at line 114 in your world_edit master file "dend" instead of end still cannot get it to work though i can get it to see 2 points but when I come to set which I presume has only 1 argument example set 1 it crashes with this error message :-
(WorldEdit_Master:103: attempt to perform arithmetic__sub on nil and number)

hows about after selecting the second slot an information message to help people use the set/replace programs

also when I use replace example replace 1 2 I get don't add extra arguments or spaces
…This is what I get for not testing my code in-game after making last-minute adjustments.
I'll fix it when I release percentage support which is mostly done, also, until percentage support is implemented, the arguments are username,x1,y1,z1,x2,y2,z2,block,meta and block2,meta2 for replace. When the percentages are implemented, your arguments will be correct.

Thanks for the feedback, I'll make sure to use something like #tArgs to print the syntax out so that doesn't happen.
Edited on 28 January 2014 - 04:14 PM
andyoc #6
Posted 28 January 2014 - 07:19 PM
so even though we use hpos1 and hpos2 to get the first and second coords i still have to type in the coords it is late here and i am going off but here is the pastebin of the quarry very messy code i have started to clean it up but not that much in case there's anything you can use or can help me with

http://pastebin.com/cm4xAfQn
also need the "NBTAPI"
http://pastebin.com/MtRsKEeK


i am as far as implementing the second chest incase you run out of storage on the first
Edited on 28 January 2014 - 06:20 PM
moomoomoo3O9 #7
Posted 28 January 2014 - 07:48 PM
If you want to try to implement hpos into your code, here's the standalone version of hpos I tested before I put it in the program (It works perfectly, I just modified it and basically just copied and pasted it into the WE_Chat program)
https://dl.dropboxusercontent.com/u/46304817/CC%20Programs/WorldEdit/Defunct%20%28Buggy%20as%20hell%21%29/getLooking.lua

And for your code, it's a quarry that mines sandstone and stone? Sounds like it could be modularized more, such as reading a block table from a file or supporting arguments. I could see some annoyingly complicated table logic in order to get it to work with any block, but I can't work on it right now. I'll see what I can do with it.
Edited on 29 May 2014 - 07:15 PM
andyoc #8
Posted 29 January 2014 - 01:13 PM
yes i am implementing it all bit by bit first of all i was looking at them blocks because it was the only blocks in a creative world i will implement a file p.s you should know this was only for testing purposes i downloaded immibus and it was the first thing i could think of creating so here i am

thanks for the bit of code i will look at implementing it and have a look through for tips on coding my own :)/>. are there any updates for testing yet?


i would like to create an staged adventure/challenge map enentualy using immibus AM computer that creates a puzzle/level for solving and and can detect it solved then create the next block/chunk/challenge
Edited on 29 January 2014 - 12:16 PM
moomoomoo3O9 #9
Posted 29 January 2014 - 04:44 PM
As for new code, It's a slow progress, as I might have to rewrite set and replace to get percentages implemented because right now the version I have does nothing, no matter what arguments you give it, so I have a lot of fixing to do.
andyoc #10
Posted 29 January 2014 - 05:26 PM
I do be-leave I have the same version. Anyway if there is anything I can help with send me a message or reply I will keep an eye on the post for updates good luck

p.s when you say percentages what do you mean am i wrong in thinking you just "/total blocks by 100 then times by lets say 30 if they want lets say 30% Stone 70% dirt" then just randomise the 2 or is it more difficult then that?
moomoomoo3O9 #11
Posted 29 January 2014 - 05:30 PM
It's basically add up the percentages and use a fraction of Percentage/TotalPercentage to calculate probability. If I get it to work, it should work exactly as worldedit's does. This means the percentage could add up to anything and it will still work, and you can use multiple block types without percentages (when I get it working properly) like 5,6,7,3,1 will do blocks 1, 3, 5, 6, and 7 even without a percentage. I might just fix up the pastebinned version so I can get out a functioning build.

edit: OP edited with stable versions which support block:meta (so set x1 y1 z1 x2 y2 z2 24:1 will work now)
edit2:Percentages come later…
Edited on 29 January 2014 - 04:52 PM
andyoc #12
Posted 30 January 2014 - 01:29 PM
do we still need to put x1 y1 z1 x2 y2 z2 or is hpos working?
moomoomoo3O9 #13
Posted 30 January 2014 - 05:50 PM
hpos was always working, the only problem was before it didn't support block:meta so you had to write set 1 0 to set a block of stone, but now you can type either 1:0 or 1 and it will fill in the 0.

edit: For clarity:
hpos was always working, but when I talked about the arguments earlier, I meant running the set program yourself, not using WE_Chat in conjunction with it. When using WE_Chat with it, the arguments should be identical, but with the omission of the coordinates.
Edited on 01 February 2014 - 03:04 PM
andyoc #14
Posted 02 February 2014 - 01:44 PM
I need your help moo so you know i was working on the immibus quarry right well successfully built it up so now it mines all vanilla blocks but the problem I face is that it always chucks the quarry out to the north I looked into and tried to get it to work myself without prevail and took a look at your getLooking Program if you wrote that it is a little to advanced for me I know nothing about directional vectors and such would it be possible for you to write me a bit of code that tells me simply which way I'm facing as I open the computer or place down the computer any of the above would be great and would most certainly be greatly appreciated
moomoomoo3O9 #15
Posted 02 February 2014 - 05:41 PM
For cardinal directions, you need to check the X and Z values and check between 0.5 and 1, and Y is the same. The only reason Y doesn't check between 0 and 1 or 0 and -1 is because then it would always say Up/Down, so it only checks 0.15 plus or minus 1 or -1.
My Little program for it:
getDirection
If you used 0.25 instead of 0.5 ranges and then checked in between those, you could get North West, South East and such.
Edited on 02 February 2014 - 04:42 PM
moomoomoo3O9 #16
Posted 11 February 2014 - 10:11 PM
Updates!
Set is pretty stable, if anyone wants to test the percentages and try to break it so I can fix it, feel free. Replace does not work yet, but I'll post the non-working version anyway because I'm done for today.
[Defunct Links]

Edit: For myself later (Maybe someone can use this?) Edit: I used it for rewriting :D/>/>
WAAAY Later Edit 2: I modified this into string.split(). I'll put it in here.

Replace_Handler (Splits 24,46,47,474,37,24

message="23,27,41,68,52,69" --Replace with any entries, these are just examples
Blocks2={}
findComma,findCommaEnd=string.find(message, ",")
table.insert(Blocks2, string.sub(message, 1,findComma-1))
repeat
  findComma2,findComma2End=string.find(message, ",", findComma+1)
  if findComma2~=nil then
	table.insert(Blocks2, string.sub(message, findComma+1,findComma2-1))
	findComma=findComma2
  end
until findComma2==nil
table.insert(Blocks2, string.sub(message, findComma+1))
for i=1,#Blocks2 do
  print(Blocks2[i])
end
string.split()

function string.split(str,char)
  tbl={}
  if char=="%" then --Curse you, Lua patterns!
	char="%%"
  end
  findChar,findCharEnd=str:find(char)
  if findChar then
	table.insert(tbl,str:sub(1,findChar-1))
	repeat
	  findChar2,findChar2End=string.find(str, char, findChar+1)
	  if findChar2~=nil then
		table.insert(tbl,string.sub(str, findChar+1,findChar2-1))
		findChar=findChar2
	  end
	until findChar2==nil
	table.insert(tbl,str:sub(findChar+1))
  else
	tbl={str}
  end
  return tbl
end
Edited on 19 March 2015 - 11:45 PM
moomoomoo3O9 #17
Posted 23 February 2014 - 02:54 PM
After a (very long due to procrastination and multiple failures) delay, I have finally finished implementing Percentages into the Set and Replace programs. Take 'em off of pastebin in the OP, I just updated it.

What this means:
replace 10:1,20,30,40 25%1,37%2:1 will replace blocks 10:1 (block ID 10, metadata 1), 20, 30, and 40 (20, 30, and 40 work with any meta) with a 25/62 chance of block 1, and a 37/62 chance of block 2:1.
set 25%1,37%2:1
Set works the same, but without the 10-40 part, making it set it with 37/62 chance of block 2:1 and 25/62 chance of block 1.

Obviously, the rest still works, you can still just type "set 0" to set the selection to air or use "replace 98 89" to replace 98 with 89.

Have fun WorldEditing!
biggest yikes #18
Posted 23 February 2014 - 03:19 PM
Best thing I've seen in a while.
Nice job!
moomoomoo3O9 #19
Posted 03 March 2014 - 12:32 AM
Next up for this program is implementing the names of blocks in WorldEdit, taken straight from here!
Here it is in a nice, neat Lua table in case anyone wants it. (The block id is 1 less than the table entry, so block 136 is the 137th entry in the table due to air being a block)
edit: This feature is now implemented in my test version, however, I need to fix a few bugs in both of the programs involving the way the strings are split up, so the release will be delayed for a while.
Edited on 29 May 2015 - 12:38 AM
moomoomoo3O9 #20
Posted 29 May 2014 - 09:08 PM
Hello, hello, hello Computercrafters! I am back from a two month absence and I have finally gotten the program to work due to the cooperative efforts of my friend exlted! (credit is given in the program ;)/> )
Now the program's an installer, which installs the two required programs.
Happy worldediting!

Edit: Unlike previous versions, I have actually extensively tested this, and confirmed its functionality! Feel free, however, to test its functionality yourself, and send bug reports my way should they be needed.
Edited on 29 May 2014 - 07:13 PM
exlted #21
Posted 31 May 2014 - 04:46 AM
Glad to help, if there are any questions on the codebase or about individual sections both of us are available to answer questions either here or in PM. If you want individual functions seperated out and released for download, just ask we can easily release any individual section of the code annotated to be as easy to understand as possible
Geforce Fan #22
Posted 17 June 2014 - 06:58 AM
Replace command is broken on this.
edit: nevermind. I forgot to specify the blocks
You need a copy command, though. Also how about storing builds on files?
Edited on 17 June 2014 - 05:25 AM
moomoomoo3O9 #23
Posted 17 June 2014 - 06:04 PM
You need a copy command, though. Also how about storing builds on files?
Well, I'm planning on storing the clipboard in files and having the export command, it's just that I haven't had the time to code it, plus given that I'd also have to read/write the NBT data on each block, it might make some pretty massive files.

So, I will get to it eventually, but it may be very slow to work or it might take a while for me to code.

Edit: But I will start coding it today, I haven't really touched the code since the 30th, so I should start now.
Edit2: First draft of the code is written, but 100% untested. If you'd like a beta version, here you go.
Edit3: This code never worked. I don't know why I didn't remove/update it at any point
Edited on 18 July 2015 - 07:14 PM
exlted #24
Posted 17 February 2015 - 04:15 AM
We apologize for the delay in updates (for all the maybe two people in the world who care)
Moo and I got distracted by other projects and have just recently gotten back onto this project
Today we fixed the brokeness of the main program and also have built up Polygon Select to a point of theoretical completeness, to implement this selection into the main program we will need to do some recoding of WE Core so after getting through testing of Polygon Select it might be ~3 weeks from today for an actual update to the public build of the program.
There might be a good build pushed sooner than that without copy or poly, but don't hold your breath, but overall not much has changed.
We bid you a good night, day, afternoon or whatever
exlted, Moo
moomoomoo3O9 #25
Posted 21 February 2015 - 07:12 PM
Here's a stable release for you guys. Use the installer or the files themselves from the OP.

What's changed?
  • Block blacklist is now a table.
  • the weird way I accessed WE_Commands through core is now fixed to make more sense
  • WE_Commands split into WE_Cuboid and WE_Sel so that the Cuboid only functions are separate.
  • set now says the correct number of blocks changed.
  • getDirection now works properly on north and south.
  • All parts of the main loop have been put into functions (like hpos1)
  • round() has been renamed to math.round() because that makes way more sense.
  • shift, expand, and contract now work without a provided direction.
  • shift, expand, and contract now give more informative output.
  • I have given up on WE_Clipboard until I can find a release where NBT works (It hasn't worked since CC 1.58 from my testing)
  • hpos1 and hpos2 are much more accurate due to player coordinates not being rounded
  • The selection is no longer generated on calling set/replace, it is now stored in a table (making way for poly)
  • Immibis's NBT API won't be included in my programs, but instead in a separate file if and when WE_Clipboard works.
  • Probably more stuff, but that's all I could think of.
Edited on 29 May 2015 - 12:39 AM
Geforce Fan #26
Posted 22 February 2015 - 03:24 AM
you should rewrite this for command computers
moomoomoo3O9 #27
Posted 24 February 2015 - 02:42 AM
Speedwise, it would be way way slower, but to make it work with command computers requires one thing that I would need to get: I would need ANOTHER freaking table with all of the block names in it, except the numerical index would have to correspond to the name of the block "minecraft:stone" or something of the sort. (To be honest, I'll need to do this eventually either way, I just really don't want to) Then, all I'd need to do is check if it's a command computer and if it doesn't find an adventure map interface, write a handful of functions/pointers which do the setting and replacing of the blocks.

Also, is there any way to get chat or the way the player is looking with a command computer? I can't find any way of doing that. Without those, you couldn't run any commands, and hpos isn't implementable.


TL;DR Give me a way to get chat and a way to see where the player is looking with the command computer and I'll try it. (I'm actually interested in trying it, but I need those things before I do, because it wouldn't be super hard to do if I can implement it 100%, I just need to change a couple method names)

Edit 1: If I feel rather inspired, I may tackle it using the Peripherals++ or Computronics Chat Box, and get the username and chat from players that way. hpos is still not implementable without the player's direction vector, which I doubt anything else will give me.

Edit 2: The links in the OP were leading to a 404 because I derped. Fixed!
Edited on 24 February 2015 - 02:04 AM
DannySMc #28
Posted 03 March 2015 - 04:04 PM
This is awesome, could you upload this on my app store please? check my profile for the link the to the app store thread.
moomoomoo3O9 #29
Posted 06 March 2015 - 04:01 PM
This is awesome, could you upload this on my app store please? check my profile for the link the to the app store thread.
Sure, I just need to push one feature I completely forgot about first. (It doesn't throw an error if it doesn't find the adventure map interface!)

edit: Done. Installed on the app store, and removed a bunch of dead code and code that is not yet ready to see the light of day, and updated OP with a link to the app store.
Edited on 06 March 2015 - 03:59 PM
DannySMc #30
Posted 06 March 2015 - 05:16 PM
This is awesome, could you upload this on my app store please? check my profile for the link the to the app store thread.
Sure, I just need to push one feature I completely forgot about first. (It doesn't throw an error if it doesn't find the adventure map interface!)

edit: Done. Installed on the app store, and removed a bunch of dead code and code that is not yet ready to see the light of day, and updated OP with a link to the app store.

If you want to add a quick link to your app, on the app store: click menu -> click apps -> click all -> find your program -> click it -> then see the 8 character code at the bottom? you can use the code in the search to go straight to your app?:D/> and it allows you to install apps via the command line :P/> and thanks for the link!
moomoomoo3O9 #31
Posted 06 March 2015 - 05:29 PM
This is awesome, could you upload this on my app store please? check my profile for the link the to the app store thread.
Sure, I just need to push one feature I completely forgot about first. (It doesn't throw an error if it doesn't find the adventure map interface!)

edit: Done. Installed on the app store, and removed a bunch of dead code and code that is not yet ready to see the light of day, and updated OP with a link to the app store.

If you want to add a quick link to your app, on the app store: click menu -> click apps -> click all -> find your program -> click it -> then see the 8 character code at the bottom? you can use the code in the search to go straight to your app? :D/> and it allows you to install apps via the command line :P/> and thanks for the link!
No problem. Code added to the OP. If I'm using your store, I see no reason why I wouldn't recognize that here :)/>
DannySMc #32
Posted 06 March 2015 - 06:52 PM
Well it's not going far, and I think it's awsome! So the more people that see it the more people that will use it :P/>
moomoomoo3O9 #33
Posted 19 May 2015 - 01:08 AM
I'm pushing version 1.1.2, as development is going somewhat slowly, but theres some usability stuffs added since last release.
The direction now is to finish Poly development, then release it along with a command shell I've (mostly) written after the polygon selection is done and merged with WE_Core.

What's changed:
  • WE_Cuboid now actually prints all of its text correctly, and the text is more informative.
  • All selection operations print the size of the selection in parentheses.
  • My GeneralAPI is now a dependency. As a result, more of the functions should have better error handling. Not everything has been moved over yet.
  • Overlay and Naturalize should now work correctly. (I must have been sleep deprived when I wrote them originally…) This means everything in WE_Sel will work with all selection types when Poly is added.
  • All of minecraft's localized and unlocalized names have been added to the BlockNames table. (So, the name in f3+h for a block will definitely work now in addition to the name on English (US)!)
  • The BlockNames table is now indexed by Block ID instead of Block ID+1, but must now be iterated through with pairs() or ipairs()
The installation is the same. Just run WE_Installer.
moomoomoo3O9 #34
Posted 24 May 2015 - 04:31 PM
I didn't think I would've done it, but I did. Here is the release of WE_Clipboard, and by extension, version 1.2.0!
What's changed:
  • Percentages now work correctly. (I fixed one thing and broke another last version)
  • WE_Clipboard has finally been released in a semi-stable manner!
  • Copy, save, load, paste, stack, and move have been added.
  • Any blocks with NBT data will be copied correctly, unless you are on CC 1.64 or CC 1.65. (If someone knows how I can detect if someone's on CC 1.64, let me know. I could if the computer was a turtle, but that's a stupid requirement to add for this program, and os.version() will only return 1.6 or 1.7) /rom/help/changelog
  • refresh command added. This command runs all of the other programs other than core, allowing you to change code on the fly without rebooting.
  • reboot command added. This reboots the computer running WE_Core.
  • terminate command added. This ends the program.
Edited on 27 May 2015 - 06:10 PM
moomoomoo3O9 #35
Posted 22 June 2015 - 01:04 AM
I thought some more on how to get the command block version working, if it's possible. So, using the peripherals++ or moarperipherals chat box, I can get chat. Using command blocks, I can set/replace blocks. Now, my problem is that I cannot find where the player is looking. The only way I can think of doing this is as follows, and bear with me, I won't actually do this:
  • Place a computer and a sensor (from OpenCCSensors or OpenPeripherals) near the player somewhere (within the scanning radius)
  • Make sure the computer placed has the same ID as the computer running the program (not a problem)
  • write the data to a file
  • destroy the computer and the sensor
  • stare, mouth agape at the pure stupidity that you just witnessed as it prints out the correct block you were looking at.
If anyone can think of a good way to find the pitch/yaw or something of the sort that I can use to figure out which block the player is looking at, I'm all ears.
Edited on 21 June 2015 - 11:07 PM
moomoomoo3O9 #36
Posted 30 June 2015 - 02:39 AM
(Very) Minor update 1.2.1 released.
  • Added the help command.
I think this warranted a release without me touching any other features because I should have written it a long time ago. Post any feedback you have about my help text.
moomoomoo3O9 #37
Posted 16 July 2015 - 12:02 AM
Major update 1.3.0 released. The changelog isn't going to be too large, but it's a big update.
Changes:
  • Added support for Command Computers. Everything but getDirection("self") and hpos1 and 2 works.
  • Rewrote almost every command to add that support.
  • added "endchatspam" command. runs "/gamemode commandBlockOutput false"
This one may need some testing from the community. It's a very big update, and I may have left a bug or two around, though I did test pretty extensively. Let me know if you find any.

edit: Should this be moved to command programs? It works with the Adventure Map Interface or as a Command Program depending on what peripherals it has.
Edited on 16 July 2015 - 12:17 AM
AoD #38
Posted 31 July 2015 - 01:21 PM
Hi moom I have loaded up your program and it errors out on line 32 what version of minecraft and cc are required to use your program??

kind regards

AoD
moomoomoo3O9 #39
Posted 31 July 2015 - 03:48 PM
Hi moom I have loaded up your program and it errors out on line 32 what version of minecraft and cc are required to use your program??

kind regards

AoD

Line 32 is peripheral.find(), assuming you're using command computers, you need computercraft 1.7, but if you aren't, then you need at least computercraft 1.5. Tell me what CC version you're running and I can probably port it to an older version. (That line could be replaced with like 3-8 lines that would work in an older version)
AoD #40
Posted 31 July 2015 - 04:15 PM
well im kinda on version mc 1.6.2 and cc 1.56 lol my linux system at all that lol I was just wondering because of that error thats all just trying to port worldedit into Arc OS and then that error came about :)/> no need to port it to an older version just for me.

other than that error does the files need to be in a set folder or not because my Program repository is using a separate dir to the the boot file (holds all the commands) for Arc OS and just want to make sure that when the Arc OS update comes out that world edit works just as it does for you
Edited on 31 July 2015 - 02:16 PM
moomoomoo3O9 #41
Posted 31 July 2015 - 06:10 PM
Small update 1.3.1 released.
Changes:
  • The path for all files the program uses can be changed.
moomoomoo3O9 #42
Posted 01 January 2016 - 03:33 AM
Huge update 1.4 released. Same ol' installer, new features!
Changes:
  • Added ConfigAPI, allowing for the creation and reading of config files.
  • Added distr, to see the distribution of blocks in the selection.
  • Added count, to see the amount of a single block in the selection.
  • Added size, to get the size of the selection/clipboard
  • Added config options for the paths for every file, and command line arguments to change the location of the config file and config API.
  • Re-enabled NBT support when using Immibis's Adventure Map Interface. Fixed a TON of bugs while using it due to me not testing with it. (I checked command computer compatibility too!)
  • Added pre-emptive support for unlimited position count for the poly selection type (internal changes, not too much changed user-side)
  • Fixed hpos not starting from the right position.
  • Selection now persists across reboots. I'm so sorry I didn't add this before because it's an amazing feature, and was easy to add.
  • Time it took to change blocks when running set, replace, etc. should be right now.
  • Added chunk command. It sets the selection to the chunk the player is in.
  • Added support for pos and hpos to have spaces in if desired. ("hpos1" or "hpos 1")
  • Capitalized the first letter of all commands in the help text.
  • Probably some more, too, because of the numerous internal changes.
Edited on 01 January 2016 - 02:39 AM
moomoomoo3O9 #43
Posted 30 May 2016 - 04:25 AM
Small update 1.4.1 released.

Changes:
  • Due to 1.8.9 not having a single chat box peripheral, I added the ability to enter commands on the computer itself or over rednet.
  • Set should be a lot faster now.
I'll have another update soon which utilizes 1.8's new stuff (like the fill command, and the ability to make NBT work properly on command computers), but in case anyone wants to use this on 1.8 (or without a chat box), I thought I'd put this smaller update out.
Edited on 30 May 2016 - 11:13 AM
moomoomoo3O9 #44
Posted 01 June 2016 - 01:17 AM
Large Update 1.5 released.

Changes:
  • Input on the computer and over rednet has been improved using lsh from Lyqyd
  • Set and replace have been sped up. (More can be done for replace, naturalize, and overlay, but that can wait for 1.5.1)
  • hpos has been implemented for command computers! Now you can select the block you're looking at using a command computer!
  • contract now works properly in the east and west direction. (I swapped them, whoops!)
  • Copy and paste now have NBT support on the command computer! (Applies to almost everything in WE_Clipboard)
  • Trusted rednet IDs and the current clipboard are now properly saved, and now persist across reboots
This release requires MC version 1.8.9 (and thus CC 1.7.9+).

Thank you to Lyqyd for lsh, and Wergat for your amazing code to get the player's looking vector!
Edited on 31 May 2016 - 11:17 PM
Lyqyd #45
Posted 01 June 2016 - 02:31 PM
Moved to Command Programs by request.
moomoomoo3O9 #46
Posted 25 July 2016 - 04:01 AM
Medium update 1.5.1 released.

Changes:
  • Replace and any other command which "scans" blocks, including copy (if you don't need NBT data), is now much faster (up to 4096 blocks/tick instead of 1 block/tick)
  • Command "deepcopy" and "deepcut" added, which copies or cuts an area, including its NBT data. If you don't want NBT data, just use copy or cut as normal.
  • Command "list" or "ls" added, which lists all of the schematics currently stored.
  • Command "exportVar" added for debugging purposes. If you want to play around with it, feel free. It can export any variable currently in the local or global environment and traverse tables within them. It's not perfect, but it's useful.
  • Did a little bit of cleanup with the Rednet Companion. Clear clears the text on both the companion and the computer itself now.
  • move -s has been added, so you can move your selection along with moving an area.
  • Set now reports the number of blocks changed correctly.
  • Tons of refactoring in WE_Core, now everything is in a function or within main.
  • Rotate command added. Rotate your selections 90, 180, or 270 degrees! (on any axis, or X by default)
  • Tons of bug fixes and other forgotten changes since 1.5 that I forgot about.
If anyone wants to mess around with exportVar in their own code, here it is:

local function splitStr(str,char) --#Converts str into a table given char as a delimiter.
	local tbl={}
	local findChar=str:find(char)
	local findChar2
	if findChar then
		table.insert(tbl,str:sub(1,findChar-1))
		repeat
			findChar2=str:find(char,findChar+#char)
			if findChar2~=nil then
				table.insert(tbl,str:sub(findChar+1,findChar2-1))
				findChar=findChar2
			end
		until findChar2==nil
		table.insert(tbl,str:sub(findChar+#char))
	else
		return {str}
	end
	return tbl
end

local function exportVar(varName,filePath,silent,printFct)
	printFct=type(printFct)=="function" and printFct or print
	local shortVarName=varName:sub(1,(varName:find"%." or (#varName+1))-1)
	local var=rawget(_G,shortVarName) or rawget(_ENV,shortVarName) --#Check locals and globals
	if var~=nil then --#It's allowed to be false, so an explicit nil check is needed.
		local outString=""
		if type(var)=="table" and varName:find"%." then
			local fields=splitStr(varName,"%.")
			for i=2,#fields do
				var=var[tonumber(fields[i]) or fields[i]]
			end
		end
		outString=type(var)=="table" and textutils.serialize(var) or type(var)=="function" and string.dump(var) or tostring(var)
		local success,errMessage=pcall( --#Try to write it to a file, and catch any errors if necessary.
			function()
				if type(filePath)=="string" and #filePath>0 then
					local f=fs.open(filePath,"w")
					f.write(outString)
					f.close()
				else
					error(("File path \"%s\" not a valid path!"):format(tostring(filePath)))
				end
			end
		)
		if not silent then
			if not success then
				printFct(("Error writing to file! Error message: \"%s\""):format(errMessage))
			else
				printFct(("Variable \"%s\" written to file at %svars/%s"):format(varname,ConfigFolder,varName))
			end
		end
		return outString
	elseif not silent then
		printFct(("The variable \"%s\" doesn't exist or is nil."):format(varName))
	end
end
Edited on 31 July 2016 - 08:37 PM
moomoomoo3O9 #47
Posted 04 April 2017 - 05:12 PM
Since dropbox removed the pubic folder, I moved the project over to GitHub. The links should all work again.

I pushed my development code onto the repo, so there might be a few changes. It should mostly be bugfixes, but I haven't worked on the project recently, so I'm not sure what all of the changes are.

A few I can recall:
  • Support for serpent as a table serialization library added for exportVar.
  • Refactoring so IntelliJ doesn't yell at me for suspicious global creation.
  • Added support for elliptical selections.
  • Added a few extra parameters to commands from WorldEdit (move -s, for example)
  • Fixed argument parsing internally (Most commands weren't using it, so I ported a few over and realized it was broken!)
  • Moved command registration into the respective file that created the command (move is in WE_Clipboard, for example)
  • Fixed stack (it wasn't working before)
TODO:
Rewrite selectLargeArea to use coroutines? (May not be worth it, since it may end up killing servers because it's using as many resources as possible)
Polygon Selection (always)
#clipboard in block patterns?
moomoomoo3O9 #48
Posted 17 May 2017 - 09:17 PM
1.6 Released.

Changes (from commit description):

Added task system:
-"Tasks" are plugins which are put into the parallel.waitForAny() call that runs. They only have a name and a function at index 1.

Moved data into their own files:
-blocknames, MCNames, pipeblocks, ids moved into their own files.

Bug fixes:
-Fixed missing tostring() in blockHasChanged(), making set and replace report how many blocks changed correctly.
-Fixed obsolete references.
-Fixed region operations trying to reference a nil table.

Refactoring:
-Moved more variables into WE table, such as username and message.
-Made heightmap() local to sel.
-Moved makeSelection.cuboid into cuboid.

Misc:
-Made pos switch positions like hpos does.
-Fixed warning in help() so commands with missing help text actually issue a warning.
-Made sortedHelpText sort on command registry using insertion sort.
-Add tablex.walk() to GeneralAPI.
-Modified tablex.reverse() to be able to copy the table.
Edited on 17 May 2017 - 07:18 PM
bradster2214 #49
Posted 04 July 2018 - 02:50 PM
Hi.
I have no idea how the command computer works, i don't really intend on learning as it takes time and i don't intend on doing much with it. i want to be able to use a command computer to run the command "//replacenear 100 stone lava". i don't know how to do it. i did the pastebin run ku1FHyEW command but all it did was "Connecting to pastebin.com… Success." and that's it. if someone can please help i would greatly appreciate it.
moomoomoo3O9 #50
Posted 04 July 2018 - 09:13 PM
Hi.
I have no idea how the command computer works, i don't really intend on learning as it takes time and i don't intend on doing much with it. i want to be able to use a command computer to run the command "//replacenear 100 stone lava". i don't know how to do it. i did the pastebin run ku1FHyEW command but all it did was "Connecting to pastebin.com… Success." and that's it. if someone can please help i would greatly appreciate it.
You need to run WorldEdit.lua on the command computer, then either hook up a chat box, an ender modem and pocket computer, or enter the command on the computer itself.

However, replacenear is not implemented, mostly because it would be really slow because of how WorldEdit-CC scans for blocks. You would have to actually select the region you want replaced and then use replace.

Under "Media" in the original post is a video showing how to set it up. The only change from the video is you run WorldEdit.lua now, not WE_Core.
Edited on 06 July 2018 - 09:18 PM