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

[Need an Advice] API code organization

Started by PonyKuu, 22 March 2013 - 07:34 PM
PonyKuu #1
Posted 22 March 2013 - 08:34 PM
Hello again. Here is my two APIs that meant to work together. And they do work pretty well, but it seems like they are useful only to make a quarry program… I don't think that API with only one usage is a good idea, so I want to ask you - what can I do with it? I'm not talking about new features. It seems like there are some extra stuff that shouldn't be there.
Or maybe it's too bad and it needs a complete rewrite?

Here is the APIs
master API: http://pastebin.com/J3i3TrjU
module API: http://pastebin.com/dULznkqY
PonyKuu #2
Posted 23 March 2013 - 05:19 PM
Guys? No idea? Or maybe just a wrong place to ask it?
jadelade #3
Posted 23 March 2013 - 07:44 PM
I found lerning how to you this api hard and annoying. Let me give you one or two tips on how to make it easier to read and understand.
1) you dont need "–" for each line you can use "–[[" and "]]". For example.
–[[
Hello
Minecraft
Text
Text
]]

2) if you have a look at how lua tells you how to use their apis, thay just tell you the name then how to use it under the name. See for your self.
http://www.lua.org/manual/5.2/manual.html#pdf-string.match
PonyKuu #4
Posted 23 March 2013 - 08:17 PM
Well, I know about block comments, I just think that dashes look better. And I like one Dash as well…
And that's about documentation, I actually just didn't make actual documentation yet. That's more like a quick start guide

I want to ask about code - which functions are overcomplicated, which are not useful. Maybe API needs more options, more "set/get"-functions. Maybe I should split those init() functions to smaller ones… I just don't know
theoriginalbit #5
Posted 23 March 2013 - 08:28 PM
there are definitely improvements that could be made to the functions. as for another usage for the api, I'm not sure if there really is one, however I'm not the best at coming up with ideas, so maybe there is. You could try and generalise the API's and it may provide some features to other programs, but again, not too sure.
jadelade #6
Posted 23 March 2013 - 08:55 PM
This is some nice code. I like to keep my code at a lower level for the coder just starting but not all code is for learning. There is not much for other uses for a turtle. I would say this would work well with a program that tunnels a diamond strip mine placeing chests and returning wen full of rock with one or two diamonds.
PS brohoof
PonyKuu #7
Posted 24 March 2013 - 03:06 AM
Well, I think there are some things that might be a problem for making other programs:

1) Second Ender chest. First is required for fuel, but the second one is dedicated to mined stuff. If the turtle mines something - that's good, but if it doesn't do that, or doesn't care about the stuff it mines, this might be annoying. Maybe you are making a building swarm after all…
2) Built-in navigation method. It is quite good if you want turtles to do something with some horizontal area, but is not very good for, say, branch mining.

I think there are something else, but for now, I can't say what is it… The best way to find - is to have something who try to use the API and tell me, what's the issue…

PS brohoof
Yay! *broohoof*