Open byorgey opened 2 years ago
To tie it back to the map idea, maybe you could "place entities" on some (finite) canvas?
You would not actually put the entity there, just print the entity character with its attributes.
So the resulting command could be print :: entity -> (int*int) -> entity -> cmd ()
where the entity
type is from #455 and the third argument would be the particular "map canvas" in inventory.
The "canvas" idea is cool, but it seems like that would require doing #455 first; at the current rate I don't know how soon that will actually happen. For now it seems like it could be a relatively straightforward, "low hanging fruit"-type task to add a couple commands to print to the virtual console and then make a way to visualize it in the UI.
My original motivation was contemplating the idea of sending robots into places you can't see (off the screen, into structures #112 or sub-worlds #144 ...) and programming them to wander around, build a map of the area (probably using some kind of mutable array #98 ), then come back and give you the map. How would you actually view the resulting map?
I propose having a "virtual I/O console" (perhaps in a different "tab" in the same window as the world view, so you can switch back and forth between them, or perhaps in the same window as the REPL) and adding some commands to output to the console. One might think of adding built-in commands like
putStr
, but actually, since I'd like to keep the number of new primitives to a minimum, and because I want to be able to do cool things like draw color maps, we might contemplate going even lower-level like a command to set the color and a command to put a character at a specific (row,column) position. Then you could build your own functions likeputStr
on top of that.I am not sure how reading keyboard input would work, or whether we should, but just doing output to the virtual console seems like a good place to start.
Edit: a simpler, useful thing to start could be just a simple command like
print : text -> cmd unit
(and perhaps aninput : cmd text
to go with it) which outputs (respectively, reads) a string from the REPL console. This wouldn't be as useful for printing maps etc. but it would be useful for displaying information, debugging, etc. Edit 2: not sure how usefulprint
/input
would be on their own anymore, since we havelog
for outputting information and key input handlers for (a limited form of) input.