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

Map API - Map of characters

Started by libraryaddict, 16 June 2012 - 01:47 PM
libraryaddict #1
Posted 16 June 2012 - 03:47 PM
Important
If you want to use this, Ask for a updated API.
I often update it and I'm kind of lazy.
Barely any bug fixes and lots of features added.

If you would like a guide on using my API, Just ask.
If you want a updated version, Either post in here or send me a mail.

Confusing title I know..
Basically this stores a "map" into a table. Which you can then modify.
Basically, Use this if you plan to make a game.
Or plan to make something that prints off stuff to the screen.

This is basic as I want to give the programmer control.
I was going to add in checking for the moveScreen() so it can't extend beyond the range.
But then that would A. Look messy. B. Might interfere with your programming..
Edit: I've changed this so you have it render anything off the map as " "
If you don't want this, Add in checks!

http://pastebin.com/9Dnyp2MX - The API!

Looking for a example?

http://pastebin.com/VfN0PFsi - A program you could test out on!

I am sorry if I do not make sense.
But this allows you to make a map you could easily edit.
Its a map on the screen. Made out of characters.
Using this you can easily do many things.
Such as moving a enemy character in a game.
Indicating where a turtle is.

If you still are confused, by all means try out the example program.
Name the API MapsAPI

Use "asdw" to navigate

I origanally made this for a game API which I realised was stupid.
So I redesigned it to be a map API.
Which was stupid.
So I remade it in 20min to a.. Godly API.

But to those who use the sample program.
You will notice you can move the viewed screen around with the asdw keys.
It creates a file called "World" which is the map.
It was 6000x6000 before but it was getting errors while making it >.>

It looks similar to the edit program.
But its way way different.
I will eventally get around to my custom edit program which will use this to display..
The main advantages my custom edit program will feature is multiple people can edit one file.
The file would be stored at one computer while 2+ can access that one file and edit it just like normal.

So I could work on the password script and you did your redstone stuff.

Cheat sheet!
createMap(MapName)
loadMap(MapName) – Load a file into the API
cView(Viewer, Map, xWide, yHigh) – Create a view point on this map which is x chars wide and y chars high
dView(Viewer) – delete the viewer
draw(Viewer) – Draws the viewpoint from the viewer.
editMap(Map, X, Y, Char) – Edit the map at this point to replace the char there with this char
returnView(Viewer) – Returns the view to whatever called it. Catch like this Stuff = {returnView("ME!!")} then its loaded into the table "stuff" in your program
moveScreen(Viewer, X, Y) Moves the viewpoint of the viewer to that x, y
saveMap(Map, Location) Saves the loaded map into the location
replaceLine(Map, LineNo, From, To, StuffToReplaceWith) replaceLine("World", 3, 10, 30, "") would replace line 3 at map World chars 10 to 30 with ""
insertLine(Map, y, data) Makes a new line there
removeLine(Map, y) do I really need to say this?
getSize(Map)
returnChar(Map, X, Y) returns the char there
libraryaddict #2
Posted 07 July 2012 - 09:01 PM
Updated my kinda vague post with a updated API!
Better then ever!
Almost godlike!

Featured in Maze Game!
Mendax #3
Posted 08 July 2012 - 10:23 AM
B)/>/> :)/>/> Awesome! Perfect for my game! Although, making tanks will be one heck of a job…