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

Tip: How to create an already running Computer/Turtle

Started by exosceleton, 12 August 2016 - 08:10 AM
exosceleton #1
Posted 12 August 2016 - 10:10 AM
This is a question I've been asked by many of my friends who have just began to use Command Computers, so I decided to post this tip here to help share the knowledge. ^_^/>

When setting a block using the setblock command, you can specify what nbt data the block will get. All Computer types that come in block form (Computers,Advanced Computers,Turtles,Advanced Turtles,Command Computers) have a tag called on. this tag can be set to 1b or 0b. (defaults to 0b.) Setting this tag to 1b manually will have the Computer already active without the need to right-click it.
Another useful tag is id which specifies what computer ID that Computer will have.
So, using the id tag we can create a Computer with the ID of a Computer that has premade files, and by setting on to 1b we can make it run it's startup file automatically.
Edited on 12 August 2016 - 08:37 AM
Lyqyd #2
Posted 12 August 2016 - 03:17 PM
Moved to Tutorials.
Lupus590 #3
Posted 12 August 2016 - 03:27 PM
Can you fill a turtles inventory?
SquidDev #4
Posted 12 August 2016 - 07:35 PM
Can you fill a turtles inventory?

Yes: items are stored in the "Items" tag so you can do something like: {Items:[{id:1,Slot:0,Count:1,Damage:0}]} to put a piece of stone in the 1st slot. In 1.8 you can use replaceitem: /replaceitem block <x> <y> <z> slot.container.0 1 1 (slot 0 with item 1 of stack size 1).
KingofGamesYami #5
Posted 12 August 2016 - 08:59 PM
Note on inventory: My CC Jam 2016 project successfully copied a turtle plus inventory. You can view it on github.
Lupus590 #6
Posted 13 August 2016 - 12:22 AM
So I could teleport turtles with this?
KingofGamesYami #7
Posted 13 August 2016 - 01:47 AM
So I could teleport turtles with this?

Yep. Just make sure to copy the nbt data with commands.blockdata - that includes the id, tools, and inventory.
moomoomoo3O9 #8
Posted 13 August 2016 - 03:02 AM
Note on inventory: My CC Jam 2016 project successfully copied a turtle plus inventory. You can view it on github.
Yep. WorldEdit can as well with deepcopy and paste.

Only thing about reading NBT's that you have to wait for the command to yield, so it's 1 block/tick at most afaik (unless you can make coroutines which'll each get one block and do it that way?)
Edited on 13 August 2016 - 01:03 AM
Bomb Bloke #9
Posted 13 August 2016 - 12:34 PM
You can also generate brand new systems if you play around with peripheral calls and disk drives. Spawn a new system next to your command computer, boot it and get its ID, shift it near a disk drive (or perhaps INTO a disk drive) so it can be configured, then finally shift it to where ever you actually want it to end up…

(unless you can make coroutines which'll each get one block and do it that way?)

You probably can; I never rigged my world scanner to use command.getBlockInfos(), but use of coroutines still allowd it to read over a hundred blocks per server tick. So presumably it'd operate at about half speed if it started using blockdata in addition to getBlockInfo (well, probably something like 90% speed, bearing in mind that it could be rigged to skip NBT reading on most blocks which are known not to be tile entities, such as air / dirt / stone…).

Note that yielding does not, in itself, take "a server tick" - it's pretty much instant, and you can effectively resume as soon as the event you're after appears in the queue. In this particular case ("commands API functions") it takes longer than a tick for each event to show up (which can fortunately be dealt with by requesting tons of the things concurrently), but the time varies depending on the event you're talking about (most are also pretty much instant - it's usually only those related to third-party peripherals that have any notable delay).
TheRockettek #10
Posted 13 August 2016 - 10:23 PM
I never rigged my world scanner to use command.getBlockInfos(),

Its a shame getBlockInfos limit is a 16 cube tho…
moomoomoo3O9 #11
Posted 24 October 2016 - 05:05 PM
I never rigged my world scanner to use command.getBlockInfos(),

Its a shame getBlockInfos limit is a 16 cube tho…
It's a big pain to work with, but I worked around it in WorldEdit.