- Sky
- Blueberry
- Slate
- Blackcurrant
- Watermelon
- Strawberry
- Orange
- Banana
- Apple
- Emerald
- Chocolate
- Charcoal
jaspercayne
-
Content Count
2 -
Joined
-
Last visited
Posts posted by jaspercayne
-
-
I know this was asked months ago, but since nobody seems to be providing any answers, I just recently have been working on a robot to farm cocoa beans so I found out a bit about how to do this the hard way... Easy answer is to utilize a geolyzer component, and run the analyze function to get the metadata of the crop, comparing it to the metadata for a full grown crop that you can find on the Minecraft wiki. Complicated answer follows:
local analyze = component.geolyzer.analyze(3) -- 3 is the front of the robot function getFacing() -- Get the facing of the cocoa bean for k,v in pairs(analyze) do local i = k if i == "metadata" then local n = v return n end end end function growCocoa() -- Fertilize as needed if robot.count(bonemeal) > 0 then -- If bonemeal is in slot 2 robot.select(bonemeal) for k,v in pairs(analyze) do local i = k if i == "metadata" then local n = v if n < getFacing()+8 then robot.place() os.sleep(1) robot.place() end end end else if robot.count(bonemeal) == 0 then for k,v in pairs(analyze) do local i = k if i == "metadata" then local n = v if n < getFacing()+8 then local x,y = robot.durability() if y == "tool cannot be damaged" then robot.use() os.sleep(1) robot.use() else for k,v in pairs(analyze) do local i = k if i == "metadata" then local n = v while n < getFacing()+8 do print("Waiting for growth to finish...") for k,v in pairs(analyze) do local i = k if i == "metadata" then local n = v if n == getFacing()+8 then return end else os.sleep(10) end end end end end end end end end end end end
(Please note that these functions are an excerpt from my cocoa harvesting script, and currently do not work when the robot has no bonemeal at all. If there is interest in it, I can post the whole thing if anyone wishes to assist me in finishing it off.)
So in getFacing(), I am checking which side of the tree the cocoa pod is growing on to use as a reference point (base metadata if you will), then during growCocoa() I check if the current metadata is equal to the reference point+8 (no matter which side of the tree the pod is on, base metadata+8 will be fully grown). If the current metadata is high enough to signal that is is matured, I can harvest and replant, or else I apply liberal amounts of bonemeal until it does return base+8. If this doesn't make sense, let me know and I will see about making another script for automated wheat harvesting as a less complicated example.
Problems centering text
in Programming
Posted
I am having issues with a text API that I am writing and am looking for input from more experienced coders. The problem I am currently facing is with my centering method. If be used to center text to the full screen width it works great, if I am trying to center text in a smaller portion of the screen that is offset towards either edge, it fails miserably. API-in-progress below:
I am certain that the main issue is from trying to pull the absolute x,y coords and derive a center point from that, but my brain just isn't putting together what the centerText function should look like... Help? Anyone?