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

Turtle Tweaks

Started by HPWebcamAble, 18 July 2015 - 07:51 PM
HPWebcamAble #1
Posted 18 July 2015 - 09:51 PM
While playing with turtles today, I thought of something;

These functions, (for example)…

compareUp()
compareDown()

suckUp()
suckDown()

equipLeft()
equipRight()

Why don't they work like this:

compare("top")
compare("bottom")

suck("top")
suck("bottom")

equip("left")
equip("right")
(There are others, like dig, detect, inspect ect)

Obviously, they would have to error if you used a side that doesn't work, like trying to equip something on top of a turtle, or sucking from the back of a turtle.
Alternatively, they could just not do anything when given a nonsense side.

What do you guys think?
Has this been suggested before?


I made an API that does this:
http://www.computercraft.info/forums2/index.php?/topic/24030-turtle-tweaks-api/
Edited on 18 July 2015 - 10:34 PM
Lupus590 #2
Posted 18 July 2015 - 11:14 PM
I don't think that this is a good suggestion, as the error messages caused by attempting to do something on an invalid side is useful.

Other than the convince of being able to loop through a table with "up", nil, "down" to call each, I see no point. Also I'm sure that people more creative than me will be able to replicate that without making a wrapper function.

Another note, what will be do with the old functions? You will cause a lot of compatibility issues if you remove them.
jerimo #3
Posted 18 July 2015 - 11:46 PM
I would think the main reason it was implemented implementer his way is because it's much faster this way.

Let's compare;
The current way you call the function it does its thing and its done.
The way you are proposing you call a function, which then needs to compare strings, followed by assigning a few more variables to determine which block needs to be checked based on the strong and finally do its thing.

If the turtles and computers did not have to share a single thread it would not matter but due to the way that the system is made any acceleration is good

On a server I played in we had over three hundred computers running at all times, around fifty of those being turtles that were not assigned to a farm, such as the wither boss farm
HPWebcamAble #4
Posted 19 July 2015 - 12:32 AM
Ok first, maybe I'm the only one who wants this. In which case, I'll just use my API.

What API? Oh this api:
http://www.computerc...tle-tweaks-api/
It perfectly implements what I envisioned.

Spoiler
I don't think that this is a good suggestion, as the error messages caused by attempting to do something on an invalid side is useful.
You mean doing 'turtle.digLeft()' erroring is good? or 'turtle.dig("left")' erroring is good?

Other than the convince of being able to loop through a table with "up", nil, "down" to call each, I see no point. Also I'm sure that people more creative than me will be able to replicate that without making a wrapper function.
Its more uniform I guess, its like rednet.openRight() makes no sense. Then again, you can do 'rednet.open' for any side, whereas 'turtle.dig' would only work for 3.

Another note, what will be do with the old functions? You will cause a lot of compatibility issues if you remove them.
They would have to stay, at least for a few versions.

Spoiler
I would think the main reason it was implemented implementer his way is because it's much faster this way.
Err.. Not really, a simple if statment requires very little processing time.
I don't know how long, but I'd guess less than .001 second I really don't know.

But it wouldn't effect anything.

Let's compare;
The current way you call the function it does its thing and its done.

Thats how computers work! Right?

Like I said, implementing it Java side wouldn't slow anything down.
I'd bet you wouldn't even notice a difference when using my API.
Edited on 18 July 2015 - 10:33 PM
jerimo #5
Posted 25 July 2015 - 08:09 AM
– snip –
The difference would be small, yes but there would be a difference which would start showing if you had a hundred turtles all trying to do this as quickly as they can