# Minecraft I/O Methods

Seeing as how we've discussed a size measurement for Minecraft redstone creations, I thought I'd follow that up with establishing standard output and input methods.

Minecraft, obviously, does not have STDIN or STDOUT in the traditional sense. So how exactly should we handle input and output for Minecraft redstone "programs?" What methods should be considered standard?

• You could output with "/say " – Alien G Nov 16 '15 at 3:16
• Is this asking about pure redstone or redstone+command blocks or both? – Calvin's Hobbies Nov 16 '15 at 3:28
• @Calvin'sHobbies Both. – a spaghetto Nov 16 '15 at 4:16
• The meta question you link failed to establish an objective size measurement. – feersum Nov 16 '15 at 18:40
• @feersum I believe it has. This answer has been accepted, and several answers have been made with these rules. – a spaghetto Nov 16 '15 at 18:43
• @quartata That answer is bogus. It provides no way to decode a sequence of bytes into an assembly of Minecraft blocks, or vice versa. – feersum Nov 16 '15 at 18:48
• @feersum By this reasoning, we should have a textual representation for Piet. – a spaghetto Nov 16 '15 at 18:49
• @feersum I have seen no Piet program scored in this manner. The accepted standard, as far as I know, is by codels. – a spaghetto Nov 16 '15 at 18:52
• @feersum Let's move this to The Nineteenth Byte. – Addison Crump Nov 16 '15 at 18:53
• Indeed, I don't think any Piet program could be scored like that, since even the raw image format contains headers and metadata. – a spaghetto Nov 16 '15 at 18:53
• @quartata, the "is accepted" property is almost entirely irrelevant on meta questions which are trying to establish a community consensus. The only thing it tells you is that OP preferred that answer. +10/-7 doesn't look like a real consensus. – Peter Taylor Nov 16 '15 at 23:24
• @PeterTaylor Wait, it had 7 downvotes? – a spaghetto Nov 17 '15 at 0:07
• I was not aware of this at all. My bad. – a spaghetto Nov 17 '15 at 0:08
• Can anyone think of a situation where button input would be useful over lever input? Perhaps to start/halt execution? – mbomb007 Nov 21 '15 at 18:31

# Output using /say or /tellraw in a Command Block

This is probably the most obvious output method, since it outputs as text to chat. As a bonus, /say (but not /tellraw) would also output to "real" STDOUT on a server.

Since /say outputs a [@] before the text, we should probably use similar rules to this to determine when /say is allowed (as opposed to /tellraw).

• It actually doesn't output tellraw to STDOUT, as it doesn't identify it as a user. Only /say will output to the command line, as the @ player does the /say command. – Addison Crump Nov 16 '15 at 18:37
• Oh, I didn't know that. – a spaghetto Nov 16 '15 at 18:37
• Another problem - all /say is prepended with [@]  (note the space), so, depending on the OPs choice, it may not be valid output. In the chat log, it's prepended with [current time] [@] . – Addison Crump Nov 16 '15 at 18:40
• You can do /gamerule CommandBlockOutput false or something like that, though that is a byte-waster. Perhaps this can be an assumed state? – Conor O'Brien Nov 16 '15 at 18:44
• @CᴏɴᴏʀO'Bʀɪᴇɴ Won't solve it - the [@]  is still the player that executes /say. – Addison Crump Nov 16 '15 at 18:44

# Alternate Output with Redstone Lamps

Consider a pure redstone mechanism. Using a Command Block would eat a good deal of bytes; I agree that, when explicitly said, STDOUT is what quartata suggested in his answer. When otherwise not stated, it may be easier to output using Redstone Lamps, if all you need to output is a truthy/fasly value. Thus, an on-state redstone lamp could be truthy, and an off-state could be a falsy value.

• As an extension to this, a sequence lamps used together could possibly be used for binary numeric output. – ankh-morpork Nov 20 '15 at 21:42
• @dohaqatar7 Like if a question asks to write a function xor-ing two bytes together, for example, then you have 16 levers for input, 8 lamps for output. – mbomb007 Nov 21 '15 at 18:24

## Binary input with levers on blocks

This is the obvious, simple solution for pure-redstone answers. Encode the input into binary, and input it with levers. Bit order (most significant first or least significant first) and the translation between bits and lever positions (e.g. 0 = up, 1 = down, or vice-versa) would be individually specified by the answer. Since levers can only be placed on the sides of blocks, a free (as in, not counting towards the score of the program) block with a single lever mounted on it for each bit of input seems appropriate.

## String Input, via tellraw

So it actually is possible to get textual input in minecraft, though you couldnt do much with it. WARNING: THE FOLLOWING IS COMPLEX.

Lets start with the actual string input. This can be achieved through a simple keyboard tellraw command (like the one in this video). Each key can be linked to a trigger objective where the key determines the value of the score in that objective. Command blocks would then determine what key it is, and summon an entity with that name at a certain position. The system would then detect an entity there, and move it over by one block. This repeats, moving each entity over by one block until a row of "character" entities is made. Next, to use this information, you can issue specific testfors and executes to determine the string. In this case, a command could be /execute @e[0,0,0,r=0,type=Chicken,name=A] ~ ~ ~1 execute @e[r=0,type=Chicken,name=B] ~ ~ ~1 execute @e[r=0,type=Chicken,name=e] ~ ~ ~1 execute @e[r=0,type=Chicken,name=2] ~ ~ ~ say TRUE, for example.

### TLDR

Create a tellraw keyboard that spawns in an entity chain, adding to the chain in each click, and perform execute commands to test string qualities.

Note: If this answer gets enough votes I will make a fully working example system to prove this concept.

• That's... cool. Wow. – Conor O'Brien Nov 18 '15 at 4:10
• @CᴏɴᴏʀO'Bʀɪᴇɴ I made a whole adventure map with this concept once... too bad it has been lost with time or else I would of included it. Oh well. – GamrCorps Nov 18 '15 at 4:11
• You could use Sethbling's typewriter but change the commands to do this instead. – DanTheMan Nov 18 '15 at 17:16
• Ewww. I think I prefer the hard coded idea better, as input in MC shouldn't be this complicated. Plus, this isn't really input, per say, but testing if the string is existent. – Addison Crump Nov 18 '15 at 21:27