- ComputerCraft | Programmable Computers for Minecraft
- → Noiro's Content
Noiro's Content
There have been 19 items by Noiro (Search limited from 10-February 22)
#224062 Computercraft Emulator
Posted by
Noiro
on 01 July 2015 - 02:07 PM
in
APIs and Utilities
#224060 [STABLE] MoveAPI - Reboot persist, coordinate tracking, smart movement
Posted by
Noiro
on 01 July 2015 - 01:22 PM
in
APIs and Utilities
blackrabt, on 07 March 2015 - 12:42 PM, said:
If I might suggest something, another moveTo method that will try to complete a movement in one direction, but if it encounters an obstacle and is not supposed to break blocks, it tries to move in another axis toward the destination and then returns to the blocked axis after it has made progress. Does that make sense?
Also if it were possible to use an existing rednet GPS setup to input the initial coordinates that would save some work with turtles that are frequently moved. I suppose the built in GPS does not supply facing, but setCoords((gps.locate), "west") would still be nice.
xTable = {354}
turtle.moveTo(xTable, "y", "x", "south", "z", 13, 5)
That would say: "Go to coordinates: x:354, y:-13, z: 5, face south when you get there, then travel along the y axis first, then x, then z." Order will no longer matter in terms of where you place the variables, but order DOES matter relative to numbers and x,y,z axis order. In your case:
originalPos = gps.locate()
--Insert code to go do a thing
turtle.moveTo(originalPos, "east")
print("Hey, I'm back!")
Would work just fine. Though if I"m totally honest, I'm being a bit selfish in that half the reason I even am adding this is so you can pull stuff like:
--Locations
home = {0,0,0,"north","z","x","y"}
exitHome1 = {5,0,-6,"east","x","z","y"}
exitHome2 = {5,3,-6,"east","y","z","x"}
friendHouse = {-306,55,1522, "south"}
function goHome()
turtle.moveTo(exitHome2)
turtle.moveTo(exitHome1)
turtle.moveTo(home)
end
function leaveHome()
turtle.moveTo(exitHome1)
turtle.moveTo(exitHome2)
end
--Here's the fun part
leaveHome()
turtle.travel(friendHouse)
--Insert code to fill his house with water (I'm a bad person)
goHome()
See how this code works? It essentially allows you to build locations and then make functions that essentially generate paths so the turtle can get around without hitting things. He enters into exit2 (which is likely the turtle entranceway), then moves down into exit1 (which is where he'll then go into his 'home' position), then go to home, this way, along with axis specifications, you have full control over how he gets where.
#221528 Different terminals and print
Posted by
Noiro
on 16 June 2015 - 12:34 AM
in
Ask a Pro
Lyqyd, on 16 June 2015 - 12:26 AM, said:
So it's fair to assume if someone performs a peripheral.wrap() and starts using it as a terminal, it WILL be a monitor of some kind under all circumstances? My goal with the API is not to bind to a specific side so one computer can run across however many monitors/terminals they want. Do displays have some kind of identifier like functions do? does the pointer to the monitor return an id of some kind I can use as an index in a table and store a value telling me how to deal with it?
I was considering hijacking the peripheral.wrap() function, adding a "Add this to my own table", then continueing on with its normal operation, though I'm sure that's probably the more hacky way to do it.
Edit: Ok, I went through Touchpoint line by line and I see how you did it. Blargh. You did it with the OOP route by just assigning the pointer of the side via each screen or buttonscreen object. I was hoping my API would let them bounce between different terminals of their own accord and if they said they wanted a button there, I'd put a button there, but now I can sorta see how that'd be difficult to manage if I was going to give them that much freedom but the API would still be expected to manage input from them.
My question on touchpoint though, line 99 and line 108, it looks like run 'runs' handleEvent though you seem to want users using your api to call button:run(), it looks like handleEvent is the one actually returning all the variables and I don't see run returning anything that handleEvent unpacks and returns. Where is it going and how is run returning the values? (better yet, I'm not exactly sure WHAT values it's returning though you gave p1-p5) as possible returns.
#221526 Different terminals and print
Posted by
Noiro
on 16 June 2015 - 12:24 AM
in
Ask a Pro
valithor, on 15 June 2015 - 11:26 PM, said:
It would wrap to the next line of the window.
You could check if term.current() is equal to term.native (if true it is just the default terminal window) or if term.current is equal to peripheral.wrap(side of monitor) (if true it's just the default monitor window).
All a window is, is a table of functions which determine how things such as term.write behave. So yes type(term.current()) is a table.
Wrote of my phone sorry if it's hard to read.
#221519 Different terminals and print
Posted by
Noiro
on 15 June 2015 - 10:51 PM
in
Ask a Pro
My second question is regarding terminals themselves. Since they can be different objects, is there a way I can tell the difference between say a window object, a native terminal object, and a monitor? I would assume that type(term.current()) would return table instead of "window" or "monitor". If they do return "window" or "monitor", how would I make code that'd let me give custom objects I create their own names for when returning a type() as well?
#219882 [WIP] [MIT] Hive - a turtle control system
Posted by
Noiro
on 04 June 2015 - 03:10 PM
in
Turtle Programs
If you intend to utilize GPS functionality as well, my turtle.setCoords() function will soon be receiving an update so that it can take the GPS.locate's output as a valid parameter. So you'd get something to the effect of turtle.setCoords(gps.locate(), "west") or whatever. Tbh, he shouldn't need to have his loc set all that often unless he gets picked up, move does a pretty handy job of keeping track of it through reboots/crashes/whatever. I was actually considering starting a project like this myself and i kind wouldn't mind getting involved in helping develop. My only hangup is that I've never used Git seriously in my life. xD
I noticed on the github that you were also looking for an updater. I do have one I've been working on but it's probably not as fancy as you're looking for. Basically it runs off of a masterfile stored...somewhere, that you can edit and assigns every program a version number. If the version number is newer than the version on the machine, it will automatically download and update it when update gets run. Feel free to poke me if you'd be interested, I built it for a custom launcher I'm building that just keeps all my utilities in order and set up.
#218221 [STABLE] MoveAPI - Reboot persist, coordinate tracking, smart movement
Posted by
Noiro
on 22 May 2015 - 04:06 PM
in
APIs and Utilities
Krutoy242, on 28 March 2015 - 07:50 AM, said:
But i cant understand, why saveData() called after turn function?
turtle.turnLeft = function() --Turns turtle left once and changes dir turnLeft() if dir == "north" then dir = "west" elseif dir == "south" then dir = "east" elseif dir == "west" then dir = "south" elseif dir == "east" then dir = "north" end saveData() endIf server restarting during rotation in progress, isnt new coordinates will be unsaved?
Also, I found, that you not redefine turtle.back() function. If this will be called manually, turtle will be lost.
And, i found small mistake on 752 line:
elseif data[5] > (turtle.getFuelLevel()-1) or data[5] < turtle.getFuelLevel() thenYou already cheked for == fuel() and == fuel()+1 , so right comparsion should be
elseif data[5] > (turtle.getFuelLevel()+1) or data[5] < turtle.getFuelLevel() thenAnd after this, next code after else is unreachable.
Thank you for looking it over. I am going to go back over and poke at some of the edits you mentioned. My only worry is that I'm uncertain on if the server reboots during a turn if the turn gets saved by CC the moment the turtle starts turning (in which case I should saveData() first, or if it will not save the state until it's finished so during a reboot, the turtle will go back to before it tried (my theory at the time)).
I am planning to pick this back up again and poke a couple extra things. I've had a lot going on in life recently so been busy, but with a new modpack I'm building and wanting to get my WorldEater program perfected (which uses move), I will be going back over some of the code. I was not even aware turtle.back() was even a thing.
#198211 [STABLE] MoveAPI - Reboot persist, coordinate tracking, smart movement
Posted by
Noiro
on 12 November 2014 - 12:15 PM
in
APIs and Utilities
#192461 APT-GET Package Manager (Early)
Posted by
Noiro
on 28 August 2014 - 01:47 PM
in
APIs and Utilities
#192450 TwoMove - Turtle movement API with position tracking
Posted by
Noiro
on 28 August 2014 - 11:39 AM
in
APIs and Utilities
#191141 How to overwrite default programs/commands
Posted by
Noiro
on 14 August 2014 - 08:09 PM
in
Ask a Pro
flaghacker, on 14 August 2014 - 08:06 PM, said:
You should make your function like Cranium said:
local oldForward = turtle.forward turtle.forward = function() -- logic, loops, bla bla bla turtle.forward() end
If you're making a local backup, why wouldn't it be:
local oldForward = turtle.forward turtle.forward = function() -- logic, loops, bla bla bla oldForward() end
But even if I overwrite those, since this is happening within an API, wouldn't the program still executing my api still have to reference them as api.turtle.function() ?
#191137 How to overwrite default programs/commands
Posted by
Noiro
on 14 August 2014 - 08:01 PM
in
Ask a Pro
Cranium, on 14 August 2014 - 07:57 PM, said:
local oldForward = turtle.forward function turtle.forward(num) return oldForward(num) endBasically.
So in my API, I could literally say:
turtle.forward = myForward?
Or would I have to:
holderFunction = turtle.forward turtle.forward = myforward function myforward() holderFunction() end
#191134 How to overwrite default programs/commands
Posted by
Noiro
on 14 August 2014 - 07:53 PM
in
Ask a Pro
Cranium, on 14 August 2014 - 07:48 PM, said:
While that may work for executing programs from the shell, what about when programming? I want to overwrite turtle.forward(), since putting it in the root directory would not automatically load the API as turtle, how exactly would I do this? Could I replace go and refuel without spamming their root with a ton of replacements? Or would I have to have the api named turtle and somehow replace their startup script so it automatically loads 'turtle' overwriting the previous one? Since it is an API, I can't use shell.getRunningProgram() to get it's name, rename it to turtle only the fly, move it to the root directory, then load it.
And if I loaded turtle over the current one, does that mean I'd have to provide ALL of the turtle functions or would it just overwrite the ones I've got and when it couldn't find it from mine, it'd look elsewhere after that?
#191129 How to overwrite default programs/commands
Posted by
Noiro
on 14 August 2014 - 07:22 PM
in
Ask a Pro
#190904 [STABLE] MoveAPI - Reboot persist, coordinate tracking, smart movement
Posted by
Noiro
on 12 August 2014 - 11:43 PM
in
APIs and Utilities
Sovietshark, on 12 August 2014 - 06:19 AM, said:
os.importAPI("move")
turtle.travel(nukeLocation)
turtle.up()
turtle.placeDown()
rs.setOutput("bottom", true)
sleep(.1)
rs.setOutput("bottom", false)
turtle.travel(home)
Tbh, the turtle may not survive that depending on range of the nuke.
Update Status: Testing - 98.3%
-Basic movement functions - tested
-moveTo and fMoveTo - tested
-Reboot Persistence - tested
-travel() - Works for the most partish, don't super rely on it quite yet
-collisionHandling() - Turn that on if you really don't have any other obstacle avoidance available, will do its best
In other news, the beta is released! When you guys test collisionHandling or travel() (specifically), keep an eye out. Most of the core forward/fFoward stuff should be perfectly fine along with moveTo and fMoveTo, travel() has and likely always will be a little experimental. And I did basic collision handling because bored so...yeah. If you were one of the zealous ones to download the first couple minutes I uploaded, redownload...I forgot to turn debug off XD
#190635 [STABLE] MoveAPI - Reboot persist, coordinate tracking, smart movement
Posted by
Noiro
on 11 August 2014 - 01:53 AM
in
APIs and Utilities
Win7yes, on 10 August 2014 - 03:49 PM, said:
os.loadAPI("api Name")
and not os.import("api Name")
Woops, thanks for catching that. I had a friend review the post and he was like, "Make sure you specify they have to import and use move.etc" So I kinda hastily threw that in there (though if you're going to be using an API, that should be common sense)
#190505 [STABLE] MoveAPI - Reboot persist, coordinate tracking, smart movement
Posted by
Noiro
on 08 August 2014 - 08:11 PM
in
APIs and Utilities
flaghacker, on 08 August 2014 - 08:01 PM, said:
So this is 100% reboot persistent? Nice!
As for turning around, I'm sure that shouldn't be too hard for you to implement in your own programs.
#190497 [STABLE] MoveAPI - Reboot persist, coordinate tracking, smart movement
Posted by
Noiro
on 08 August 2014 - 07:23 PM
in
APIs and Utilities
#190488 [STABLE] MoveAPI - Reboot persist, coordinate tracking, smart movement
Posted by
Noiro
on 08 August 2014 - 05:57 PM
in
APIs and Utilities
v1.31
NOTICE: This API is now released as stable with exception to the travel() function still being experimental. All else should be fine.
So, what is MoveAPI? Well, moveAPI is a full toolset allowing you to easily navigate/move and get your turtle around the map as smoothly as possible with as little code as possible. It offers everything from simple dig replacements which automatically handle falling sand/gravel/gravity blocks, to advanced customization moveTo() of specific coordinates using relative or specific. Want to say, "Eh, go to these coordinates and if something gets in the way, break it or attack it until it's not and keep going till you get there", you can!
How to use: When you download the program, just os.loadAPI("apiName"). It should download and be named 'move', but if you choose to rename it, you will import under that name, instead. Any functions you want to call MUST START WITH turtle.functionName() (yes, vanilla turtle functions have been overwritten while move is loaded.)
One thing to note, MoveAPI is setup so if you plan to use any of the GPS/coordinate tracking features, ALL TURTLE MOVEMENT COMMANDS in your programs must use move. As long as all programs running on the turtle import move, coordinates should always persist properly. Just don't get into the shell and type "go forward 3" or whatever because on next load it will wipe your GPS data due to inaccuracy.
Random note: coordinates are reboot/chunkload persistent so as long as you have a program using move as startup, move will always know where it is at. If you pick it up and place it back down, be sure to delete move's config file in /api/moveLoc. If the turtle's fuel changes by more than 1 when off, he will auto-reset upon re-import of move (coords will overwrite and store as 0,0,0,"north"). If you plan to place autoexecuting turtles back down, ensure your program running move uses turtle.setCoords() accordingly. The only time you may get some corruption of your coordinates is in the event of a server crash, the server not saving block locations properly, and move saving, thus putting him however many blocks back the server failed to. This can't be fixed on my end so: Try not to crash your server
Downloads
Planned Features for 1.33
-Turn optimization (turns in fastest route)
-Cleaning up param input for travel and moveTo to accept GPS and a little more dynamic stuffs
-Adding turtle.back to overwrite list (woops)
-Notice: I will be deprecating the function turtle.turnToDir() and switching it out with turtle.turnTo(), new version will give you a chance to switch everything over. 1.34 will not support turtle.turnToDir()
-Additionally, I will be removing collision handling from the feature list. After a little more introspection, I don't feel it fits within the scope of this project. I may create a pathfinding API later on down the line but for now, I'd like to limit moveAPI to just the movements provided.
Changelogs
v1.32
-Fixed a couple minor bugs, sped up mining. Mostly bugfixes.
v1.31
-Fixed a tiny mishap with turtle.refuel()
-Optimized turtle.digDown() so it doesn't have the same lag-time the other dig's do waiting for things to fall (since they won't)
v1.3
-Persistence of holding coordinates through reboots
-Fixes to forward/up/down so they return false with obstructions
-Added navigate() for chunkload hacking around the map
-Cleaning up some old code in the the moveTo()'s, still need to do more of that, they're messy.
-travel() will pickup where it left off if server restarts and get to the destination once chunks reload.
-For travel(), moveTo's, you can pass in a table of x,y,z and dir (if you want) or pass in just x/y/z/dir by itself.
-For travel() and moveTo's, further options CAN be passed in to specify order of axis the turtle solves for. Just enter "x", "z", "y" (must include all three) in whatever order you want the turtle to nav
Documentation/How-To
Digging
dig()
-Pretty self-explanatory, digs in front (automatically handles sand/gravel)
digUp()
-Digs upwards, will handle sand/gravel falling
digDown()
-Same as turtle.dig(), here so you never have to use turtle.etc when executing similar commands.
NOTE: If you need vanilla digging mechanics for any reason (only mine just one block, no gravity blocks), use move.dig()/digUp/digDown() instead.
Movement
forward([distance])
-Moves forward (1 forward if no arg given, will move x forward if an int provided)
--Returns false if something in the way
up([distance])
-Moves up (1 up if no arg given, will move x up if an int provided)
--Returns false if something in the way
down([distance])
-Moves down (1 forward if no arg given, will move x down if an int provided)
--Returns false if something in the way
fForward([distance])
-Moves forward (1 forward if no arg given, will move x forward if an int provided). Will break blocks in front and move if they are in way. Will attack monsters if they are in way.
--Returns false if unable to break block (ie. bedrock/warded block)
fDown([distance])
-Moves down (1 down if no arg given, will move x down if an int provided) Will break blocks in above and move if they are in way. Will attack monsters if they are in way.
--Returns false if unable to break block (ie. bedrock/warded block)
fUp([distance])
-Moves up (1 up if no arg given, will move x up if an int provided) Will break blocks in below and move if they are in way. Will attack monsters if they are in way.
--Returns false if unable to break block (ie. bedrock/warded block)
move(direction, distance)
-Moves in the given direction and removes objects if in the way (viable examples of dir are "north", "south", "east", "west")
--Returns false if something unbreakable in the way
Turning
turnLeft()
-Turns left, updates GPS dir
turnRight()
-Turns right, updates GPS dir
turnAround()
-Turns around, updates GPS dir
turnToDir(dir)
-Turns to direction specified (north, south, east, west &lt;- As strings)
GPS/Location
Note: Upon importing moveAPI for the first time, your coordinates will start as: 0,0,0,"north". This is for those who wish to build programs which only abide by relative coordinates more useful. (ie, going to starting location would be move.goto(0,0,0,"north")
setCoords(x,y,z,dir)
-Sets the coordinates to those provided (used for exact coordinate systems)
getCoords()
--Returns the x,y,z,dir of the turtle's current coordinates
getCoordsTbl()
--Returns the x,y,z,dir table (great for easily setting locations you can pass into moveTo and travel())
getX()
--Returns current X coordinate
getY()
--Returns current Y coordinate
getZ()
--Returns current Z coordinate
getDir()
--Returns current Direction
getFront()
--Returns x,y,z of space immediately in front of turtle
getFrontTbl()
--Returns table containing x,y,z of space immediately in front of turtle
Advanced Movement
Note: moveTo() and travel() CAN utilize pathfinding. To deactivate it, move.setPathFinding(false). By doing this, at any obstacle the turtle cannot overcome, it will return false for that function, instead.
moveTo(x,y,z, , dir[axisCustomize if you want])
-Goes to the coordinates provided. If you enter 4 coordinate requirements into a table, you can pass the table in as replacement. Proper usage if using a coordinate table is:
--Returns true or false
coords = {xInt, yInt, zInt, dirString}
moveTo(coords)
or if you want to customize whether the turtle solves for which axis in which order (default is x, then y, then z)moveTo(xCoord, yCoord, zCoord, dir, "x", "z", "y") --Goes to specified coordinates, then follows x axis, then z axis, then y axis.or
home = {0,0,0,"north"}
moveTo(home, "y","z","x") --Goes to coordinates in home table but follows y axis first, then z, then x to get there
fMoveTo(x,y,z, dir, [axisCustomize if you want])
-Goes to the coordinates provided. Digs/attacks things out of the way if needed. For further usage instructions, follow moveTo() instructions
--Returns false if cannot move.
move(direction, distance)
-Goes in the direction specified for the number of blocks specified (accepted directions are "north", "south", "east", "west")
--Returns false if cannot move.
navigate(x,y,z,dir)
-A chunkload hack used to move anywhere on a map regardless of loaded chunks. Requires turtle have a ChickenChunks chunkloader.
-!Notice: If the server reboots when the turtle is moving and no chunkloader is placed, the turtle will cease. If you have your programs auto-restart, just reexecute travel and you should be fine. Check your turtle has his loader, first before continuing (look up)
-Notice 2: I highly suggest you have the turtle navigate to a y-level out of range first (or just moveTo if that area will be loaded), THEN run your travel() to whereever. Less stuff to run into that way.
Example:
turtle.moveTo(turtle.getX(),120, turtle.getZ()) turtle.travel(location)
--Returns false if it gets stuck (warded blocks or bedrock, likely)
setChunkSlot(slotNum)
-Sets the slot the turtle will look for the chunkloader in.
setPathFinding(setting)
-Turns on or off pathfinding for moveTo and travel() (only two functions which utilize it). On by default.
Random
refuel(refuelAmount)
-Attempts to refuel from selected slot. Returns false if failed.
Credits
-Sangar who I found out (85% into this project), had made something extremely similar for an older version. Sangar, I am borrowing your awesome idea to use fuel-level checks to compare for persistence. Thank you, much!
-Inari in IRC: Your help in various questions I had (I learned as I went) was greatly appreciated (and your massive code condensation help).
-Random IRC/forum people I poked regarding various aspects of stuff, mostly about how the heck Lua does function table overwrites
- ComputerCraft | Programmable Computers for Minecraft
- → Noiro's Content


